summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
Diffstat (limited to 'Doc')
-rw-r--r--Doc/api/abstract.tex6
-rw-r--r--Doc/api/concrete.tex40
-rw-r--r--Doc/api/init.tex2
-rw-r--r--Doc/api/memory.tex7
-rw-r--r--Doc/api/newtypes.tex2
-rw-r--r--Doc/api/utilities.tex91
-rw-r--r--Doc/commontex/copyright.tex2
-rw-r--r--Doc/commontex/license.tex3
-rw-r--r--Doc/dist/dist.tex14
-rw-r--r--Doc/ext/newtypes.tex97
-rw-r--r--Doc/ext/shoddy.c91
-rw-r--r--Doc/inst/inst.tex2
-rw-r--r--Doc/lib/compiler.tex3
-rw-r--r--Doc/lib/email.tex4
-rw-r--r--Doc/lib/emailutil.tex4
-rw-r--r--Doc/lib/libamoeba.tex29
-rw-r--r--Doc/lib/libasyncore.tex2
-rw-r--r--Doc/lib/libbsddb.tex27
-rw-r--r--Doc/lib/libcfgparser.tex42
-rw-r--r--Doc/lib/libcgitb.tex6
-rw-r--r--Doc/lib/libcmath.tex9
-rw-r--r--Doc/lib/libcmd.tex44
-rw-r--r--Doc/lib/libcode.tex18
-rw-r--r--Doc/lib/libcodecs.tex14
-rw-r--r--Doc/lib/libcollections.tex66
-rw-r--r--Doc/lib/libcommands.tex4
-rw-r--r--Doc/lib/libconsts.tex2
-rw-r--r--Doc/lib/libcookielib.tex34
-rwxr-xr-xDoc/lib/libctypes.tex23
-rw-r--r--Doc/lib/libcurses.tex16
-rw-r--r--Doc/lib/libcursespanel.tex24
-rw-r--r--Doc/lib/libdatetime.tex8
-rw-r--r--Doc/lib/libdbhash.tex1
-rw-r--r--Doc/lib/libdecimal.tex2
-rw-r--r--Doc/lib/libdl.tex6
-rw-r--r--Doc/lib/libdoctest.tex31
-rw-r--r--Doc/lib/libdocxmlrpc.tex20
-rw-r--r--Doc/lib/libdumbdbm.tex2
-rw-r--r--Doc/lib/libetree.tex36
-rw-r--r--Doc/lib/libfm.tex25
-rw-r--r--Doc/lib/libfnmatch.tex31
-rw-r--r--Doc/lib/libftplib.tex61
-rw-r--r--Doc/lib/libfuncs.tex26
-rw-r--r--Doc/lib/libgettext.tex4
-rw-r--r--Doc/lib/libhmac.tex2
-rw-r--r--Doc/lib/libhotshot.tex16
-rw-r--r--Doc/lib/libhtmllib.tex14
-rw-r--r--Doc/lib/libhtmlparser.tex18
-rw-r--r--Doc/lib/libhttplib.tex53
-rw-r--r--Doc/lib/libimaplib.tex98
-rw-r--r--Doc/lib/liblogging.tex75
-rw-r--r--Doc/lib/libmailbox.tex9
-rw-r--r--Doc/lib/libmimetools.tex12
-rw-r--r--Doc/lib/libmimetypes.tex24
-rw-r--r--Doc/lib/libmimewriter.tex14
-rw-r--r--Doc/lib/libmmap.tex26
-rw-r--r--Doc/lib/libmsilib.tex38
-rw-r--r--Doc/lib/libmultifile.tex26
-rw-r--r--Doc/lib/libmutex.tex8
-rw-r--r--Doc/lib/libnetrc.tex8
-rw-r--r--Doc/lib/libnntplib.tex48
-rw-r--r--Doc/lib/liboptparse.tex2
-rw-r--r--Doc/lib/libos.tex24
-rw-r--r--Doc/lib/libpdb.tex8
-rw-r--r--Doc/lib/libpipes.tex14
-rw-r--r--Doc/lib/libplatform.tex17
-rw-r--r--Doc/lib/libpopen2.tex13
-rw-r--r--Doc/lib/libpoplib.tex42
-rw-r--r--Doc/lib/libposixfile.tex21
-rw-r--r--Doc/lib/libposixpath.tex33
-rw-r--r--Doc/lib/libpprint.tex10
-rw-r--r--Doc/lib/libqueue.tex18
-rw-r--r--Doc/lib/libre.tex2
-rw-r--r--Doc/lib/librepr.tex28
-rw-r--r--Doc/lib/librexec.tex42
-rw-r--r--Doc/lib/librfc822.tex50
-rw-r--r--Doc/lib/libsched.tex10
-rw-r--r--Doc/lib/libselect.tex6
-rw-r--r--Doc/lib/libshlex.tex42
-rw-r--r--Doc/lib/libshutil.tex4
-rw-r--r--Doc/lib/libsimplexmlrpc.tex25
-rw-r--r--Doc/lib/libsite.tex17
-rw-r--r--Doc/lib/libsmtplib.tex51
-rw-r--r--Doc/lib/libsocket.tex23
-rw-r--r--Doc/lib/libsqlite3.tex34
-rw-r--r--Doc/lib/libstdtypes.tex98
-rw-r--r--Doc/lib/libstring.tex3
-rw-r--r--Doc/lib/libsubprocess.tex16
-rw-r--r--Doc/lib/libsun.tex2
-rw-r--r--Doc/lib/libsys.tex4
-rw-r--r--Doc/lib/libtarfile.tex157
-rw-r--r--Doc/lib/libtelnetlib.tex46
-rw-r--r--Doc/lib/libtempfile.tex22
-rw-r--r--Doc/lib/libtest.tex44
-rw-r--r--Doc/lib/libtextwrap.tex9
-rw-r--r--Doc/lib/libthreading.tex68
-rw-r--r--Doc/lib/libtimeit.tex27
-rw-r--r--Doc/lib/libturtle.tex2
-rw-r--r--Doc/lib/libunittest.tex20
-rw-r--r--Doc/lib/liburllib2.tex7
-rw-r--r--Doc/lib/liburlparse.tex2
-rw-r--r--Doc/lib/libwebbrowser.tex12
-rw-r--r--Doc/lib/libwinreg.tex6
-rw-r--r--Doc/lib/libxmlrpclib.tex24
-rw-r--r--Doc/lib/libzipfile.tex28
-rw-r--r--Doc/lib/libzlib.tex4
-rw-r--r--Doc/mac/libframework.tex4
-rw-r--r--Doc/mac/libmacic.tex10
-rw-r--r--Doc/mac/undoc.tex4
-rw-r--r--Doc/mac/using.tex308
-rw-r--r--Doc/ref/ref1.tex2
-rw-r--r--Doc/ref/ref3.tex97
-rw-r--r--Doc/ref/ref5.tex186
-rw-r--r--Doc/ref/ref6.tex34
-rw-r--r--Doc/ref/ref7.tex2
-rw-r--r--Doc/texinputs/python.sty16
-rw-r--r--Doc/tut/tut.tex33
-rw-r--r--Doc/whatsnew/whatsnew23.tex2
-rw-r--r--Doc/whatsnew/whatsnew24.tex2
-rw-r--r--Doc/whatsnew/whatsnew25.tex15
-rw-r--r--Doc/whatsnew/whatsnew26.tex121
121 files changed, 2219 insertions, 1224 deletions
diff --git a/Doc/api/abstract.tex b/Doc/api/abstract.tex
index f292972..c5b53d7 100644
--- a/Doc/api/abstract.tex
+++ b/Doc/api/abstract.tex
@@ -790,7 +790,7 @@ determination.
the Python statement \samp{del \var{o}[\var{i1}:\var{i2}]}.
\end{cfuncdesc}
-\begin{cfuncdesc}{int}{PySequence_Count}{PyObject *o, PyObject *value}
+\begin{cfuncdesc}{Py_ssize_t}{PySequence_Count}{PyObject *o, PyObject *value}
Return the number of occurrences of \var{value} in \var{o}, that is,
return the number of keys for which \code{\var{o}[\var{key}] ==
\var{value}}. On failure, return \code{-1}. This is equivalent to
@@ -804,7 +804,7 @@ determination.
expression \samp{\var{value} in \var{o}}.
\end{cfuncdesc}
-\begin{cfuncdesc}{int}{PySequence_Index}{PyObject *o, PyObject *value}
+\begin{cfuncdesc}{Py_ssize_t}{PySequence_Index}{PyObject *o, PyObject *value}
Return the first index \var{i} for which \code{\var{o}[\var{i}] ==
\var{value}}. On error, return \code{-1}. This is equivalent to
the Python expression \samp{\var{o}.index(\var{value})}.
@@ -854,7 +854,7 @@ determination.
\versionadded{2.3}
\end{cfuncdesc}
-\begin{cfuncdesc}{int}{PySequence_Fast_GET_SIZE}{PyObject *o}
+\begin{cfuncdesc}{Py_ssize_t}{PySequence_Fast_GET_SIZE}{PyObject *o}
Returns the length of \var{o}, assuming that \var{o} was
returned by \cfunction{PySequence_Fast()} and that \var{o} is
not \NULL. The size can also be gotten by calling
diff --git a/Doc/api/concrete.tex b/Doc/api/concrete.tex
index 630a726..cdf6856 100644
--- a/Doc/api/concrete.tex
+++ b/Doc/api/concrete.tex
@@ -442,7 +442,9 @@ booleans. The following macros are available, however.
\begin{cfuncdesc}{double}{PyFloat_AsDouble}{PyObject *pyfloat}
Return a C \ctype{double} representation of the contents of
- \var{pyfloat}.
+ \var{pyfloat}. If \var{pyfloat} is not a Python floating point
+ object but has a \method{__float__} method, this method will first
+ be called to convert \var{pyfloat} into a float.
\end{cfuncdesc}
\begin{cfuncdesc}{double}{PyFloat_AS_DOUBLE}{PyObject *pyfloat}
@@ -557,8 +559,11 @@ typedef struct {
\end{cfuncdesc}
\begin{cfuncdesc}{Py_complex}{PyComplex_AsCComplex}{PyObject *op}
- Return the \ctype{Py_complex} value of the complex number
- \var{op}.
+ Return the \ctype{Py_complex} value of the complex number \var{op}.
+ \versionchanged[If \var{op} is not a Python complex number object
+ but has a \method{__complex__} method, this method
+ will first be called to convert \var{op} to a Python
+ complex number object]{2.6}
\end{cfuncdesc}
@@ -2156,6 +2161,35 @@ def PyDict_MergeFromSeq2(a, seq2, override):
\section{Other Objects \label{otherObjects}}
+\subsection{Class Objects \label{classObjects}}
+
+\obindex{class}
+Note that the class objects described here represent old-style classes,
+which will go away in Python 3. When creating new types for extension
+modules, you will want to work with type objects (section
+\ref{typeObjects}).
+
+\begin{ctypedesc}{PyClassObject}
+ The C structure of the objects used to describe built-in classes.
+\end{ctypedesc}
+
+\begin{cvardesc}{PyObject*}{PyClass_Type}
+ This is the type object for class objects; it is the same object as
+ \code{types.ClassType} in the Python layer.
+ \withsubitem{(in module types)}{\ttindex{ClassType}}
+\end{cvardesc}
+
+\begin{cfuncdesc}{int}{PyClass_Check}{PyObject *o}
+ Return true if the object \var{o} is a class object, including
+ instances of types derived from the standard class object. Return
+ false in all other cases.
+\end{cfuncdesc}
+
+\begin{cfuncdesc}{int}{PyClass_IsSubclass}{PyObject *klass, PyObject *base}
+ Return true if \var{klass} is a subclass of \var{base}. Return false in
+ all other cases.
+\end{cfuncdesc}
+
\subsection{File Objects \label{fileObjects}}
\obindex{file}
diff --git a/Doc/api/init.tex b/Doc/api/init.tex
index e380bdb..76fcf61 100644
--- a/Doc/api/init.tex
+++ b/Doc/api/init.tex
@@ -245,7 +245,7 @@
program name (set by \cfunction{Py_SetProgramName()} above) and some
environment variables. The returned string consists of a series of
directory names separated by a platform dependent delimiter
- character. The delimiter character is \character{:} on \UNIX and Mac OS X,
+ character. The delimiter character is \character{:} on \UNIX{} and Mac OS X,
\character{;} on Windows. The returned string points into
static storage; the caller should not modify its value. The value
is available to Python code as the list
diff --git a/Doc/api/memory.tex b/Doc/api/memory.tex
index 4bc2c7a..18abe98 100644
--- a/Doc/api/memory.tex
+++ b/Doc/api/memory.tex
@@ -100,7 +100,9 @@ are available for allocating and releasing memory from the Python heap:
memory block is resized but is not freed, and the returned pointer
is non-\NULL. Unless \var{p} is \NULL, it must have been
returned by a previous call to \cfunction{PyMem_Malloc()} or
- \cfunction{PyMem_Realloc()}.
+ \cfunction{PyMem_Realloc()}. If the request fails,
+ \cfunction{PyMem_Realloc()} returns \NULL{} and \var{p} remains a
+ valid pointer to the previous memory area.
\end{cfuncdesc}
\begin{cfuncdesc}{void}{PyMem_Free}{void *p}
@@ -124,7 +126,8 @@ that \var{TYPE} refers to any C type.
\begin{cfuncdesc}{\var{TYPE}*}{PyMem_Resize}{void *p, TYPE, size_t n}
Same as \cfunction{PyMem_Realloc()}, but the memory block is resized
to \code{(\var{n} * sizeof(\var{TYPE}))} bytes. Returns a pointer
- cast to \ctype{\var{TYPE}*}.
+ cast to \ctype{\var{TYPE}*}. On return, \var{p} will be a pointer to
+ the new memory area, or \NULL{} in the event of failure.
\end{cfuncdesc}
\begin{cfuncdesc}{void}{PyMem_Del}{void *p}
diff --git a/Doc/api/newtypes.tex b/Doc/api/newtypes.tex
index af1aed3..77ad7a5 100644
--- a/Doc/api/newtypes.tex
+++ b/Doc/api/newtypes.tex
@@ -1316,7 +1316,7 @@ PyObject *tp_alloc(PyTypeObject *self, Py_ssize_t nitems)
This field is inherited by static subtypes, but not by dynamic
subtypes (subtypes created by a class statement); in the latter,
- this field is always set to \cfunction{PyType_GenericAlloc()}, to
+ this field is always set to \cfunction{PyType_GenericAlloc}, to
force a standard heap allocation strategy. That is also the
recommended value for statically defined types.
\end{cmemberdesc}
diff --git a/Doc/api/utilities.tex b/Doc/api/utilities.tex
index 5a6f0b0..93e3796 100644
--- a/Doc/api/utilities.tex
+++ b/Doc/api/utilities.tex
@@ -930,3 +930,94 @@ PyArg_ParseTuple(args, "O|O:ref", &object, &callback)
If there is an error in the format string, the
\exception{SystemError} exception is set and \NULL{} returned.
\end{cfuncdesc}
+
+\section{String conversion and formatting \label{string-formatting}}
+
+Functions for number conversion and formatted string output.
+
+\begin{cfuncdesc}{int}{PyOS_snprintf}{char *str, size_t size,
+ const char *format, \moreargs}
+Output not more than \var{size} bytes to \var{str} according to the format
+string \var{format} and the extra arguments. See the \UNIX{} man
+page \manpage{snprintf}{2}.
+\end{cfuncdesc}
+
+\begin{cfuncdesc}{int}{PyOS_vsnprintf}{char *str, size_t size,
+ const char *format, va_list va}
+Output not more than \var{size} bytes to \var{str} according to the format
+string \var{format} and the variable argument list \var{va}. \UNIX{}
+man page \manpage{vsnprintf}{2}.
+\end{cfuncdesc}
+
+\cfunction{PyOS_snprintf} and \cfunction{PyOS_vsnprintf} wrap the
+Standard C library functions \cfunction{snprintf()} and
+\cfunction{vsnprintf()}. Their purpose is to guarantee consistent
+behavior in corner cases, which the Standard C functions do not.
+
+The wrappers ensure that \var{str}[\var{size}-1] is always
+\character{\textbackslash0} upon return. They never write more than
+\var{size} bytes (including the trailing \character{\textbackslash0}
+into str. Both functions require that \code{\var{str} != NULL},
+\code{\var{size} > 0} and \code{\var{format} != NULL}.
+
+If the platform doesn't have \cfunction{vsnprintf()} and the buffer
+size needed to avoid truncation exceeds \var{size} by more than 512
+bytes, Python aborts with a \var{Py_FatalError}.
+
+The return value (\var{rv}) for these functions should be interpreted
+as follows:
+
+\begin{itemize}
+
+\item When \code{0 <= \var{rv} < \var{size}}, the output conversion
+ was successful and \var{rv} characters were written to \var{str}
+ (excluding the trailing \character{\textbackslash0} byte at
+ \var{str}[\var{rv}]).
+
+\item When \code{\var{rv} >= \var{size}}, the output conversion was
+ truncated and a buffer with \code{\var{rv} + 1} bytes would have
+ been needed to succeed. \var{str}[\var{size}-1] is
+ \character{\textbackslash0} in this case.
+
+\item When \code{\var{rv} < 0}, ``something bad happened.''
+ \var{str}[\var{size}-1] is \character{\textbackslash0} in this case
+ too, but the rest of \var{str} is undefined. The exact cause of the
+ error depends on the underlying platform.
+
+\end{itemize}
+
+The following functions provide locale-independent string to number
+conversions.
+
+\begin{cfuncdesc}{double}{PyOS_ascii_strtod}{const char *nptr, char **endptr}
+Convert a string to a \ctype{double}. This function behaves like the
+Standard C function \cfunction{strtod()} does in the C locale. It does
+this without changing the current locale, since that would not be
+thread-safe.
+
+\cfunction{PyOS_ascii_strtod} should typically be used for reading
+configuration files or other non-user input that should be locale
+independent. \versionadded{2.4}
+
+See the \UNIX{} man page \manpage{strtod}{2} for details.
+
+\end{cfuncdesc}
+
+\begin{cfuncdesc}{char *}{PyOS_ascii_formatd}{char *buffer, size_t buf_len,
+ const char *format, double d}
+Convert a \ctype{double} to a string using the \character{.} as the
+decimal separator. \var{format} is a \cfunction{printf()}-style format
+string specifying the number format. Allowed conversion characters are
+\character{e}, \character{E}, \character{f}, \character{F},
+\character{g} and \character{G}.
+
+The return value is a pointer to \var{buffer} with the converted
+string or NULL if the conversion failed. \versionadded{2.4}
+\end{cfuncdesc}
+
+\begin{cfuncdesc}{double}{PyOS_ascii_atof}{const char *nptr}
+Convert a string to a \ctype{double} in a locale-independent
+way. \versionadded{2.4}
+
+See the \UNIX{} man page \manpage{atof}{2} for details.
+\end{cfuncdesc}
diff --git a/Doc/commontex/copyright.tex b/Doc/commontex/copyright.tex
index 05f15a1..ce70d0c 100644
--- a/Doc/commontex/copyright.tex
+++ b/Doc/commontex/copyright.tex
@@ -1,4 +1,4 @@
-Copyright \copyright{} 2001-2006 Python Software Foundation.
+Copyright \copyright{} 2001-2007 Python Software Foundation.
All rights reserved.
Copyright \copyright{} 2000 BeOpen.com.
diff --git a/Doc/commontex/license.tex b/Doc/commontex/license.tex
index c98a2c3..fe6485c 100644
--- a/Doc/commontex/license.tex
+++ b/Doc/commontex/license.tex
@@ -52,6 +52,7 @@ GPL-compatible; the table below summarizes the various releases.
\linev{2.4.3}{2.4.2}{2006}{PSF}{yes}
\linev{2.4.4}{2.4.3}{2006}{PSF}{yes}
\linev{2.5}{2.4}{2006}{PSF}{yes}
+ \linev{2.5.1}{2.5}{2007}{PSF}{yes}
\end{tablev}
\note{GPL-compatible doesn't mean that we're distributing
@@ -82,7 +83,7 @@ license to reproduce, analyze, test, perform and/or display publicly,
prepare derivative works, distribute, and otherwise use Python
\version{} alone or in any derivative version, provided, however, that
PSF's License Agreement and PSF's notice of copyright, i.e.,
-``Copyright \copyright{} 2001-2006 Python Software Foundation; All
+``Copyright \copyright{} 2001-2007 Python Software Foundation; All
Rights Reserved'' are retained in Python \version{} alone or in any
derivative version prepared by Licensee.
diff --git a/Doc/dist/dist.tex b/Doc/dist/dist.tex
index 7a0f073..928b642 100644
--- a/Doc/dist/dist.tex
+++ b/Doc/dist/dist.tex
@@ -1802,9 +1802,9 @@ example:
setup.py
foo.py
\end{verbatim}
-(In all diagrams in this section, \verb|<root>| will refer to the
-distribution root directory.) A minimal setup script to describe this
-situation would be:
+(In all diagrams in this section, \var{\textless root\textgreater}
+will refer to the distribution root directory.) A minimal setup script
+to describe this situation would be:
\begin{verbatim}
from distutils.core import setup
setup(name='foo',
@@ -3179,7 +3179,7 @@ for any variables not found in either \var{local_vars} or \code{os.environ}.
Note that this is not a fully-fledged string interpolation function. A
valid \code{\$variable} can consist only of upper and lower case letters,
-numbers and an underscore. No \{ \} or \( \) style quoting is available.
+numbers and an underscore. No \{ \} or ( ) style quoting is available.
\end{funcdesc}
\begin{funcdesc}{grok_environment_error}{exc\optional{, prefix=\samp{'error: '}}}
@@ -3733,7 +3733,7 @@ implementing the class \class{peel_banana}, a subclass of
Subclasses of \class{Command} must define the following methods.
-\begin{methoddesc}{initialize_options()}
+\begin{methoddesc}[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
@@ -3742,7 +3742,7 @@ between options; generally, \method{initialize_options()} implementations
are just a bunch of \samp{self.foo = None} assignments.
\end{methoddesc}
-\begin{methoddesc}{finalize_options}{}
+\begin{methoddesc}[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
@@ -3751,7 +3751,7 @@ done. Thus, this is the place to to code option dependencies: if
\var{bar} as long as \var{foo} still has the same value it was assigned in
\method{initialize_options()}.
\end{methoddesc}
-\begin{methoddesc}{run}{}
+\begin{methoddesc}[Command]{run}{}
A command's raison d'etre: carry out the action it exists to
perform, controlled by the options initialized in
\method{initialize_options()}, customized by other commands, the setup
diff --git a/Doc/ext/newtypes.tex b/Doc/ext/newtypes.tex
index a485a15..5c1f0ae 100644
--- a/Doc/ext/newtypes.tex
+++ b/Doc/ext/newtypes.tex
@@ -489,7 +489,6 @@ this?
garbage collection, there are calls that can be made to ``untrack''
the object from garbage collection, however, these calls are
advanced and not covered here.}
-\item
\end{itemize}
@@ -930,6 +929,102 @@ That's pretty much it. If we had written custom \member{tp_alloc} or
collection. Most extensions will use the versions automatically
provided.
+\subsection{Subclassing other types}
+
+It is possible to create new extension types that are derived from existing
+types. It is easiest to inherit from the built in types, since an extension
+can easily use the \class{PyTypeObject} it needs. It can be difficult to
+share these \class{PyTypeObject} structures between extension modules.
+
+In this example we will create a \class{Shoddy} type that inherits from
+the builtin \class{list} type. The new type will be completely compatible
+with regular lists, but will have an additional \method{increment()} method
+that increases an internal counter.
+
+\begin{verbatim}
+>>> import shoddy
+>>> s = shoddy.Shoddy(range(3))
+>>> s.extend(s)
+>>> print len(s)
+6
+>>> print s.increment()
+1
+>>> print s.increment()
+2
+\end{verbatim}
+
+\verbatiminput{shoddy.c}
+
+As you can see, the source code closely resembles the \class{Noddy} examples in previous
+sections. We will break down the main differences between them.
+
+\begin{verbatim}
+typedef struct {
+ PyListObject list;
+ int state;
+} Shoddy;
+\end{verbatim}
+
+The primary difference for derived type objects is that the base type's
+object structure must be the first value. The base type will already
+include the \cfunction{PyObject_HEAD} at the beginning of its structure.
+
+When a Python object is a \class{Shoddy} instance, its \var{PyObject*} pointer
+can be safely cast to both \var{PyListObject*} and \var{Shoddy*}.
+
+\begin{verbatim}
+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;
+}
+\end{verbatim}
+
+In the \member{__init__} method for our type, we can see how to call through
+to the \member{__init__} method of the base type.
+
+This pattern is important when writing a type with custom \member{new} and
+\member{dealloc} methods. The \member{new} method should not actually create the
+memory for the object with \member{tp_alloc}, that will be handled by
+the base class when calling its \member{tp_new}.
+
+When filling out the \cfunction{PyTypeObject} for the \class{Shoddy} type,
+you see a slot for \cfunction{tp_base}. Due to cross platform compiler
+issues, you can't fill that field directly with the \cfunction{PyList_Type};
+it can be done later in the module's \cfunction{init} function.
+
+\begin{verbatim}
+PyMODINIT_FUNC
+initshoddy(void)
+{
+ PyObject *m;
+
+ ShoddyType.tp_base = &PyList_Type;
+ if (PyType_Ready(&ShoddyType) < 0)
+ return;
+
+ m = Py_InitModule3("shoddy", NULL, "Shoddy module");
+ if (m == NULL)
+ return;
+
+ Py_INCREF(&ShoddyType);
+ PyModule_AddObject(m, "Shoddy", (PyObject *) &ShoddyType);
+}
+\end{verbatim}
+
+Before calling \cfunction{PyType_Ready}, the type structure must have the
+\member{tp_base} slot filled in. When we are deriving a new type, it is
+not necessary to fill out the \member{tp_alloc} slot with
+\cfunction{PyType_GenericNew} -- the allocate function from the base type
+will be inherited.
+
+After that, calling \cfunction{PyType_Ready} and adding the type object
+to the module is the same as with the basic \class{Noddy} examples.
+
+
\section{Type Methods
\label{dnt-type-methods}}
diff --git a/Doc/ext/shoddy.c b/Doc/ext/shoddy.c
new file mode 100644
index 0000000..07a4177
--- /dev/null
+++ b/Doc/ext/shoddy.c
@@ -0,0 +1,91 @@
+#include <Python.h>
+
+typedef struct {
+ PyListObject list;
+ int state;
+} Shoddy;
+
+
+static PyObject *
+Shoddy_increment(Shoddy *self, PyObject *unused)
+{
+ self->state++;
+ return PyInt_FromLong(self->state);
+}
+
+
+static PyMethodDef Shoddy_methods[] = {
+ {"increment", (PyCFunction)Shoddy_increment, METH_NOARGS,
+ PyDoc_STR("increment state counter")},
+ {NULL, NULL},
+};
+
+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;
+}
+
+
+static PyTypeObject ShoddyType = {
+ PyObject_HEAD_INIT(NULL)
+ 0, /* ob_size */
+ "shoddy.Shoddy", /* tp_name */
+ sizeof(Shoddy), /* tp_basicsize */
+ 0, /* tp_itemsize */
+ 0, /* tp_dealloc */
+ 0, /* tp_print */
+ 0, /* tp_getattr */
+ 0, /* tp_setattr */
+ 0, /* tp_compare */
+ 0, /* tp_repr */
+ 0, /* tp_as_number */
+ 0, /* tp_as_sequence */
+ 0, /* tp_as_mapping */
+ 0, /* tp_hash */
+ 0, /* tp_call */
+ 0, /* tp_str */
+ 0, /* tp_getattro */
+ 0, /* tp_setattro */
+ 0, /* tp_as_buffer */
+ Py_TPFLAGS_DEFAULT |
+ Py_TPFLAGS_BASETYPE, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ 0, /* tp_weaklistoffset */
+ 0, /* tp_iter */
+ 0, /* tp_iternext */
+ Shoddy_methods, /* tp_methods */
+ 0, /* tp_members */
+ 0, /* tp_getset */
+ 0, /* tp_base */
+ 0, /* tp_dict */
+ 0, /* tp_descr_get */
+ 0, /* tp_descr_set */
+ 0, /* tp_dictoffset */
+ (initproc)Shoddy_init, /* tp_init */
+ 0, /* tp_alloc */
+ 0, /* tp_new */
+};
+
+PyMODINIT_FUNC
+initshoddy(void)
+{
+ PyObject *m;
+
+ ShoddyType.tp_base = &PyList_Type;
+ if (PyType_Ready(&ShoddyType) < 0)
+ return;
+
+ m = Py_InitModule3("shoddy", NULL, "Shoddy module");
+ if (m == NULL)
+ return;
+
+ Py_INCREF(&ShoddyType);
+ PyModule_AddObject(m, "Shoddy", (PyObject *) &ShoddyType);
+}
diff --git a/Doc/inst/inst.tex b/Doc/inst/inst.tex
index 6db22ac..adc686e 100644
--- a/Doc/inst/inst.tex
+++ b/Doc/inst/inst.tex
@@ -296,7 +296,7 @@ being installed is pure Python or contains extensions (``non-pure''):
\filevar{prefix} and \filevar{exec-prefix} stand for the directories
that Python is installed to, and where it finds its libraries at
run-time. They are always the same under Windows, and very
-often the same under \UNIX and Mac OS X. You can find out what your Python
+often the same under \UNIX{} and Mac OS X. You can find out what your Python
installation uses for \filevar{prefix} and \filevar{exec-prefix} by
running Python in interactive mode and typing a few simple commands.
Under \UNIX, just type \code{python} at the shell prompt. Under
diff --git a/Doc/lib/compiler.tex b/Doc/lib/compiler.tex
index f0926e7..d4f4124 100644
--- a/Doc/lib/compiler.tex
+++ b/Doc/lib/compiler.tex
@@ -103,8 +103,7 @@ Python. In the abstract syntax tree, each node represents a syntactic
construct. The root of the tree is \class{Module} object.
The abstract syntax offers a higher level interface to parsed Python
-source code. The \ulink{\module{parser}}
-{http://www.python.org/doc/current/lib/module-parser.html}
+source code. The \refmodule{parser}
module and the compiler written in C for the Python interpreter use a
concrete syntax tree. The concrete syntax is tied closely to the
grammar description used for the Python parser. Instead of a single
diff --git a/Doc/lib/email.tex b/Doc/lib/email.tex
index ea12705..47727a7 100644
--- a/Doc/lib/email.tex
+++ b/Doc/lib/email.tex
@@ -1,4 +1,4 @@
-% Copyright (C) 2001-2006 Python Software Foundation
+% Copyright (C) 2001-2007 Python Software Foundation
% Author: barry@python.org (Barry Warsaw)
\section{\module{email} ---
@@ -239,7 +239,7 @@ Here are the differences between \module{email} version 2 and version 1:
The \module{email} package was originally prototyped as a separate
library called
-\ulink{\module{mimelib}}{http://mimelib.sf.net/}.
+\ulink{\texttt{mimelib}}{http://mimelib.sf.net/}.
Changes have been made so that
method names are more consistent, and some methods or modules have
either been added or removed. The semantics of some of the methods
diff --git a/Doc/lib/emailutil.tex b/Doc/lib/emailutil.tex
index fe96473..f9fe2d4 100644
--- a/Doc/lib/emailutil.tex
+++ b/Doc/lib/emailutil.tex
@@ -56,7 +56,7 @@ however, some mailers don't follow that format as specified, so
\code{"Mon, 20 Nov 1995 19:12:08 -0500"}. If it succeeds in parsing
the date, \function{parsedate()} returns a 9-tuple that can be passed
directly to \function{time.mktime()}; otherwise \code{None} will be
-returned. Note that fields 6, 7, and 8 of the result tuple are not
+returned. Note that indexes 6, 7, and 8 of the result tuple are not
usable.
\end{funcdesc}
@@ -70,7 +70,7 @@ offset is the opposite of the sign of the \code{time.timezone}
variable for the same timezone; the latter variable follows the
\POSIX{} standard while this module follows \rfc{2822}.}. If the input
string has no timezone, the last element of the tuple returned is
-\code{None}. Note that fields 6, 7, and 8 of the result tuple are not
+\code{None}. Note that indexes 6, 7, and 8 of the result tuple are not
usable.
\end{funcdesc}
diff --git a/Doc/lib/libamoeba.tex b/Doc/lib/libamoeba.tex
index c3274db..ce6babc 100644
--- a/Doc/lib/libamoeba.tex
+++ b/Doc/lib/libamoeba.tex
@@ -89,25 +89,24 @@ aa:1c:95:52:6a:fa/14(ff)/8e:ba:5b:8:11:1a
%
The following methods are defined for capability objects.
-\setindexsubitem{(capability method)}
-\begin{funcdesc}{dir_list}{}
+\begin{methoddesc}[capability]{dir_list}{}
Returns a list of the names of the entries in an Amoeba directory.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{b_read}{offset, maxsize}
+\begin{methoddesc}[capability]{b_read}{offset, maxsize}
Reads (at most)
\var{maxsize}
bytes from a bullet file at offset
\var{offset.}
The data is returned as a string.
EOF is reported as an empty string.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{b_size}{}
+\begin{methoddesc}[capability]{b_size}{}
Returns the size of a bullet file.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{dir_append}{}
+\begin{methoddesc}[capability]{dir_append}{}
\funcline{dir_delete}{}
\funcline{dir_lookup}{}
\funcline{dir_replace}{}
@@ -116,17 +115,17 @@ Like the corresponding
functions, but with a path relative to the capability.
(For paths beginning with a slash the capability is ignored, since this
is the defined semantics for Amoeba.)
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{std_info}{}
+\begin{methoddesc}[capability]{std_info}{}
Returns the standard info string of the object.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{tod_gettime}{}
+\begin{methoddesc}[capability]{tod_gettime}{}
Returns the time (in seconds since the Epoch, in UCT, as for \POSIX) from
a time server.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{tod_settime}{t}
+\begin{methoddesc}[capability]{tod_settime}{t}
Sets the time kept by a time server.
-\end{funcdesc}
+\end{methoddesc}
diff --git a/Doc/lib/libasyncore.tex b/Doc/lib/libasyncore.tex
index 2067839..0552896 100644
--- a/Doc/lib/libasyncore.tex
+++ b/Doc/lib/libasyncore.tex
@@ -46,7 +46,7 @@ service) is closed.
\begin{funcdesc}{loop}{\optional{timeout\optional{, use_poll\optional{,
map\optional{,count}}}}}
Enter a polling loop that terminates after count passes or all open
- channels have been closed. All arguments are optional. The \var(count)
+ channels have been closed. All arguments are optional. The \var{count}
parameter defaults to None, resulting in the loop terminating only
when all channels have been closed. The \var{timeout} argument sets the
timeout parameter for the appropriate \function{select()} or
diff --git a/Doc/lib/libbsddb.tex b/Doc/lib/libbsddb.tex
index e9d7e21..6e86d24 100644
--- a/Doc/lib/libbsddb.tex
+++ b/Doc/lib/libbsddb.tex
@@ -2,7 +2,6 @@
Interface to Berkeley DB library}
\declaremodule{extension}{bsddb}
- \platform{Unix, Windows}
\modulesynopsis{Interface to Berkeley DB database library}
\sectionauthor{Skip Montanaro}{skip@mojam.com}
@@ -46,10 +45,10 @@ portability, only the first two arguments should be used in most
instances.
\begin{funcdesc}{hashopen}{filename\optional{, flag\optional{,
- mode\optional{, bsize\optional{,
+ mode\optional{, pgsize\optional{,
ffactor\optional{, nelem\optional{,
- cachesize\optional{, hash\optional{,
- lorder}}}}}}}}}
+ cachesize\optional{, lorder\optional{,
+ hflags}}}}}}}}}
Open the hash format file named \var{filename}. Files never intended
to be preserved on disk may be created by passing \code{None} as the
\var{filename}. The optional
@@ -80,7 +79,7 @@ interpretation.
\begin{funcdesc}{rnopen}{filename\optional{, flag\optional{, mode\optional{,
rnflags\optional{, cachesize\optional{, pgsize\optional{, lorder\optional{,
-reclen\optional{, bval\optional{, bfname}}}}}}}}}}
+rlen\optional{, delim\optional{, source\optional{, pad}}}}}}}}}}}
Open a DB record format file named \var{filename}. Files never intended
to be preserved on disk may be created by passing \code{None} as the
@@ -114,23 +113,23 @@ the same methods as dictionaries. In addition, they support
the methods listed below.
\versionchanged[Added dictionary methods]{2.3.1}
-\begin{methoddesc}{close}{}
+\begin{methoddesc}[bsddbobject]{close}{}
Close the underlying file. The object can no longer be accessed. Since
there is no open \method{open} method for these objects, to open the file
again a new \module{bsddb} module open function must be called.
\end{methoddesc}
-\begin{methoddesc}{keys}{}
+\begin{methoddesc}[bsddbobject]{keys}{}
Return the list of keys contained in the DB file. The order of the list is
unspecified and should not be relied on. In particular, the order of the
list returned is different for different file formats.
\end{methoddesc}
-\begin{methoddesc}{has_key}{key}
+\begin{methoddesc}[bsddbobject]{has_key}{key}
Return \code{1} if the DB file contains the argument as a key.
\end{methoddesc}
-\begin{methoddesc}{set_location}{key}
+\begin{methoddesc}[bsddbobject]{set_location}{key}
Set the cursor to the item indicated by \var{key} and return a tuple
containing the key and its value. For binary tree databases (opened
using \function{btopen()}), if \var{key} does not actually exist in
@@ -140,32 +139,32 @@ and return that key and value. For other databases,
database.
\end{methoddesc}
-\begin{methoddesc}{first}{}
+\begin{methoddesc}[bsddbobject]{first}{}
Set the cursor to the first item in the DB file and return it. The order of
keys in the file is unspecified, except in the case of B-Tree databases.
This method raises \exception{bsddb.error} if the database is empty.
\end{methoddesc}
-\begin{methoddesc}{next}{}
+\begin{methoddesc}[bsddbobject]{next}{}
Set the cursor to the next item in the DB file and return it. The order of
keys in the file is unspecified, except in the case of B-Tree databases.
\end{methoddesc}
-\begin{methoddesc}{previous}{}
+\begin{methoddesc}[bsddbobject]{previous}{}
Set the cursor to the previous item in the DB file and return it. The
order of keys in the file is unspecified, except in the case of B-Tree
databases. This is not supported on hashtable databases (those opened
with \function{hashopen()}).
\end{methoddesc}
-\begin{methoddesc}{last}{}
+\begin{methoddesc}[bsddbobject]{last}{}
Set the cursor to the last item in the DB file and return it. The
order of keys in the file is unspecified. This is not supported on
hashtable databases (those opened with \function{hashopen()}).
This method raises \exception{bsddb.error} if the database is empty.
\end{methoddesc}
-\begin{methoddesc}{sync}{}
+\begin{methoddesc}[bsddbobject]{sync}{}
Synchronize the database on disk.
\end{methoddesc}
diff --git a/Doc/lib/libcfgparser.tex b/Doc/lib/libcfgparser.tex
index 2c08ec4..a41aee1 100644
--- a/Doc/lib/libcfgparser.tex
+++ b/Doc/lib/libcfgparser.tex
@@ -155,37 +155,37 @@ the \var{raw} parameter is false. This is relevant only for the
\class{RawConfigParser} instances have the following methods:
-\begin{methoddesc}{defaults}{}
+\begin{methoddesc}[RawConfigParser]{defaults}{}
Return a dictionary containing the instance-wide defaults.
\end{methoddesc}
-\begin{methoddesc}{sections}{}
+\begin{methoddesc}[RawConfigParser]{sections}{}
Return a list of the sections available; \code{DEFAULT} is not
included in the list.
\end{methoddesc}
-\begin{methoddesc}{add_section}{section}
+\begin{methoddesc}[RawConfigParser]{add_section}{section}
Add a section named \var{section} to the instance. If a section by
the given name already exists, \exception{DuplicateSectionError} is
raised.
\end{methoddesc}
-\begin{methoddesc}{has_section}{section}
+\begin{methoddesc}[RawConfigParser]{has_section}{section}
Indicates whether the named section is present in the
configuration. The \code{DEFAULT} section is not acknowledged.
\end{methoddesc}
-\begin{methoddesc}{options}{section}
+\begin{methoddesc}[RawConfigParser]{options}{section}
Returns a list of options available in the specified \var{section}.
\end{methoddesc}
-\begin{methoddesc}{has_option}{section, option}
+\begin{methoddesc}[RawConfigParser]{has_option}{section, option}
If the given section exists, and contains the given option,
return \constant{True}; otherwise return \constant{False}.
\versionadded{1.6}
\end{methoddesc}
-\begin{methoddesc}{read}{filenames}
+\begin{methoddesc}[RawConfigParser]{read}{filenames}
Attempt to read and parse a list of filenames, returning a list of filenames
which were successfully parsed. If \var{filenames} is a string or
Unicode string, it is treated as a single filename.
@@ -210,28 +210,28 @@ config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
\versionchanged[Returns list of successfully parsed filenames]{2.4}
\end{methoddesc}
-\begin{methoddesc}{readfp}{fp\optional{, filename}}
+\begin{methoddesc}[RawConfigParser]{readfp}{fp\optional{, filename}}
Read and parse configuration data from the file or file-like object in
\var{fp} (only the \method{readline()} method is used). If
\var{filename} is omitted and \var{fp} has a \member{name} attribute,
that is used for \var{filename}; the default is \samp{<???>}.
\end{methoddesc}
-\begin{methoddesc}{get}{section, option}
+\begin{methoddesc}[RawConfigParser]{get}{section, option}
Get an \var{option} value for the named \var{section}.
\end{methoddesc}
-\begin{methoddesc}{getint}{section, option}
+\begin{methoddesc}[RawConfigParser]{getint}{section, option}
A convenience method which coerces the \var{option} in the specified
\var{section} to an integer.
\end{methoddesc}
-\begin{methoddesc}{getfloat}{section, option}
+\begin{methoddesc}[RawConfigParser]{getfloat}{section, option}
A convenience method which coerces the \var{option} in the specified
\var{section} to a floating point number.
\end{methoddesc}
-\begin{methoddesc}{getboolean}{section, option}
+\begin{methoddesc}[RawConfigParser]{getboolean}{section, option}
A convenience method which coerces the \var{option} in the specified
\var{section} to a Boolean value. Note that the accepted values
for the option are \code{"1"}, \code{"yes"}, \code{"true"}, and \code{"on"},
@@ -241,12 +241,12 @@ string values are checked in a case-insensitive manner. Any other value will
cause it to raise \exception{ValueError}.
\end{methoddesc}
-\begin{methoddesc}{items}{section}
+\begin{methoddesc}[RawConfigParser]{items}{section}
Return a list of \code{(\var{name}, \var{value})} pairs for each
option in the given \var{section}.
\end{methoddesc}
-\begin{methoddesc}{set}{section, option, value}
+\begin{methoddesc}[RawConfigParser]{set}{section, option, value}
If the given section exists, set the given option to the specified
value; otherwise raise \exception{NoSectionError}. While it is
possible to use \class{RawConfigParser} (or \class{ConfigParser} with
@@ -256,14 +256,14 @@ output to files) can only be achieved using string values.
\versionadded{1.6}
\end{methoddesc}
-\begin{methoddesc}{write}{fileobject}
+\begin{methoddesc}[RawConfigParser]{write}{fileobject}
Write a representation of the configuration to the specified file
object. This representation can be parsed by a future \method{read()}
call.
\versionadded{1.6}
\end{methoddesc}
-\begin{methoddesc}{remove_option}{section, option}
+\begin{methoddesc}[RawConfigParser]{remove_option}{section, option}
Remove the specified \var{option} from the specified \var{section}.
If the section does not exist, raise \exception{NoSectionError}.
If the option existed to be removed, return \constant{True};
@@ -271,13 +271,13 @@ otherwise return \constant{False}.
\versionadded{1.6}
\end{methoddesc}
-\begin{methoddesc}{remove_section}{section}
+\begin{methoddesc}[RawConfigParser]{remove_section}{section}
Remove the specified \var{section} from the configuration.
If the section in fact existed, return \code{True}.
Otherwise return \code{False}.
\end{methoddesc}
-\begin{methoddesc}{optionxform}{option}
+\begin{methoddesc}[RawConfigParser]{optionxform}{option}
Transforms the option name \var{option} as found in an input file or
as passed in by client code to the form that should be used in the
internal structures. The default implementation returns a lower-case
@@ -293,14 +293,14 @@ option names case sensitive.
The \class{ConfigParser} class extends some methods of the
\class{RawConfigParser} interface, adding some optional arguments.
-\begin{methoddesc}{get}{section, option\optional{, raw\optional{, vars}}}
+\begin{methoddesc}[ConfigParser]{get}{section, option\optional{, raw\optional{, vars}}}
Get an \var{option} value for the named \var{section}. All the
\character{\%} interpolations are expanded in the return values, based
on the defaults passed into the constructor, as well as the options
\var{vars} provided, unless the \var{raw} argument is true.
\end{methoddesc}
-\begin{methoddesc}{items}{section\optional{, raw\optional{, vars}}}
+\begin{methoddesc}[ConfigParser]{items}{section\optional{, raw\optional{, vars}}}
Return a list of \code{(\var{name}, \var{value})} pairs for each
option in the given \var{section}. Optional arguments have the
same meaning as for the \method{get()} method.
@@ -313,7 +313,7 @@ same meaning as for the \method{get()} method.
The \class{SafeConfigParser} class implements the same extended
interface as \class{ConfigParser}, with the following addition:
-\begin{methoddesc}{set}{section, option, value}
+\begin{methoddesc}[SafeConfigParser]{set}{section, option, value}
If the given section exists, set the given option to the specified
value; otherwise raise \exception{NoSectionError}. \var{value} must
be a string (\class{str} or \class{unicode}); if not,
diff --git a/Doc/lib/libcgitb.tex b/Doc/lib/libcgitb.tex
index c686fe6..ca9959f 100644
--- a/Doc/lib/libcgitb.tex
+++ b/Doc/lib/libcgitb.tex
@@ -38,7 +38,7 @@ to a file for later analysis.
context\optional{, format}}}}}
This function causes the \module{cgitb} module to take over the
interpreter's default handling for exceptions by setting the
- value of \code{\refmodule{sys}.excepthook}.
+ value of \member{\refmodule{sys}.excepthook}.
\withsubitem{(in module sys)}{\ttindex{excepthook()}}
The optional argument \var{display} defaults to \code{1} and can be set
@@ -61,7 +61,7 @@ to a file for later analysis.
report it using \module{cgitb}. The optional \var{info} argument
should be a 3-tuple containing an exception type, exception
value, and traceback object, exactly like the tuple returned by
- \code{\refmodule{sys}.exc_info()}. If the \var{info} argument
+ \function{\refmodule{sys}.exc_info()}. If the \var{info} argument
is not supplied, the current exception is obtained from
- \code{\refmodule{sys}.exc_info()}.
+ \function{\refmodule{sys}.exc_info()}.
\end{funcdesc}
diff --git a/Doc/lib/libcmath.tex b/Doc/lib/libcmath.tex
index 54e0cdb..f8aa45b 100644
--- a/Doc/lib/libcmath.tex
+++ b/Doc/lib/libcmath.tex
@@ -5,7 +5,14 @@
\modulesynopsis{Mathematical functions for complex numbers.}
This module is always available. It provides access to mathematical
-functions for complex numbers. The functions are:
+functions for complex numbers. The functions in this module accept
+integers, floating-point numbers or complex numbers as arguments.
+They will also accept any Python object that has either a
+\method{__complex__} or a \method{__float__} method: these methods are
+used to convert the object to a complex or floating-point number, respectively, and
+the function is then applied to the result of the conversion.
+
+The functions are:
\begin{funcdesc}{acos}{x}
Return the arc cosine of \var{x}.
diff --git a/Doc/lib/libcmd.tex b/Doc/lib/libcmd.tex
index 9fe8123..810f19c 100644
--- a/Doc/lib/libcmd.tex
+++ b/Doc/lib/libcmd.tex
@@ -37,7 +37,7 @@ will default to \var{sys.stdin} and \var{sys.stdout}.
A \class{Cmd} instance has the following methods:
-\begin{methoddesc}{cmdloop}{\optional{intro}}
+\begin{methoddesc}[Cmd]{cmdloop}{\optional{intro}}
Repeatedly issue a prompt, accept input, parse an initial prefix off
the received input, and dispatch to action methods, passing them the
remainder of the line as argument.
@@ -82,7 +82,7 @@ commands with corresponding \method{help_*()} methods), and also lists
any undocumented commands.
\end{methoddesc}
-\begin{methoddesc}{onecmd}{str}
+\begin{methoddesc}[Cmd]{onecmd}{str}
Interpret the argument as though it had been typed in response to the
prompt. This may be overridden, but should not normally need to be;
see the \method{precmd()} and \method{postcmd()} methods for useful
@@ -93,25 +93,25 @@ value of that method is returned, otherwise the return value from the
\method{default()} method is returned.
\end{methoddesc}
-\begin{methoddesc}{emptyline}{}
+\begin{methoddesc}[Cmd]{emptyline}{}
Method called when an empty line is entered in response to the prompt.
If this method is not overridden, it repeats the last nonempty command
entered.
\end{methoddesc}
-\begin{methoddesc}{default}{line}
+\begin{methoddesc}[Cmd]{default}{line}
Method called on an input line when the command prefix is not
recognized. If this method is not overridden, it prints an
error message and returns.
\end{methoddesc}
-\begin{methoddesc}{completedefault}{text, line, begidx, endidx}
+\begin{methoddesc}[Cmd]{completedefault}{text, line, begidx, endidx}
Method called to complete an input line when no command-specific
\method{complete_*()} method is available. By default, it returns an
empty list.
\end{methoddesc}
-\begin{methoddesc}{precmd}{line}
+\begin{methoddesc}[Cmd]{precmd}{line}
Hook method executed just before the command line \var{line} is
interpreted, but after the input prompt is generated and issued. This
method is a stub in \class{Cmd}; it exists to be overridden by
@@ -121,7 +121,7 @@ implementation may re-write the command or simply return \var{line}
unchanged.
\end{methoddesc}
-\begin{methoddesc}{postcmd}{stop, line}
+\begin{methoddesc}[Cmd]{postcmd}{stop, line}
Hook method executed just after a command dispatch is finished. This
method is a stub in \class{Cmd}; it exists to be overridden by
subclasses. \var{line} is the command line which was executed, and
@@ -133,13 +133,13 @@ corresponds to \var{stop}; returning false will cause interpretation
to continue.
\end{methoddesc}
-\begin{methoddesc}{preloop}{}
+\begin{methoddesc}[Cmd]{preloop}{}
Hook method executed once when \method{cmdloop()} is called. This
method is a stub in \class{Cmd}; it exists to be overridden by
subclasses.
\end{methoddesc}
-\begin{methoddesc}{postloop}{}
+\begin{methoddesc}[Cmd]{postloop}{}
Hook method executed once when \method{cmdloop()} is about to return.
This method is a stub in \class{Cmd}; it exists to be overridden by
subclasses.
@@ -147,42 +147,52 @@ subclasses.
Instances of \class{Cmd} subclasses have some public instance variables:
-\begin{memberdesc}{prompt}
+\begin{memberdesc}[Cmd]{prompt}
The prompt issued to solicit input.
\end{memberdesc}
-\begin{memberdesc}{identchars}
+\begin{memberdesc}[Cmd]{identchars}
The string of characters accepted for the command prefix.
\end{memberdesc}
-\begin{memberdesc}{lastcmd}
+\begin{memberdesc}[Cmd]{lastcmd}
The last nonempty command prefix seen.
\end{memberdesc}
-\begin{memberdesc}{intro}
+\begin{memberdesc}[Cmd]{intro}
A string to issue as an intro or banner. May be overridden by giving
the \method{cmdloop()} method an argument.
\end{memberdesc}
-\begin{memberdesc}{doc_header}
+\begin{memberdesc}[Cmd]{doc_header}
The header to issue if the help output has a section for documented
commands.
\end{memberdesc}
-\begin{memberdesc}{misc_header}
+\begin{memberdesc}[Cmd]{misc_header}
The header to issue if the help output has a section for miscellaneous
help topics (that is, there are \method{help_*()} methods without
corresponding \method{do_*()} methods).
\end{memberdesc}
-\begin{memberdesc}{undoc_header}
+\begin{memberdesc}[Cmd]{undoc_header}
The header to issue if the help output has a section for undocumented
commands (that is, there are \method{do_*()} methods without
corresponding \method{help_*()} methods).
\end{memberdesc}
-\begin{memberdesc}{ruler}
+\begin{memberdesc}[Cmd]{ruler}
The character used to draw separator lines under the help-message
headers. If empty, no ruler line is drawn. It defaults to
\character{=}.
\end{memberdesc}
+
+\begin{memberdesc}[Cmd]{use_rawinput}
+A flag, defaulting to true. If true, \method{cmdloop()} uses
+\function{input()} to display a prompt and read the next command;
+if false, \method{sys.stdout.write()} and
+\method{sys.stdin.readline()} are used. (This means that by
+importing \refmodule{readline}, on systems that support it, the
+interpreter will automatically support \program{Emacs}-like line editing
+and command-history keystrokes.)
+\end{memberdesc}
diff --git a/Doc/lib/libcode.tex b/Doc/lib/libcode.tex
index 628a1eb..8e14b02 100644
--- a/Doc/lib/libcode.tex
+++ b/Doc/lib/libcode.tex
@@ -68,7 +68,7 @@ syntax error, or raises \exception{OverflowError} or
\subsection{Interactive Interpreter Objects
\label{interpreter-objects}}
-\begin{methoddesc}{runsource}{source\optional{, filename\optional{, symbol}}}
+\begin{methoddesc}[InteractiveInterpreter]{runsource}{source\optional{, filename\optional{, symbol}}}
Compile and run some source in the interpreter.
Arguments are the same as for \function{compile_command()}; the
default for \var{filename} is \code{'<input>'}, and for
@@ -98,7 +98,7 @@ The return value can be used to decide whether to use
\code{sys.ps1} or \code{sys.ps2} to prompt the next line.
\end{methoddesc}
-\begin{methoddesc}{runcode}{code}
+\begin{methoddesc}[InteractiveInterpreter]{runcode}{code}
Execute a code object.
When an exception occurs, \method{showtraceback()} is called to
display a traceback. All exceptions are caught except
@@ -109,7 +109,7 @@ elsewhere in this code, and may not always be caught. The caller
should be prepared to deal with it.
\end{methoddesc}
-\begin{methoddesc}{showsyntaxerror}{\optional{filename}}
+\begin{methoddesc}[InteractiveInterpreter]{showsyntaxerror}{\optional{filename}}
Display the syntax error that just occurred. This does not display
a stack trace because there isn't one for syntax errors.
If \var{filename} is given, it is stuffed into the exception instead
@@ -118,13 +118,13 @@ always uses \code{'<string>'} when reading from a string.
The output is written by the \method{write()} method.
\end{methoddesc}
-\begin{methoddesc}{showtraceback}{}
+\begin{methoddesc}[InteractiveInterpreter]{showtraceback}{}
Display the exception that just occurred. We remove the first stack
item because it is within the interpreter object implementation.
The output is written by the \method{write()} method.
\end{methoddesc}
-\begin{methoddesc}{write}{data}
+\begin{methoddesc}[InteractiveInterpreter]{write}{data}
Write a string to the standard error stream (\code{sys.stderr}).
Derived classes should override this to provide the appropriate output
handling as needed.
@@ -138,7 +138,7 @@ The \class{InteractiveConsole} class is a subclass of
\class{InteractiveInterpreter}, and so offers all the methods of the
interpreter objects as well as the following additions.
-\begin{methoddesc}{interact}{\optional{banner}}
+\begin{methoddesc}[InteractiveConsole]{interact}{\optional{banner}}
Closely emulate the interactive Python console.
The optional banner argument specify the banner to print before the
first interaction; by default it prints a banner similar to the one
@@ -147,7 +147,7 @@ name of the console object in parentheses (so as not to confuse this
with the real interpreter -- since it's so close!).
\end{methoddesc}
-\begin{methoddesc}{push}{line}
+\begin{methoddesc}[InteractiveConsole]{push}{line}
Push a line of source text to the interpreter.
The line should not have a trailing newline; it may have internal
newlines. The line is appended to a buffer and the interpreter's
@@ -160,11 +160,11 @@ appended. The return value is \code{True} if more input is required,
\method{runsource()}).
\end{methoddesc}
-\begin{methoddesc}{resetbuffer}{}
+\begin{methoddesc}[InteractiveConsole]{resetbuffer}{}
Remove any unhandled source text from the input buffer.
\end{methoddesc}
-\begin{methoddesc}{raw_input}{\optional{prompt}}
+\begin{methoddesc}[InteractiveConsole]{raw_input}{\optional{prompt}}
Write a prompt and read a line. The returned line does not include
the trailing newline. When the user enters the \EOF{} key sequence,
\exception{EOFError} is raised. The base implementation reads from
diff --git a/Doc/lib/libcodecs.tex b/Doc/lib/libcodecs.tex
index 557364d..78fa24d 100644
--- a/Doc/lib/libcodecs.tex
+++ b/Doc/lib/libcodecs.tex
@@ -307,7 +307,7 @@ The set of allowed values can be extended via \method{register_error}.
The \class{Codec} class defines these methods which also define the
function interfaces of the stateless encoder and decoder:
-\begin{methoddesc}{encode}{input\optional{, errors}}
+\begin{methoddesc}[Codec]{encode}{input\optional{, errors}}
Encodes the object \var{input} and returns a tuple (output object,
length consumed). While codecs are not restricted to use with Unicode, in
a Unicode context, encoding converts a Unicode object to a plain string
@@ -325,7 +325,7 @@ function interfaces of the stateless encoder and decoder:
empty object of the output object type in this situation.
\end{methoddesc}
-\begin{methoddesc}{decode}{input\optional{, errors}}
+\begin{methoddesc}[Codec]{decode}{input\optional{, errors}}
Decodes the object \var{input} and returns a tuple (output object,
length consumed). In a Unicode context, decoding converts a plain string
encoded using a particular character set encoding to a Unicode object.
@@ -1233,9 +1233,8 @@ listed as operand type in the table.
\lineiv{idna}
{}
{Unicode string}
- {Implements \rfc{3490}.
- \versionadded{2.3}
- See also \refmodule{encodings.idna}}
+ {Implements \rfc{3490},
+ see also \refmodule{encodings.idna}}
\lineiv{mbcs}
{dbcs}
@@ -1250,8 +1249,7 @@ listed as operand type in the table.
\lineiv{punycode}
{}
{Unicode string}
- {Implements \rfc{3492}.
- \versionadded{2.3}}
+ {Implements \rfc{3492}}
\lineiv{quopri_codec}
{quopri, quoted-printable, quotedprintable}
@@ -1305,6 +1303,8 @@ listed as operand type in the table.
\end{tableiv}
+\versionadded[The \code{idna} and \code{punycode} encodings]{2.3}
+
\subsection{\module{encodings.idna} ---
Internationalized Domain Names in Applications}
diff --git a/Doc/lib/libcollections.tex b/Doc/lib/libcollections.tex
index 5a07a2d..33ace7d 100644
--- a/Doc/lib/libcollections.tex
+++ b/Doc/lib/libcollections.tex
@@ -9,14 +9,16 @@
This module implements high-performance container datatypes. Currently,
-there are two datatypes, deque and defaultdict.
+there are two datatypes, deque and defaultdict, and one datatype factory
+function, \function{NamedTuple}.
Future additions may include balanced trees and ordered dictionaries.
\versionchanged[Added defaultdict]{2.5}
+\versionchanged[Added NamedTuple]{2.6}
\subsection{\class{deque} objects \label{deque-objects}}
-\begin{funcdesc}{deque}{\optional{iterable}}
- Returns a new deque objected initialized left-to-right (using
+\begin{classdesc}{deque}{\optional{iterable}}
+ Returns a new deque object initialized left-to-right (using
\method{append()}) with data from \var{iterable}. If \var{iterable}
is not specified, the new deque is empty.
@@ -30,7 +32,7 @@ Future additions may include balanced trees and ordered dictionaries.
for \samp{pop(0)} and \samp{insert(0, v)} operations which change both the
size and position of the underlying data representation.
\versionadded{2.4}
-\end{funcdesc}
+\end{classdesc}
Deque objects support the following methods:
@@ -219,7 +221,7 @@ def maketree(iterable):
\subsection{\class{defaultdict} objects \label{defaultdict-objects}}
-\begin{funcdesc}{defaultdict}{\optional{default_factory\optional{, ...}}}
+\begin{classdesc}{defaultdict}{\optional{default_factory\optional{, ...}}}
Returns a new dictionary-like object. \class{defaultdict} is a subclass
of the builtin \class{dict} class. It overrides one method and adds one
writable instance variable. The remaining functionality is the same as
@@ -231,7 +233,7 @@ def maketree(iterable):
passed to the \class{dict} constructor, including keyword arguments.
\versionadded{2.5}
-\end{funcdesc}
+\end{classdesc}
\class{defaultdict} objects support the following method in addition to
the standard \class{dict} operations:
@@ -254,11 +256,11 @@ the standard \class{dict} operations:
\class{defaultdict} objects support the following instance variable:
-\begin{datadesc}{default_factory}
+\begin{memberdesc}{default_factory}
This attribute is used by the \method{__missing__} method; it is initialized
from the first argument to the constructor, if present, or to \code{None},
if absent.
-\end{datadesc}
+\end{memberdesc}
\subsubsection{\class{defaultdict} Examples \label{defaultdict-examples}}
@@ -339,3 +341,51 @@ Setting the \member{default_factory} to \class{set} makes the
>>> d.items()
[('blue', set([2, 4])), ('red', set([1, 3]))]
\end{verbatim}
+
+
+
+\subsection{\function{NamedTuple} datatype factory function \label{named-tuple-factory}}
+
+\begin{funcdesc}{NamedTuple}{typename, fieldnames}
+ Returns a new tuple subclass named \var{typename}. The new subclass is used
+ to create tuple-like objects that have fields accessable by attribute
+ lookup as well as being indexable and iterable. Instances of the subclass
+ also have a helpful docstring (with typename and fieldnames) and a helpful
+ \method{__repr__()} method which lists the tuple contents in a \code{name=value}
+ format.
+ \versionadded{2.6}
+
+ The \var{fieldnames} are specified in a single string and are separated by spaces.
+ Any valid Python identifier may be used for a field name.
+
+ Example:
+ \begin{verbatim}
+>>> Point = NamedTuple('Point', 'x y')
+>>> Point.__doc__ # docstring for the new datatype
+'Point(x, y)'
+>>> p = Point(11, y=22) # instantiate with positional or keyword arguments
+>>> p[0] + p[1] # works just like the tuple (11, 22)
+33
+>>> x, y = p # unpacks just like a tuple
+>>> x, y
+(11, 22)
+>>> p.x + p.y # fields also accessable by name
+33
+>>> p # readable __repr__ with name=value style
+Point(x=11, y=22)
+\end{verbatim}
+
+ The use cases are the same as those for tuples. The named factories
+ assign meaning to each tuple position and allow for more readable,
+ self-documenting code. Named tuples can also be used to assign field names
+ to tuples
+ returned by the \module{csv} or \module{sqlite3} modules. For example:
+
+ \begin{verbatim}
+import csv
+EmployeeRecord = NamedTuple('EmployeeRecord', 'name age title department paygrade')
+for tup in csv.reader(open("employees.csv", "rb")):
+ print EmployeeRecord(*tup)
+\end{verbatim}
+
+\end{funcdesc}
diff --git a/Doc/lib/libcommands.tex b/Doc/lib/libcommands.tex
index 53b8a20..fa9b464 100644
--- a/Doc/lib/libcommands.tex
+++ b/Doc/lib/libcommands.tex
@@ -39,6 +39,10 @@ and the return value is a string containing the command's output.
Return the output of \samp{ls -ld \var{file}} as a string. This
function uses the \function{getoutput()} function, and properly
escapes backslashes and dollar signs in the argument.
+
+\deprecated{2.6}{This function is nonobvious and useless,
+ also the name is misleading in the presence of
+ \function{getstatusoutput()}.}
\end{funcdesc}
Example:
diff --git a/Doc/lib/libconsts.tex b/Doc/lib/libconsts.tex
index 1f56b05..bf36281 100644
--- a/Doc/lib/libconsts.tex
+++ b/Doc/lib/libconsts.tex
@@ -13,7 +13,7 @@ A small number of constants live in the built-in namespace. They are:
\end{datadesc}
\begin{datadesc}{None}
- The sole value of \code{\refmodule{types}.NoneType}. \code{None} is
+ The sole value of \member{\refmodule{types}.NoneType}. \code{None} is
frequently used to represent the absence of a value, as when default
arguments are not passed to a function.
\end{datadesc}
diff --git a/Doc/lib/libcookielib.tex b/Doc/lib/libcookielib.tex
index 01f2539..2ea3554 100644
--- a/Doc/lib/libcookielib.tex
+++ b/Doc/lib/libcookielib.tex
@@ -292,12 +292,12 @@ If there is a failure, the object's state will not be altered.
\class{FileCookieJar} instances have the following public attributes:
-\begin{memberdesc}{filename}
+\begin{memberdesc}[FileCookieJar]{filename}
Filename of default file in which to keep cookies. This attribute may
be assigned to.
\end{memberdesc}
-\begin{memberdesc}{delayload}
+\begin{memberdesc}[FileCookieJar]{delayload}
If true, load cookies lazily from disk. This attribute should not be
assigned to. This is only a hint, since this only affects
performance, not behaviour (unless the cookies on disk are changing).
@@ -400,13 +400,13 @@ In addition to implementing the methods above, implementations of the
attributes, indicating which protocols should be used, and how. All
of these attributes may be assigned to.
-\begin{memberdesc}{netscape}
+\begin{memberdesc}[CookiePolicy]{netscape}
Implement Netscape protocol.
\end{memberdesc}
-\begin{memberdesc}{rfc2965}
+\begin{memberdesc}[CookiePolicy]{rfc2965}
Implement RFC 2965 protocol.
\end{memberdesc}
-\begin{memberdesc}{hide_cookie2}
+\begin{memberdesc}[CookiePolicy]{hide_cookie2}
Don't add \mailheader{Cookie2} header to requests (the presence of
this header indicates to the server that we understand RFC 2965
cookies).
@@ -504,7 +504,7 @@ receiving cookies.
which are all initialised from the constructor arguments of the same
name, and which may all be assigned to.
-\begin{memberdesc}{rfc2109_as_netscape}
+\begin{memberdesc}[DefaultCookiePolicy]{rfc2109_as_netscape}
If true, request that the \class{CookieJar} instance downgrade RFC
2109 cookies (ie. cookies received in a \mailheader{Set-Cookie} header
with a version cookie-attribute of 1) to Netscape cookies by setting
@@ -517,7 +517,7 @@ RFC 2109 cookies are downgraded by default.
General strictness switches:
-\begin{memberdesc}{strict_domain}
+\begin{memberdesc}[DefaultCookiePolicy]{strict_domain}
Don't allow sites to set two-component domains with country-code
top-level domains like \code{.co.uk}, \code{.gov.uk},
\code{.co.nz}.etc. This is far from perfect and isn't guaranteed to
@@ -526,7 +526,7 @@ work!
RFC 2965 protocol strictness switches:
-\begin{memberdesc}{strict_rfc2965_unverifiable}
+\begin{memberdesc}[DefaultCookiePolicy]{strict_rfc2965_unverifiable}
Follow RFC 2965 rules on unverifiable transactions (usually, an
unverifiable transaction is one resulting from a redirect or a request
for an image hosted on another site). If this is false, cookies are
@@ -535,19 +535,19 @@ for an image hosted on another site). If this is false, cookies are
Netscape protocol strictness switches:
-\begin{memberdesc}{strict_ns_unverifiable}
+\begin{memberdesc}[DefaultCookiePolicy]{strict_ns_unverifiable}
apply RFC 2965 rules on unverifiable transactions even to Netscape
cookies
\end{memberdesc}
-\begin{memberdesc}{strict_ns_domain}
+\begin{memberdesc}[DefaultCookiePolicy]{strict_ns_domain}
Flags indicating how strict to be with domain-matching rules for
Netscape cookies. See below for acceptable values.
\end{memberdesc}
-\begin{memberdesc}{strict_ns_set_initial_dollar}
+\begin{memberdesc}[DefaultCookiePolicy]{strict_ns_set_initial_dollar}
Ignore cookies in Set-Cookie: headers that have names starting with
\code{'\$'}.
\end{memberdesc}
-\begin{memberdesc}{strict_ns_set_path}
+\begin{memberdesc}[DefaultCookiePolicy]{strict_ns_set_path}
Don't allow setting cookies whose path doesn't path-match request URI.
\end{memberdesc}
@@ -556,30 +556,30 @@ constructed by or-ing together (for example,
\code{DomainStrictNoDots|DomainStrictNonDomain} means both flags are
set).
-\begin{memberdesc}{DomainStrictNoDots}
+\begin{memberdesc}[DefaultCookiePolicy]{DomainStrictNoDots}
When setting cookies, the 'host prefix' must not contain a dot
(eg. \code{www.foo.bar.com} can't set a cookie for \code{.bar.com},
because \code{www.foo} contains a dot).
\end{memberdesc}
-\begin{memberdesc}{DomainStrictNonDomain}
+\begin{memberdesc}[DefaultCookiePolicy]{DomainStrictNonDomain}
Cookies that did not explicitly specify a \code{domain}
cookie-attribute can only be returned to a domain equal to the domain
that set the cookie (eg. \code{spam.example.com} won't be returned
cookies from \code{example.com} that had no \code{domain}
cookie-attribute).
\end{memberdesc}
-\begin{memberdesc}{DomainRFC2965Match}
+\begin{memberdesc}[DefaultCookiePolicy]{DomainRFC2965Match}
When setting cookies, require a full RFC 2965 domain-match.
\end{memberdesc}
The following attributes are provided for convenience, and are the
most useful combinations of the above flags:
-\begin{memberdesc}{DomainLiberal}
+\begin{memberdesc}[DefaultCookiePolicy]{DomainLiberal}
Equivalent to 0 (ie. all of the above Netscape domain strictness flags
switched off).
\end{memberdesc}
-\begin{memberdesc}{DomainStrict}
+\begin{memberdesc}[DefaultCookiePolicy]{DomainStrict}
Equivalent to \code{DomainStrictNoDots|DomainStrictNonDomain}.
\end{memberdesc}
diff --git a/Doc/lib/libctypes.tex b/Doc/lib/libctypes.tex
index 2f880f2..f19507a 100755
--- a/Doc/lib/libctypes.tex
+++ b/Doc/lib/libctypes.tex
@@ -7,21 +7,21 @@
\versionadded{2.5}
\code{ctypes} is a foreign function library for Python. It provides C
-compatible data types, and allows to call functions in dlls/shared
+compatible data types, and allows calling functions in dlls/shared
libraries. It can be used to wrap these libraries in pure Python.
\subsection{ctypes tutorial\label{ctypes-ctypes-tutorial}}
-Note: The code samples in this tutorial uses \code{doctest} to make sure
+Note: The code samples in this tutorial use \code{doctest} to make sure
that they actually work. Since some code samples behave differently
under Linux, Windows, or Mac OS X, they contain doctest directives in
comments.
-Note: Quite some code samples references the ctypes \class{c{\_}int} type.
+Note: Some code sample references the ctypes \class{c{\_}int} type.
This type is an alias to the \class{c{\_}long} type on 32-bit systems. So,
you should not be confused if \class{c{\_}long} is printed if you would
-expect \class{c{\_}int} - they are actually the same type.
+expect \class{c{\_}int} --- they are actually the same type.
\subsubsection{Loading dynamic link libraries\label{ctypes-loading-dynamic-link-libraries}}
@@ -38,7 +38,7 @@ return a Windows \class{HRESULT} error code. The error code is used to
automatically raise \class{WindowsError} Python exceptions when the
function call fails.
-Here are some examples for Windows, note that \code{msvcrt} is the MS
+Here are some examples for Windows. Note that \code{msvcrt} is the MS
standard C library containing most standard C functions, and uses the
cdecl calling convention:
\begin{verbatim}
@@ -1219,7 +1219,7 @@ py_cmp_func 5 7
It is quite interesting to see that the Windows \function{qsort} function
needs more comparisons than the linux version!
-As we can easily check, our array sorted now:
+As we can easily check, our array is sorted now:
\begin{verbatim}
>>> for i in ia: print i,
...
@@ -1242,7 +1242,7 @@ variables. An example in the Python library itself is the
\programopt{-O} or \programopt{-OO} flag given on startup.
\code{ctypes} can access values like this with the \method{in{\_}dll} class
-methods of the type. \var{pythonapi} ìs a predefined symbol giving
+methods of the type. \var{pythonapi} is a predefined symbol giving
access to the Python C api:
\begin{verbatim}
>>> opt_flag = c_int.in_dll(pythonapi, "Py_OptimizeFlag")
@@ -2113,7 +2113,7 @@ debugging; never modify the contents of this dictionary.
\end{memberdesc}
-\subsubsection{Fundamental data types\label{ctypes-fundamental-data-types}}
+\subsubsection{Fundamental data types\label{ctypes-fundamental-data-types-2}}
\begin{classdesc*}{_SimpleCData}
This non-public class is the base class of all fundamental ctypes
@@ -2294,6 +2294,13 @@ a zero-terminated wide character string. The constructor accepts
an integer address, or a string.
\end{classdesc*}
+\begin{classdesc*}{c_bool}
+Represent the C \code{bool} datatype (more accurately, _Bool from C99).
+Its value can be True or False, and the constructor accepts any object that
+has a truth value.
+\versionadded{2.6}
+\end{classdesc*}
+
\begin{classdesc*}{HRESULT}
Windows only: Represents a \class{HRESULT} value, which contains success
or error information for a function or method call.
diff --git a/Doc/lib/libcurses.tex b/Doc/lib/libcurses.tex
index fa9f974..33dea5a 100644
--- a/Doc/lib/libcurses.tex
+++ b/Doc/lib/libcurses.tex
@@ -646,6 +646,16 @@ Similar to \method{border()}, but both \var{ls} and \var{rs} are
corner characters are always used by this function.
\end{methoddesc}
+\begin{methoddesc}[window]{chgat}{\optional{y, x, } \optional{num,} attr}
+Sets the attributes of \var{num} characters at the current cursor
+position, or at position \code{(\var{y}, \var{x})} if supplied. If no
+value of \var{num} is given or \var{num} = -1, the attribute will
+be set on all the characters to the end of the line.
+This function does not move the cursor. The changed line
+will be touched using the \method{touchline} method so that the
+contents will be redisplayed by the next window refresh.
+\end{methoddesc}
+
\begin{methoddesc}[window]{clear}{}
Like \method{erase()}, but also causes the whole window to be repainted
upon next call to \method{refresh()}.
@@ -1014,9 +1024,11 @@ block for \var{delay} milliseconds, and return -1 if there is still no
input at the end of that time.
\end{methoddesc}
-\begin{methoddesc}[window]{touchline}{start, count}
+\begin{methoddesc}[window]{touchline}{start, count\optional{, changed}}
Pretend \var{count} lines have been changed, starting with line
-\var{start}.
+\var{start}. If \var{changed} is supplied, it specifies
+whether the affected lines are marked as
+having been changed (\var{changed}=1) or unchanged (\var{changed}=0).
\end{methoddesc}
\begin{methoddesc}[window]{touchwin}{}
diff --git a/Doc/lib/libcursespanel.tex b/Doc/lib/libcursespanel.tex
index 1f96717..14d83e3 100644
--- a/Doc/lib/libcursespanel.tex
+++ b/Doc/lib/libcursespanel.tex
@@ -45,52 +45,52 @@ responsible for the window's depth in the panel stack.
Panel objects have the following methods:
-\begin{methoddesc}{above}{}
+\begin{methoddesc}[Panel]{above}{}
Returns the panel above the current panel.
\end{methoddesc}
-\begin{methoddesc}{below}{}
+\begin{methoddesc}[Panel]{below}{}
Returns the panel below the current panel.
\end{methoddesc}
-\begin{methoddesc}{bottom}{}
+\begin{methoddesc}[Panel]{bottom}{}
Push the panel to the bottom of the stack.
\end{methoddesc}
-\begin{methoddesc}{hidden}{}
+\begin{methoddesc}[Panel]{hidden}{}
Returns true if the panel is hidden (not visible), false otherwise.
\end{methoddesc}
-\begin{methoddesc}{hide}{}
+\begin{methoddesc}[Panel]{hide}{}
Hide the panel. This does not delete the object, it just makes the
window on screen invisible.
\end{methoddesc}
-\begin{methoddesc}{move}{y, x}
+\begin{methoddesc}[Panel]{move}{y, x}
Move the panel to the screen coordinates \code{(\var{y}, \var{x})}.
\end{methoddesc}
-\begin{methoddesc}{replace}{win}
+\begin{methoddesc}[Panel]{replace}{win}
Change the window associated with the panel to the window \var{win}.
\end{methoddesc}
-\begin{methoddesc}{set_userptr}{obj}
+\begin{methoddesc}[Panel]{set_userptr}{obj}
Set the panel's user pointer to \var{obj}. This is used to associate an
arbitrary piece of data with the panel, and can be any Python object.
\end{methoddesc}
-\begin{methoddesc}{show}{}
+\begin{methoddesc}[Panel]{show}{}
Display the panel (which might have been hidden).
\end{methoddesc}
-\begin{methoddesc}{top}{}
+\begin{methoddesc}[Panel]{top}{}
Push panel to the top of the stack.
\end{methoddesc}
-\begin{methoddesc}{userptr}{}
+\begin{methoddesc}[Panel]{userptr}{}
Returns the user pointer for the panel. This might be any Python object.
\end{methoddesc}
-\begin{methoddesc}{window}{}
+\begin{methoddesc}[Panel]{window}{}
Returns the window object associated with the panel.
\end{methoddesc}
diff --git a/Doc/lib/libdatetime.tex b/Doc/lib/libdatetime.tex
index 0d2b5bb..fb13ea7 100644
--- a/Doc/lib/libdatetime.tex
+++ b/Doc/lib/libdatetime.tex
@@ -1154,7 +1154,7 @@ following methods. Exactly which methods are needed depends on the
uses made of aware \module{datetime} objects. If in doubt, simply
implement all of them.
-\begin{methoddesc}{utcoffset}{self, dt}
+\begin{methoddesc}[tzinfo]{utcoffset}{self, dt}
Return offset of local time from UTC, in minutes east of UTC. If
local time is west of UTC, this should be negative. Note that this
is intended to be the total offset from UTC; for example, if a
@@ -1178,7 +1178,7 @@ implement all of them.
\exception{NotImplementedError}.
\end{methoddesc}
-\begin{methoddesc}{dst}{self, dt}
+\begin{methoddesc}[tzinfo]{dst}{self, dt}
Return the daylight saving time (DST) adjustment, in minutes east of
UTC, or \code{None} if DST information isn't known. Return
\code{timedelta(0)} if DST is not in effect.
@@ -1237,7 +1237,7 @@ implement all of them.
\exception{NotImplementedError}.
\end{methoddesc}
-\begin{methoddesc}{tzname}{self, dt}
+\begin{methoddesc}[tzinfo]{tzname}{self, dt}
Return the time zone name corresponding to the \class{datetime}
object \var{dt}, as a string.
Nothing about string names is defined by the
@@ -1278,7 +1278,7 @@ and not need worry about objects in other timezones.
There is one more \class{tzinfo} method that a subclass may wish to
override:
-\begin{methoddesc}{fromutc}{self, dt}
+\begin{methoddesc}[tzinfo]{fromutc}{self, dt}
This is called from the default \class{datetime.astimezone()}
implementation. When called from that, \code{\var{dt}.tzinfo} is
\var{self}, and \var{dt}'s date and time members are to be viewed as
diff --git a/Doc/lib/libdbhash.tex b/Doc/lib/libdbhash.tex
index f5f98ea..cf44707 100644
--- a/Doc/lib/libdbhash.tex
+++ b/Doc/lib/libdbhash.tex
@@ -2,7 +2,6 @@
DBM-style interface to the BSD database library}
\declaremodule{standard}{dbhash}
- \platform{Unix, Windows}
\modulesynopsis{DBM-style interface to the BSD database library.}
\sectionauthor{Fred L. Drake, Jr.}{fdrake@acm.org}
diff --git a/Doc/lib/libdecimal.tex b/Doc/lib/libdecimal.tex
index 127eb1d..a0a257e 100644
--- a/Doc/lib/libdecimal.tex
+++ b/Doc/lib/libdecimal.tex
@@ -425,7 +425,7 @@ also have a number of specialized methods:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\subsection{Context objects \label{decimal-decimal}}
+\subsection{Context objects \label{decimal-context}}
Contexts are environments for arithmetic operations. They govern precision,
set rules for rounding, determine which signals are treated as exceptions, and
diff --git a/Doc/lib/libdl.tex b/Doc/lib/libdl.tex
index 325724c..d4a799e 100644
--- a/Doc/lib/libdl.tex
+++ b/Doc/lib/libdl.tex
@@ -67,11 +67,11 @@ example of the fact that using this module is usually a bad alternative.
Dl objects, as returned by \function{open()} above, have the
following methods:
-\begin{methoddesc}{close}{}
+\begin{methoddesc}[dl]{close}{}
Free all resources, except the memory.
\end{methoddesc}
-\begin{methoddesc}{sym}{name}
+\begin{methoddesc}[dl]{sym}{name}
Return the pointer for the function named \var{name}, as a number, if
it exists in the referenced shared object, otherwise \code{None}. This
is useful in code like:
@@ -87,7 +87,7 @@ is useful in code like:
\NULL{} pointer)
\end{methoddesc}
-\begin{methoddesc}{call}{name\optional{, arg1\optional{, arg2\ldots}}}
+\begin{methoddesc}[dl]{call}{name\optional{, arg1\optional{, arg2\ldots}}}
Call the function named \var{name} in the referenced shared object.
The arguments must be either Python integers, which will be
passed as is, Python strings, to which a pointer will be passed,
diff --git a/Doc/lib/libdoctest.tex b/Doc/lib/libdoctest.tex
index 957ecf4..5e28c2a 100644
--- a/Doc/lib/libdoctest.tex
+++ b/Doc/lib/libdoctest.tex
@@ -201,6 +201,19 @@ prohibit it by passing \code{verbose=False}. In either of those cases,
\code{sys.argv} is not examined by \function{testmod()} (so passing
\programopt{-v} or not has no effect).
+Since Python 2.6, there is also a command line shortcut for running
+\function{testmod()}. You can instruct the Python interpreter to run
+the doctest module directly from the standard library and pass the module
+name(s) on the command line:
+
+\begin{verbatim}
+python -m doctest -v example.py
+\end{verbatim}
+
+This will import \file{example.py} as a standalone module and run
+\function{testmod()} on it. Note that this may not work correctly if the
+file is part of a package and imports other submodules from that package.
+
For more information on \function{testmod()}, see
section~\ref{doctest-basic-api}.
@@ -267,6 +280,18 @@ Like \function{testmod()}, \function{testfile()}'s verbosity can be
set with the \programopt{-v} command-line switch or with the optional
keyword argument \var{verbose}.
+Since Python 2.6, there is also a command line shortcut for running
+\function{testfile()}. You can instruct the Python interpreter to run
+the doctest module directly from the standard library and pass the file
+name(s) on the command line:
+
+\begin{verbatim}
+python -m doctest -v example.txt
+\end{verbatim}
+
+Because the file name does not end with \file{.py}, \module{doctest} infers
+that it must be run with \function{testfile()}, not \function{testmod()}.
+
For more information on \function{testfile()}, see
section~\ref{doctest-basic-api}.
@@ -1716,7 +1741,7 @@ Doctest provides several mechanisms for debugging doctest examples:
>>>
\end{verbatim}
- \versionchanged[The ability to use \code{\refmodule{pdb}.set_trace()}
+ \versionchanged[The ability to use \function{\refmodule{pdb}.set_trace()}
usefully inside doctests was added]{2.4}
\end{itemize}
@@ -1800,10 +1825,10 @@ print doctest.testsource(a, "a.f")
used. If \var{pm} has a true value, the script file is run directly, and
the debugger gets involved only if the script terminates via raising an
unhandled exception. If it does, then post-mortem debugging is invoked,
- via \code{\refmodule{pdb}.post_mortem()}, passing the traceback object
+ via \function{\refmodule{pdb}.post_mortem()}, passing the traceback object
from the unhandled exception. If \var{pm} is not specified, or is false,
the script is run under the debugger from the start, via passing an
- appropriate \function{execfile()} call to \code{\refmodule{pdb}.run()}.
+ appropriate \function{execfile()} call to \function{\refmodule{pdb}.run()}.
\versionadded{2.3}
diff --git a/Doc/lib/libdocxmlrpc.tex b/Doc/lib/libdocxmlrpc.tex
index 2f1e6ca..f93b3b2 100644
--- a/Doc/lib/libdocxmlrpc.tex
+++ b/Doc/lib/libdocxmlrpc.tex
@@ -14,8 +14,12 @@ HTTP GET requests. Servers can either be free standing, using
\class{DocXMLRPCServer}, or embedded in a CGI environment, using
\class{DocCGIXMLRPCRequestHandler}.
-\begin{classdesc}{DocXMLRPCServer}{addr\optional{,
- requestHandler\optional{, logRequests}}}
+\begin{classdesc}{DocXMLRPCServer}{addr\optional{,
+ requestHandler\optional{,
+ logRequests\optional{,
+ allow_none\optional{,
+ encoding\optional{,
+ bind_and_activate}}}}}}
Create a new server instance. All parameters have the same meaning as
for \class{SimpleXMLRPCServer.SimpleXMLRPCServer};
@@ -47,14 +51,14 @@ requests are handled as XML-RPC method calls. HTTP GET requests are
handled by generating pydoc-style HTML documentation. This allows a
server to provide its own web-based documentation.
-\begin{methoddesc}{set_server_title}{server_title}
+\begin{methoddesc}[DocXMLRPCServer]{set_server_title}{server_title}
Set the title used in the generated HTML documentation. This title
will be used inside the HTML "title" element.
\end{methoddesc}
-\begin{methoddesc}{set_server_name}{server_name}
+\begin{methoddesc}[DocXMLRPCServer]{set_server_name}{server_name}
Set the name used in the generated HTML documentation. This name will
appear at the top of the generated documentation inside a "h1"
@@ -63,7 +67,7 @@ element.
\end{methoddesc}
-\begin{methoddesc}{set_server_documentation}{server_documentation}
+\begin{methoddesc}[DocXMLRPCServer]{set_server_documentation}{server_documentation}
Set the description used in the generated HTML documentation. This
description will appear as a paragraph, below the server name, in the
@@ -80,14 +84,14 @@ are handled as XML-RPC method calls. HTTP GET requests are handled by
generating pydoc-style HTML documentation. This allows a server to
provide its own web-based documentation.
-\begin{methoddesc}{set_server_title}{server_title}
+\begin{methoddesc}[DocCGIXMLRPCRequestHandler]{set_server_title}{server_title}
Set the title used in the generated HTML documentation. This title
will be used inside the HTML "title" element.
\end{methoddesc}
-\begin{methoddesc}{set_server_name}{server_name}
+\begin{methoddesc}[DocCGIXMLRPCRequestHandler]{set_server_name}{server_name}
Set the name used in the generated HTML documentation. This name will
appear at the top of the generated documentation inside a "h1"
@@ -96,7 +100,7 @@ element.
\end{methoddesc}
-\begin{methoddesc}{set_server_documentation}{server_documentation}
+\begin{methoddesc}[DocCGIXMLRPCRequestHandler]{set_server_documentation}{server_documentation}
Set the description used in the generated HTML documentation. This
description will appear as a paragraph, below the server name, in the
diff --git a/Doc/lib/libdumbdbm.tex b/Doc/lib/libdumbdbm.tex
index 4495774..d0917be 100644
--- a/Doc/lib/libdumbdbm.tex
+++ b/Doc/lib/libdumbdbm.tex
@@ -57,7 +57,7 @@ only when the database has to be created. It defaults to octal
In addition to the methods provided by the \class{UserDict.DictMixin} class,
\class{dumbdbm} objects provide the following methods.
-\begin{methoddesc}{sync}{}
+\begin{methoddesc}[dumbdbm]{sync}{}
Synchronize the on-disk directory and data files. This method is called by
the \method{sync} method of \class{Shelve} objects.
\end{methoddesc}
diff --git a/Doc/lib/libetree.tex b/Doc/lib/libetree.tex
index f769c63..6f20ee3 100644
--- a/Doc/lib/libetree.tex
+++ b/Doc/lib/libetree.tex
@@ -144,12 +144,12 @@ Returns a tuple containing an Element instance and a dictionary.
Element objects returned by Element or SubElement have the
following methods and attributes.
-\begin{memberdesc}{tag}
+\begin{memberdesc}[Element]{tag}
A string identifying what kind of data this element represents
(the element type, in other words).
\end{memberdesc}
-\begin{memberdesc}{text}
+\begin{memberdesc}[Element]{text}
The \var{text} attribute can be used to hold additional data
associated with the element.
As the name implies this attribute is usually a string but may be any
@@ -158,7 +158,7 @@ If the element is created from an XML file the attribute will contain
any text found between the element tags.
\end{memberdesc}
-\begin{memberdesc}{tail}
+\begin{memberdesc}[Element]{tail}
The \var{tail} attribute can be used to hold additional data
associated with the element.
This attribute is usually a string but may be any application-specific object.
@@ -166,7 +166,7 @@ If the element is created from an XML file the attribute will contain
any text found after the element's end tag and before the next tag.
\end{memberdesc}
-\begin{memberdesc}{attrib}
+\begin{memberdesc}[Element]{attrib}
A dictionary containing the element's attributes.
Note that while the \var{attrib} value is always a real mutable Python
dictionary, an ElementTree implementation may choose to use another
@@ -177,52 +177,52 @@ dictionary methods below whenever possible.
The following dictionary-like methods work on the element attributes.
-\begin{methoddesc}{clear}{}
+\begin{methoddesc}[Element]{clear}{}
Resets an element. This function removes all subelements, clears
all attributes, and sets the text and tail attributes to None.
\end{methoddesc}
-\begin{methoddesc}{get}{key\optional{, default=None}}
+\begin{methoddesc}[Element]{get}{key\optional{, default=None}}
Gets the element attribute named \var{key}.
Returns the attribute value, or \var{default} if the
attribute was not found.
\end{methoddesc}
-\begin{methoddesc}{items}{}
+\begin{methoddesc}[Element]{items}{}
Returns the element attributes as a sequence of (name, value) pairs.
The attributes are returned in an arbitrary order.
\end{methoddesc}
-\begin{methoddesc}{keys}{}
+\begin{methoddesc}[Element]{keys}{}
Returns the elements attribute names as a list.
The names are returned in an arbitrary order.
\end{methoddesc}
-\begin{methoddesc}{set}{key, value}
+\begin{methoddesc}[Element]{set}{key, value}
Set the attribute \var{key} on the element to \var{value}.
\end{methoddesc}
The following methods work on the element's children (subelements).
-\begin{methoddesc}{append}{subelement}
+\begin{methoddesc}[Element]{append}{subelement}
Adds the element \var{subelement} to the end of this elements internal list
of subelements.
\end{methoddesc}
-\begin{methoddesc}{find}{match}
+\begin{methoddesc}[Element]{find}{match}
Finds the first subelement matching \var{match}.
\var{match} may be a tag name or path.
Returns an element instance or \code{None}.
\end{methoddesc}
-\begin{methoddesc}{findall}{match}
+\begin{methoddesc}[Element]{findall}{match}
Finds all subelements matching \var{match}.
\var{match} may be a tag name or path.
Returns an iterable yielding all matching elements in document order.
\end{methoddesc}
-\begin{methoddesc}{findtext}{condition\optional{, default=None}}
+\begin{methoddesc}[Element]{findtext}{condition\optional{, default=None}}
Finds text for the first subelement matching \var{condition}.
\var{condition} may be a tag name or path.
Returns the text content of the first matching element, or
@@ -230,11 +230,11 @@ Returns the text content of the first matching element, or
matching element has no text content an empty string is returned.
\end{methoddesc}
-\begin{methoddesc}{getchildren}{}
+\begin{methoddesc}[Element]{getchildren}{}
Returns all subelements. The elements are returned in document order.
\end{methoddesc}
-\begin{methoddesc}{getiterator}{\optional{tag=None}}
+\begin{methoddesc}[Element]{getiterator}{\optional{tag=None}}
Creates a tree iterator with the current element as the root.
The iterator iterates over this element and all elements below it
that match the given tag. If tag
@@ -243,16 +243,16 @@ Returns an iterable that provides element objects in document (depth first)
order.
\end{methoddesc}
-\begin{methoddesc}{insert}{index, element}
+\begin{methoddesc}[Element]{insert}{index, element}
Inserts a subelement at the given position in this element.
\end{methoddesc}
-\begin{methoddesc}{makeelement}{tag, attrib}
+\begin{methoddesc}[Element]{makeelement}{tag, attrib}
Creates a new element object of the same type as this element.
Do not call this method, use the SubElement factory function instead.
\end{methoddesc}
-\begin{methoddesc}{remove}{subelement}
+\begin{methoddesc}[Element]{remove}{subelement}
Removes \var{subelement} from the element.
Unlike the findXXX methods this method compares elements based on
the instance identity, not on tag value or contents.
diff --git a/Doc/lib/libfm.tex b/Doc/lib/libfm.tex
index 0b429e0..0a0c237 100644
--- a/Doc/lib/libfm.tex
+++ b/Doc/lib/libfm.tex
@@ -55,40 +55,39 @@ Returns the current font search path.
Font handle objects support the following operations:
-\setindexsubitem{(font handle method)}
-\begin{funcdesc}{scalefont}{factor}
+\begin{methoddesc}[font handle]{scalefont}{factor}
Returns a handle for a scaled version of this font.
Calls \code{fmscalefont(\var{fh}, \var{factor})}.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{setfont}{}
+\begin{methoddesc}[font handle]{setfont}{}
Makes this font the current font.
Note: the effect is undone silently when the font handle object is
deleted.
Calls \code{fmsetfont(\var{fh})}.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{getfontname}{}
+\begin{methoddesc}[font handle]{getfontname}{}
Returns this font's name.
Calls \code{fmgetfontname(\var{fh})}.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{getcomment}{}
+\begin{methoddesc}[font handle]{getcomment}{}
Returns the comment string associated with this font.
Raises an exception if there is none.
Calls \code{fmgetcomment(\var{fh})}.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{getfontinfo}{}
+\begin{methoddesc}[font handle]{getfontinfo}{}
Returns a tuple giving some pertinent data about this font.
This is an interface to \code{fmgetfontinfo()}.
The returned tuple contains the following numbers:
\code{(}\var{printermatched}, \var{fixed_width}, \var{xorig},
\var{yorig}, \var{xsize}, \var{ysize}, \var{height},
\var{nglyphs}\code{)}.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{getstrwidth}{string}
+\begin{methoddesc}[font handle]{getstrwidth}{string}
Returns the width, in pixels, of \var{string} when drawn in this font.
Calls \code{fmgetstrwidth(\var{fh}, \var{string})}.
-\end{funcdesc}
+\end{methoddesc}
diff --git a/Doc/lib/libfnmatch.tex b/Doc/lib/libfnmatch.tex
index fc4b97a..1ac46bd 100644
--- a/Doc/lib/libfnmatch.tex
+++ b/Doc/lib/libfnmatch.tex
@@ -36,6 +36,19 @@ lower- or upper-case before the comparison is performed. If you
require a case-sensitive comparison regardless of whether that's
standard for your operating system, use \function{fnmatchcase()}
instead.
+
+This example will print all file names in the current directory with the
+extension \code{.txt}:
+
+\begin{verbatim}
+import fnmatch
+import os
+
+for file in os.listdir('.'):
+ if fnmatch.fnmatch(file, '*.txt'):
+ print file
+\end{verbatim}
+
\end{funcdesc}
\begin{funcdesc}{fnmatchcase}{filename, pattern}
@@ -50,6 +63,24 @@ implemented more efficiently.
\versionadded{2.2}
\end{funcdesc}
+\begin{funcdesc}{translate}{pattern}
+Return the shell-style \var{pattern} converted to a regular
+expression.
+
+Example:
+
+\begin{verbatim}
+>>> import fnmatch, re
+>>>
+>>> regex = fnmatch.translate('*.txt')
+>>> regex
+'.*\\.txt$'
+>>> reobj = re.compile(regex)
+>>> print reobj.match('foobar.txt')
+<_sre.SRE_Match object at 0x...>
+\end{verbatim}
+\end{funcdesc}
+
\begin{seealso}
\seemodule{glob}{\UNIX{} shell-style path expansion.}
\end{seealso}
diff --git a/Doc/lib/libftplib.tex b/Doc/lib/libftplib.tex
index 58d16cb..98d7e80 100644
--- a/Doc/lib/libftplib.tex
+++ b/Doc/lib/libftplib.tex
@@ -37,12 +37,15 @@ dr-xr-srwt 105 ftp-usr pdmaint 1536 Mar 21 14:32 ..
The module defines the following items:
\begin{classdesc}{FTP}{\optional{host\optional{, user\optional{,
- passwd\optional{, acct}}}}}
+ passwd\optional{, acct\optional{, timeout}}}}}}
Return a new instance of the \class{FTP} class. When
\var{host} is given, the method call \code{connect(\var{host})} is
made. When \var{user} is given, additionally the method call
\code{login(\var{user}, \var{passwd}, \var{acct})} is made (where
\var{passwd} and \var{acct} default to the empty string when not given).
+The optional \var{timeout} parameter specifies a timeout in seconds for the
+connection attempt (if is not specified, or passed as None, the global
+default timeout setting will be used).
\end{classdesc}
\begin{datadesc}{all_errors}
@@ -92,7 +95,7 @@ which is used followed by \samp{lines} for the text version or
\class{FTP} instances have the following methods:
-\begin{methoddesc}{set_debuglevel}{level}
+\begin{methoddesc}[FTP]{set_debuglevel}{level}
Set the instance's debugging level. This controls the amount of
debugging output printed. The default, \code{0}, produces no
debugging output. A value of \code{1} produces a moderate amount of
@@ -101,22 +104,28 @@ debugging output, generally a single line per request. A value of
logging each line sent and received on the control connection.
\end{methoddesc}
-\begin{methoddesc}{connect}{host\optional{, port}}
+\begin{methoddesc}[FTP]{connect}{host\optional{, port\optional{, timeout}}}
Connect to the given host and port. The default port number is \code{21}, as
specified by the FTP protocol specification. It is rarely needed to
specify a different port number. This function should be called only
once for each instance; it should not be called at all if a host was
given when the instance was created. All other methods can only be
used after a connection has been made.
+
+The optional \var{timeout} parameter specifies a timeout in seconds for
+the connection attempt. If is not specified, or passed as None, the
+object timeout is used (the timeout that you passed when instantiating the
+class); if the object timeout is also None, the global default timeout
+setting will be used.
\end{methoddesc}
-\begin{methoddesc}{getwelcome}{}
+\begin{methoddesc}[FTP]{getwelcome}{}
Return the welcome message sent by the server in reply to the initial
connection. (This message sometimes contains disclaimers or help
information that may be relevant to the user.)
\end{methoddesc}
-\begin{methoddesc}{login}{\optional{user\optional{, passwd\optional{, acct}}}}
+\begin{methoddesc}[FTP]{login}{\optional{user\optional{, passwd\optional{, acct}}}}
Log in as the given \var{user}. The \var{passwd} and \var{acct}
parameters are optional and default to the empty string. If no
\var{user} is specified, it defaults to \code{'anonymous'}. If
@@ -128,23 +137,23 @@ instance was created. Most FTP commands are only allowed after the
client has logged in.
\end{methoddesc}
-\begin{methoddesc}{abort}{}
+\begin{methoddesc}[FTP]{abort}{}
Abort a file transfer that is in progress. Using this does not always
work, but it's worth a try.
\end{methoddesc}
-\begin{methoddesc}{sendcmd}{command}
+\begin{methoddesc}[FTP]{sendcmd}{command}
Send a simple command string to the server and return the response
string.
\end{methoddesc}
-\begin{methoddesc}{voidcmd}{command}
+\begin{methoddesc}[FTP]{voidcmd}{command}
Send a simple command string to the server and handle the response.
Return nothing if a response code in the range 200--299 is received.
Raise an exception otherwise.
\end{methoddesc}
-\begin{methoddesc}{retrbinary}{command,
+\begin{methoddesc}[FTP]{retrbinary}{command,
callback\optional{, maxblocksize\optional{, rest}}}
Retrieve a file in binary transfer mode. \var{command} should be an
appropriate \samp{RETR} command: \code{'RETR \var{filename}'}.
@@ -157,7 +166,7 @@ read on the low-level socket object created to do the actual transfer
same thing as in the \method{transfercmd()} method.
\end{methoddesc}
-\begin{methoddesc}{retrlines}{command\optional{, callback}}
+\begin{methoddesc}[FTP]{retrlines}{command\optional{, callback}}
Retrieve a file or directory listing in \ASCII{} transfer mode.
\var{command} should be an appropriate \samp{RETR} command (see
\method{retrbinary()}) or a \samp{LIST} command (usually just the string
@@ -166,13 +175,13 @@ with the trailing CRLF stripped. The default \var{callback} prints
the line to \code{sys.stdout}.
\end{methoddesc}
-\begin{methoddesc}{set_pasv}{boolean}
+\begin{methoddesc}[FTP]{set_pasv}{boolean}
Enable ``passive'' mode if \var{boolean} is true, other disable
passive mode. (In Python 2.0 and before, passive mode was off by
default; in Python 2.1 and later, it is on by default.)
\end{methoddesc}
-\begin{methoddesc}{storbinary}{command, file\optional{, blocksize}}
+\begin{methoddesc}[FTP]{storbinary}{command, file\optional{, blocksize}}
Store a file in binary transfer mode. \var{command} should be an
appropriate \samp{STOR} command: \code{"STOR \var{filename}"}.
\var{file} is an open file object which is read until \EOF{} using its
@@ -181,14 +190,14 @@ data to be stored. The \var{blocksize} argument defaults to 8192.
\versionchanged[default for \var{blocksize} added]{2.1}
\end{methoddesc}
-\begin{methoddesc}{storlines}{command, file}
+\begin{methoddesc}[FTP]{storlines}{command, file}
Store a file in \ASCII{} transfer mode. \var{command} should be an
appropriate \samp{STOR} command (see \method{storbinary()}). Lines are
read until \EOF{} from the open file object \var{file} using its
\method{readline()} method to provide the data to be stored.
\end{methoddesc}
-\begin{methoddesc}{transfercmd}{cmd\optional{, rest}}
+\begin{methoddesc}[FTP]{transfercmd}{cmd\optional{, rest}}
Initiate a transfer over the data connection. If the transfer is
active, send a \samp{EPRT} or \samp{PORT} command and the transfer command specified
by \var{cmd}, and accept the connection. If the server is passive,
@@ -210,7 +219,7 @@ not recognize the \samp{REST} command, an
simply call \method{transfercmd()} without a \var{rest} argument.
\end{methoddesc}
-\begin{methoddesc}{ntransfercmd}{cmd\optional{, rest}}
+\begin{methoddesc}[FTP]{ntransfercmd}{cmd\optional{, rest}}
Like \method{transfercmd()}, but returns a tuple of the data
connection and the expected size of the data. If the expected size
could not be computed, \code{None} will be returned as the expected
@@ -218,14 +227,14 @@ size. \var{cmd} and \var{rest} means the same thing as in
\method{transfercmd()}.
\end{methoddesc}
-\begin{methoddesc}{nlst}{argument\optional{, \ldots}}
+\begin{methoddesc}[FTP]{nlst}{argument\optional{, \ldots}}
Return a list of files as returned by the \samp{NLST} command. The
optional \var{argument} is a directory to list (default is the current
server directory). Multiple arguments can be used to pass
non-standard options to the \samp{NLST} command.
\end{methoddesc}
-\begin{methoddesc}{dir}{argument\optional{, \ldots}}
+\begin{methoddesc}[FTP]{dir}{argument\optional{, \ldots}}
Produce a directory listing as returned by the \samp{LIST} command,
printing it to standard output. The optional \var{argument} is a
directory to list (default is the current server directory). Multiple
@@ -235,41 +244,41 @@ command. If the last argument is a function, it is used as a
prints to \code{sys.stdout}. This method returns \code{None}.
\end{methoddesc}
-\begin{methoddesc}{rename}{fromname, toname}
+\begin{methoddesc}[FTP]{rename}{fromname, toname}
Rename file \var{fromname} on the server to \var{toname}.
\end{methoddesc}
-\begin{methoddesc}{delete}{filename}
+\begin{methoddesc}[FTP]{delete}{filename}
Remove the file named \var{filename} from the server. If successful,
returns the text of the response, otherwise raises
\exception{error_perm} on permission errors or
\exception{error_reply} on other errors.
\end{methoddesc}
-\begin{methoddesc}{cwd}{pathname}
+\begin{methoddesc}[FTP]{cwd}{pathname}
Set the current directory on the server.
\end{methoddesc}
-\begin{methoddesc}{mkd}{pathname}
+\begin{methoddesc}[FTP]{mkd}{pathname}
Create a new directory on the server.
\end{methoddesc}
-\begin{methoddesc}{pwd}{}
+\begin{methoddesc}[FTP]{pwd}{}
Return the pathname of the current directory on the server.
\end{methoddesc}
-\begin{methoddesc}{rmd}{dirname}
+\begin{methoddesc}[FTP]{rmd}{dirname}
Remove the directory named \var{dirname} on the server.
\end{methoddesc}
-\begin{methoddesc}{size}{filename}
+\begin{methoddesc}[FTP]{size}{filename}
Request the size of the file named \var{filename} on the server. On
success, the size of the file is returned as an integer, otherwise
\code{None} is returned. Note that the \samp{SIZE} command is not
standardized, but is supported by many common server implementations.
\end{methoddesc}
-\begin{methoddesc}{quit}{}
+\begin{methoddesc}[FTP]{quit}{}
Send a \samp{QUIT} command to the server and close the connection.
This is the ``polite'' way to close a connection, but it may raise an
exception of the server reponds with an error to the
@@ -278,7 +287,7 @@ method which renders the \class{FTP} instance useless for subsequent
calls (see below).
\end{methoddesc}
-\begin{methoddesc}{close}{}
+\begin{methoddesc}[FTP]{close}{}
Close the connection unilaterally. This should not be applied to an
already closed connection such as after a successful call to
\method{quit()}. After this call the \class{FTP} instance should not
diff --git a/Doc/lib/libfuncs.tex b/Doc/lib/libfuncs.tex
index b488ce4..0900317 100644
--- a/Doc/lib/libfuncs.tex
+++ b/Doc/lib/libfuncs.tex
@@ -175,15 +175,15 @@ class C:
\code{\var{x} > \var{y}}.
\end{funcdesc}
-\begin{funcdesc}{compile}{string, filename, kind\optional{,
+\begin{funcdesc}{compile}{source, filename, mode\optional{,
flags\optional{, dont_inherit}}}
- Compile the \var{string} into a code object. Code objects can be
+ Compile the \var{source} into a code object. Code objects can be
executed by a call to \function{exec()} or evaluated by a call to
\function{eval()}. The \var{filename} argument should
give the file from which the code was read; pass some recognizable value
if it wasn't read from a file (\code{'<string>'} is commonly used).
- The \var{kind} argument specifies what kind of code must be
- compiled; it can be \code{'exec'} if \var{string} consists of a
+ The \var{mode} argument specifies what kind of code must be
+ compiled; it can be \code{'exec'} if \var{source} consists of a
sequence of statements, \code{'eval'} if it consists of a single
expression, or \code{'single'} if it consists of a single
interactive statement (in the latter case, expression statements
@@ -198,7 +198,7 @@ class C:
The optional arguments \var{flags} and \var{dont_inherit}
(which are new in Python 2.2) control which future statements (see
- \pep{236}) affect the compilation of \var{string}. If neither is
+ \pep{236}) affect the compilation of \var{source}. If neither is
present (or both are zero) the code is compiled with those future
statements that are in effect in the code that is calling compile.
If the \var{flags} argument is given and \var{dont_inherit} is not
@@ -582,8 +582,9 @@ class C:
\begin{funcdesc}{isinstance}{object, classinfo}
Return true if the \var{object} argument is an instance of the
\var{classinfo} argument, or of a (direct or indirect) subclass
- thereof. Also return true if \var{classinfo} is a type object and
- \var{object} is an object of that type. If \var{object} is not a
+ thereof. Also return true if \var{classinfo} is a type object
+ (new-style class) and \var{object} is an object of that type or of a
+ (direct or indirect) subclass thereof. If \var{object} is not a
class instance or an object of the given type, the function always
returns false. If \var{classinfo} is neither a class object nor a
type object, it may be a tuple of class or type objects, or may
@@ -641,6 +642,11 @@ class C:
\warning{The contents of this dictionary should not be modified;
changes may not affect the values of local variables used by the
interpreter.}
+
+ Free variables are returned by \var{locals} when it is called in
+ a function block. Modifications of free variables may not affect
+ the values used by the interpreter. Free variables are not
+ returned in class blocks.
\end{funcdesc}
\begin{funcdesc}{long}{\optional{x\optional{, radix}}}
@@ -980,7 +986,7 @@ except NameError:
\begin{funcdesc}{reversed}{seq}
Return a reverse iterator. \var{seq} must be an object which
- supports the sequence protocol (the __len__() method and the
+ supports the sequence protocol (the \method{__len__()} method and the
\method{__getitem__()} method with integer arguments starting at
\code{0}).
\versionadded{2.4}
@@ -1148,7 +1154,7 @@ class C(B):
as detailed below.
\end{funcdesc}
-\begin{funcdesc}{type}{name, bases, dict}
+\begin{funcdescni}{type}{name, bases, dict}
Return a new type object. This is essentially a dynamic form of the
\keyword{class} statement. The \var{name} string is the class name
and becomes the \member{__name__} attribute; the \var{bases} tuple
@@ -1165,7 +1171,7 @@ class C(B):
>>> X = type('X', (object,), dict(a=1))
\end{verbatim}
\versionadded{2.2}
-\end{funcdesc}
+\end{funcdescni}
\begin{funcdesc}{unichr}{i}
Return the Unicode string of one character whose Unicode code is the
diff --git a/Doc/lib/libgettext.tex b/Doc/lib/libgettext.tex
index 5c7c6b9..6aee255 100644
--- a/Doc/lib/libgettext.tex
+++ b/Doc/lib/libgettext.tex
@@ -102,9 +102,9 @@ If no translation is found, return \var{singular} if \var{n} is 1;
return \var{plural} otherwise.
The Plural formula is taken from the catalog header. It is a C or
-Python expression that has a free variable n; the expression evaluates
+Python expression that has a free variable \var{n}; the expression evaluates
to the index of the plural in the catalog. See the GNU gettext
-documentation for the precise syntax to be used in .po files, and the
+documentation for the precise syntax to be used in \file{.po} files and the
formulas for a variety of languages.
\versionadded{2.3}
diff --git a/Doc/lib/libhmac.tex b/Doc/lib/libhmac.tex
index 5ca24d1..5329cb5 100644
--- a/Doc/lib/libhmac.tex
+++ b/Doc/lib/libhmac.tex
@@ -15,7 +15,7 @@ This module implements the HMAC algorithm as described by \rfc{2104}.
Return a new hmac object. If \var{msg} is present, the method call
\code{update(\var{msg})} is made. \var{digestmod} is the digest
constructor or module for the HMAC object to use. It defaults to
- the \code{\refmodule{hashlib}.md5} constructor. \note{The md5 hash
+ the \function{\refmodule{hashlib}.md5} constructor. \note{The md5 hash
has known weaknesses but remains the default for backwards compatibility.
Choose a better one for your application.}
\end{funcdesc}
diff --git a/Doc/lib/libhotshot.tex b/Doc/lib/libhotshot.tex
index ae089c2..0004e37 100644
--- a/Doc/lib/libhotshot.tex
+++ b/Doc/lib/libhotshot.tex
@@ -48,25 +48,25 @@ information).
Profile objects have the following methods:
-\begin{methoddesc}{addinfo}{key, value}
+\begin{methoddesc}[Profile]{addinfo}{key, value}
Add an arbitrary labelled value to the profile output.
\end{methoddesc}
-\begin{methoddesc}{close}{}
+\begin{methoddesc}[Profile]{close}{}
Close the logfile and terminate the profiler.
\end{methoddesc}
-\begin{methoddesc}{fileno}{}
+\begin{methoddesc}[Profile]{fileno}{}
Return the file descriptor of the profiler's log file.
\end{methoddesc}
-\begin{methoddesc}{run}{cmd}
+\begin{methoddesc}[Profile]{run}{cmd}
Profile an \function{exec()}-compatible string in the script environment.
The globals from the \refmodule[main]{__main__} module are used as
both the globals and locals for the script.
\end{methoddesc}
-\begin{methoddesc}{runcall}{func, *args, **keywords}
+\begin{methoddesc}[Profile]{runcall}{func, *args, **keywords}
Profile a single call of a callable.
Additional positional and keyword arguments may be passed
along; the result of the call is returned, and exceptions are
@@ -75,16 +75,16 @@ disabled on the way out.
\end{methoddesc}
-\begin{methoddesc}{runctx}{cmd, globals, locals}
+\begin{methoddesc}[Profile]{runctx}{cmd, globals, locals}
Profile an \function{exec()}-compatible string in a specific environment.
The string is compiled before profiling begins.
\end{methoddesc}
-\begin{methoddesc}{start}{}
+\begin{methoddesc}[Profile]{start}{}
Start the profiler.
\end{methoddesc}
-\begin{methoddesc}{stop}{}
+\begin{methoddesc}[Profile]{stop}{}
Stop the profiler.
\end{methoddesc}
diff --git a/Doc/lib/libhtmllib.tex b/Doc/lib/libhtmllib.tex
index a84dd85..e51dfcb 100644
--- a/Doc/lib/libhtmllib.tex
+++ b/Doc/lib/libhtmllib.tex
@@ -96,11 +96,11 @@ error while parsing.
In addition to tag methods, the \class{HTMLParser} class provides some
additional methods and instance variables for use within tag methods.
-\begin{memberdesc}{formatter}
+\begin{memberdesc}[HTMLParser]{formatter}
This is the formatter instance associated with the parser.
\end{memberdesc}
-\begin{memberdesc}{nofill}
+\begin{memberdesc}[HTMLParser]{nofill}
Boolean flag which should be true when whitespace should not be
collapsed, or false when it should be. In general, this should only
be true when character data is to be treated as ``preformatted'' text,
@@ -109,7 +109,7 @@ affects the operation of \method{handle_data()} and \method{save_end()}.
\end{memberdesc}
-\begin{methoddesc}{anchor_bgn}{href, name, type}
+\begin{methoddesc}[HTMLParser]{anchor_bgn}{href, name, type}
This method is called at the start of an anchor region. The arguments
correspond to the attributes of the \code{<A>} tag with the same
names. The default implementation maintains a list of hyperlinks
@@ -118,27 +118,27 @@ document. The list of hyperlinks is available as the data attribute
\member{anchorlist}.
\end{methoddesc}
-\begin{methoddesc}{anchor_end}{}
+\begin{methoddesc}[HTMLParser]{anchor_end}{}
This method is called at the end of an anchor region. The default
implementation adds a textual footnote marker using an index into the
list of hyperlinks created by \method{anchor_bgn()}.
\end{methoddesc}
-\begin{methoddesc}{handle_image}{source, alt\optional{, ismap\optional{,
+\begin{methoddesc}[HTMLParser]{handle_image}{source, alt\optional{, ismap\optional{,
align\optional{, width\optional{, height}}}}}
This method is called to handle images. The default implementation
simply passes the \var{alt} value to the \method{handle_data()}
method.
\end{methoddesc}
-\begin{methoddesc}{save_bgn}{}
+\begin{methoddesc}[HTMLParser]{save_bgn}{}
Begins saving character data in a buffer instead of sending it to the
formatter object. Retrieve the stored data via \method{save_end()}.
Use of the \method{save_bgn()} / \method{save_end()} pair may not be
nested.
\end{methoddesc}
-\begin{methoddesc}{save_end}{}
+\begin{methoddesc}[HTMLParser]{save_end}{}
Ends buffering character data and returns all data saved since the
preceding call to \method{save_bgn()}. If the \member{nofill} flag is
false, whitespace is collapsed to single spaces. A call to this
diff --git a/Doc/lib/libhtmlparser.tex b/Doc/lib/libhtmlparser.tex
index 52f8409..5e99f27 100644
--- a/Doc/lib/libhtmlparser.tex
+++ b/Doc/lib/libhtmlparser.tex
@@ -75,14 +75,18 @@ This method is called to handle the start of a tag. It is intended to
be overridden by a derived class; the base class implementation does
nothing.
-The \var{tag} argument is the name of the tag converted to
-lower case. The \var{attrs} argument is a list of \code{(\var{name},
-\var{value})} pairs containing the attributes found inside the tag's
-\code{<>} brackets. The \var{name} will be translated to lower case
-and double quotes and backslashes in the \var{value} have been
-interpreted. For instance, for the tag \code{<A
-HREF="http://www.cwi.nl/">}, this method would be called as
+The \var{tag} argument is the name of the tag converted to lower case.
+The \var{attrs} argument is a list of \code{(\var{name}, \var{value})}
+pairs containing the attributes found inside the tag's \code{<>}
+brackets. The \var{name} will be translated to lower case, and quotes
+in the \var{value} have been removed, and character and entity
+references have been replaced. For instance, for the tag \code{<A
+ HREF="http://www.cwi.nl/">}, this method would be called as
\samp{handle_starttag('a', [('href', 'http://www.cwi.nl/')])}.
+
+\versionchanged[All entity references from htmlentitydefs are now
+replaced in the attribute values]{2.6}
+
\end{methoddesc}
\begin{methoddesc}{handle_startendtag}{tag, attrs}
diff --git a/Doc/lib/libhttplib.tex b/Doc/lib/libhttplib.tex
index 557ee3d..5fd48c1 100644
--- a/Doc/lib/libhttplib.tex
+++ b/Doc/lib/libhttplib.tex
@@ -26,18 +26,27 @@ that use HTTP and HTTPS.
The module provides the following classes:
-\begin{classdesc}{HTTPConnection}{host\optional{, port}}
+\begin{classdesc}{HTTPConnection}{host\optional{, port\optional{,
+ strict\optional{, timeout}}}}
An \class{HTTPConnection} instance represents one transaction with an HTTP
server. It should be instantiated passing it a host and optional port number.
If no port number is passed, the port is extracted from the host string if it
has the form \code{\var{host}:\var{port}}, else the default HTTP port (80) is
-used. For example, the following calls all create instances that connect to
+used. When True, the optional parameter \var{strict}
+causes \code{BadStatusLine} to be raised if the status line can't be parsed
+as a valid HTTP/1.0 or 1.1 status line. If the optional \var{timeout}
+parameter is given, connection attempts will timeout after that many
+seconds (if it is not given or \code{None}, the global default
+timeout setting is used).
+
+For example, the following calls all create instances that connect to
the server at the same host and port:
\begin{verbatim}
>>> h1 = httplib.HTTPConnection('www.cwi.nl')
>>> h2 = httplib.HTTPConnection('www.cwi.nl:80')
>>> h3 = httplib.HTTPConnection('www.cwi.nl', 80)
+>>> h3 = httplib.HTTPConnection('www.cwi.nl', 80, timeout=10)
\end{verbatim}
\versionadded{2.0}
\end{classdesc}
@@ -300,7 +309,7 @@ Example: \code{httplib.responses[httplib.NOT_FOUND]} is \code{'Not Found'}.
\class{HTTPConnection} instances have the following methods:
-\begin{methoddesc}{request}{method, url\optional{, body\optional{, headers}}}
+\begin{methoddesc}[HTTPConnection]{request}{method, url\optional{, body\optional{, headers}}}
This will send a request to the server using the HTTP request method
\var{method} and the selector \var{url}. If the \var{body} argument is
present, it should be a string of data to send after the headers are finished.
@@ -314,24 +323,24 @@ with the request.
\versionchanged[\var{body} can be a file object]{2.6}
\end{methoddesc}
-\begin{methoddesc}{getresponse}{}
+\begin{methoddesc}[HTTPConnection]{getresponse}{}
Should be called after a request is sent to get the response from the server.
Returns an \class{HTTPResponse} instance.
\note{Note that you must have read the whole response before you can send a new
request to the server.}
\end{methoddesc}
-\begin{methoddesc}{set_debuglevel}{level}
+\begin{methoddesc}[HTTPConnection]{set_debuglevel}{level}
Set the debugging level (the amount of debugging output printed).
The default debug level is \code{0}, meaning no debugging output is
printed.
\end{methoddesc}
-\begin{methoddesc}{connect}{}
+\begin{methoddesc}[HTTPConnection]{connect}{}
Connect to the server specified when the object was created.
\end{methoddesc}
-\begin{methoddesc}{close}{}
+\begin{methoddesc}[HTTPConnection]{close}{}
Close the connection to the server.
\end{methoddesc}
@@ -339,7 +348,7 @@ As an alternative to using the \method{request()} method described above,
you can also send your request step by step, by using the four functions
below.
-\begin{methoddesc}{putrequest}{request, selector\optional{,
+\begin{methoddesc}[HTTPConnection]{putrequest}{request, selector\optional{,
skip\_host\optional{, skip_accept_encoding}}}
This should be the first call after the connection to the server has
been made. It sends a line to the server consisting of the
@@ -351,18 +360,18 @@ with non-False values.
\versionchanged[\var{skip_accept_encoding} argument added]{2.4}
\end{methoddesc}
-\begin{methoddesc}{putheader}{header, argument\optional{, ...}}
+\begin{methoddesc}[HTTPConnection]{putheader}{header, argument\optional{, ...}}
Send an \rfc{822}-style header to the server. It sends a line to the
server consisting of the header, a colon and a space, and the first
argument. If more arguments are given, continuation lines are sent,
each consisting of a tab and an argument.
\end{methoddesc}
-\begin{methoddesc}{endheaders}{}
+\begin{methoddesc}[HTTPConnection]{endheaders}{}
Send a blank line to the server, signalling the end of the headers.
\end{methoddesc}
-\begin{methoddesc}{send}{data}
+\begin{methoddesc}[HTTPConnection]{send}{data}
Send data to the server. This should be used directly only after the
\method{endheaders()} method has been called and before
\method{getresponse()} is called.
@@ -372,34 +381,34 @@ Send data to the server. This should be used directly only after the
\class{HTTPResponse} instances have the following methods and attributes:
-\begin{methoddesc}{read}{\optional{amt}}
+\begin{methoddesc}[HTTPResponse]{read}{\optional{amt}}
Reads and returns the response body, or up to the next \var{amt} bytes.
\end{methoddesc}
-\begin{methoddesc}{getheader}{name\optional{, default}}
+\begin{methoddesc}[HTTPResponse]{getheader}{name\optional{, default}}
Get the contents of the header \var{name}, or \var{default} if there is no
matching header.
\end{methoddesc}
-\begin{methoddesc}{getheaders}{}
+\begin{methoddesc}[HTTPResponse]{getheaders}{}
Return a list of (header, value) tuples. \versionadded{2.4}
\end{methoddesc}
-\begin{datadesc}{msg}
+\begin{memberdesc}[HTTPResponse]{msg}
A \class{mimetools.Message} instance containing the response headers.
-\end{datadesc}
+\end{memberdesc}
-\begin{datadesc}{version}
+\begin{memberdesc}[HTTPResponse]{version}
HTTP protocol version used by server. 10 for HTTP/1.0, 11 for HTTP/1.1.
-\end{datadesc}
+\end{memberdesc}
-\begin{datadesc}{status}
+\begin{memberdesc}[HTTPResponse]{status}
Status code returned by server.
-\end{datadesc}
+\end{memberdesc}
-\begin{datadesc}{reason}
+\begin{memberdesc}[HTTPResponse]{reason}
Reason phrase returned by server.
-\end{datadesc}
+\end{memberdesc}
\subsection{Examples \label{httplib-examples}}
diff --git a/Doc/lib/libimaplib.tex b/Doc/lib/libimaplib.tex
index 7658bc9..e34caaa 100644
--- a/Doc/lib/libimaplib.tex
+++ b/Doc/lib/libimaplib.tex
@@ -153,11 +153,11 @@ can contain an asterisk to indicate an infinite upper bound
An \class{IMAP4} instance has the following methods:
-\begin{methoddesc}{append}{mailbox, flags, date_time, message}
+\begin{methoddesc}[IMAP4]{append}{mailbox, flags, date_time, message}
Append \var{message} to named mailbox.
\end{methoddesc}
-\begin{methoddesc}{authenticate}{mechanism, authobject}
+\begin{methoddesc}[IMAP4]{authenticate}{mechanism, authobject}
Authenticate command --- requires response processing.
\var{mechanism} specifies which authentication mechanism is to be
@@ -176,115 +176,115 @@ data = authobject(response)
be sent instead.
\end{methoddesc}
-\begin{methoddesc}{check}{}
+\begin{methoddesc}[IMAP4]{check}{}
Checkpoint mailbox on server.
\end{methoddesc}
-\begin{methoddesc}{close}{}
+\begin{methoddesc}[IMAP4]{close}{}
Close currently selected mailbox. Deleted messages are removed from
writable mailbox. This is the recommended command before
\samp{LOGOUT}.
\end{methoddesc}
-\begin{methoddesc}{copy}{message_set, new_mailbox}
+\begin{methoddesc}[IMAP4]{copy}{message_set, new_mailbox}
Copy \var{message_set} messages onto end of \var{new_mailbox}.
\end{methoddesc}
-\begin{methoddesc}{create}{mailbox}
+\begin{methoddesc}[IMAP4]{create}{mailbox}
Create new mailbox named \var{mailbox}.
\end{methoddesc}
-\begin{methoddesc}{delete}{mailbox}
+\begin{methoddesc}[IMAP4]{delete}{mailbox}
Delete old mailbox named \var{mailbox}.
\end{methoddesc}
-\begin{methoddesc}{deleteacl}{mailbox, who}
+\begin{methoddesc}[IMAP4]{deleteacl}{mailbox, who}
Delete the ACLs (remove any rights) set for who on mailbox.
\versionadded{2.4}
\end{methoddesc}
-\begin{methoddesc}{expunge}{}
+\begin{methoddesc}[IMAP4]{expunge}{}
Permanently remove deleted items from selected mailbox. Generates an
\samp{EXPUNGE} response for each deleted message. Returned data
contains a list of \samp{EXPUNGE} message numbers in order
received.
\end{methoddesc}
-\begin{methoddesc}{fetch}{message_set, message_parts}
+\begin{methoddesc}[IMAP4]{fetch}{message_set, message_parts}
Fetch (parts of) messages. \var{message_parts} should be
a string of message part names enclosed within parentheses,
eg: \samp{"(UID BODY[TEXT])"}. Returned data are tuples
of message part envelope and data.
\end{methoddesc}
-\begin{methoddesc}{getacl}{mailbox}
+\begin{methoddesc}[IMAP4]{getacl}{mailbox}
Get the \samp{ACL}s for \var{mailbox}.
The method is non-standard, but is supported by the \samp{Cyrus} server.
\end{methoddesc}
-\begin{methoddesc}{getannotation}{mailbox, entry, attribute}
+\begin{methoddesc}[IMAP4]{getannotation}{mailbox, entry, attribute}
Retrieve the specified \samp{ANNOTATION}s for \var{mailbox}.
The method is non-standard, but is supported by the \samp{Cyrus} server.
\versionadded{2.5}
\end{methoddesc}
-\begin{methoddesc}{getquota}{root}
+\begin{methoddesc}[IMAP4]{getquota}{root}
Get the \samp{quota} \var{root}'s resource usage and limits.
This method is part of the IMAP4 QUOTA extension defined in rfc2087.
\versionadded{2.3}
\end{methoddesc}
-\begin{methoddesc}{getquotaroot}{mailbox}
+\begin{methoddesc}[IMAP4]{getquotaroot}{mailbox}
Get the list of \samp{quota} \samp{roots} for the named \var{mailbox}.
This method is part of the IMAP4 QUOTA extension defined in rfc2087.
\versionadded{2.3}
\end{methoddesc}
-\begin{methoddesc}{list}{\optional{directory\optional{, pattern}}}
+\begin{methoddesc}[IMAP4]{list}{\optional{directory\optional{, pattern}}}
List mailbox names in \var{directory} matching
\var{pattern}. \var{directory} defaults to the top-level mail
folder, and \var{pattern} defaults to match anything. Returned data
contains a list of \samp{LIST} responses.
\end{methoddesc}
-\begin{methoddesc}{login}{user, password}
+\begin{methoddesc}[IMAP4]{login}{user, password}
Identify the client using a plaintext password.
The \var{password} will be quoted.
\end{methoddesc}
-\begin{methoddesc}{login_cram_md5}{user, password}
+\begin{methoddesc}[IMAP4]{login_cram_md5}{user, password}
Force use of \samp{CRAM-MD5} authentication when identifying the
client to protect the password. Will only work if the server
\samp{CAPABILITY} response includes the phrase \samp{AUTH=CRAM-MD5}.
\versionadded{2.3}
\end{methoddesc}
-\begin{methoddesc}{logout}{}
+\begin{methoddesc}[IMAP4]{logout}{}
Shutdown connection to server. Returns server \samp{BYE} response.
\end{methoddesc}
-\begin{methoddesc}{lsub}{\optional{directory\optional{, pattern}}}
+\begin{methoddesc}[IMAP4]{lsub}{\optional{directory\optional{, pattern}}}
List subscribed mailbox names in directory matching pattern.
\var{directory} defaults to the top level directory and
\var{pattern} defaults to match any mailbox.
Returned data are tuples of message part envelope and data.
\end{methoddesc}
-\begin{methoddesc}{myrights}{mailbox}
+\begin{methoddesc}[IMAP4]{myrights}{mailbox}
Show my ACLs for a mailbox (i.e. the rights that I have on mailbox).
\versionadded{2.4}
\end{methoddesc}
-\begin{methoddesc}{namespace}{}
+\begin{methoddesc}[IMAP4]{namespace}{}
Returns IMAP namespaces as defined in RFC2342.
\versionadded{2.3}
\end{methoddesc}
-\begin{methoddesc}{noop}{}
+\begin{methoddesc}[IMAP4]{noop}{}
Send \samp{NOOP} to server.
\end{methoddesc}
-\begin{methoddesc}{open}{host, port}
+\begin{methoddesc}[IMAP4]{open}{host, port}
Opens socket to \var{port} at \var{host}.
The connection objects established by this method
will be used in the \code{read}, \code{readline}, \code{send}, and
@@ -292,42 +292,42 @@ data = authobject(response)
You may override this method.
\end{methoddesc}
-\begin{methoddesc}{partial}{message_num, message_part, start, length}
+\begin{methoddesc}[IMAP4]{partial}{message_num, message_part, start, length}
Fetch truncated part of a message.
Returned data is a tuple of message part envelope and data.
\end{methoddesc}
-\begin{methoddesc}{proxyauth}{user}
+\begin{methoddesc}[IMAP4]{proxyauth}{user}
Assume authentication as \var{user}.
Allows an authorised administrator to proxy into any user's mailbox.
\versionadded{2.3}
\end{methoddesc}
-\begin{methoddesc}{read}{size}
+\begin{methoddesc}[IMAP4]{read}{size}
Reads \var{size} bytes from the remote server.
You may override this method.
\end{methoddesc}
-\begin{methoddesc}{readline}{}
+\begin{methoddesc}[IMAP4]{readline}{}
Reads one line from the remote server.
You may override this method.
\end{methoddesc}
-\begin{methoddesc}{recent}{}
+\begin{methoddesc}[IMAP4]{recent}{}
Prompt server for an update. Returned data is \code{None} if no new
messages, else value of \samp{RECENT} response.
\end{methoddesc}
-\begin{methoddesc}{rename}{oldmailbox, newmailbox}
+\begin{methoddesc}[IMAP4]{rename}{oldmailbox, newmailbox}
Rename mailbox named \var{oldmailbox} to \var{newmailbox}.
\end{methoddesc}
-\begin{methoddesc}{response}{code}
+\begin{methoddesc}[IMAP4]{response}{code}
Return data for response \var{code} if received, or
\code{None}. Returns the given code, instead of the usual type.
\end{methoddesc}
-\begin{methoddesc}{search}{charset, criterion\optional{, ...}}
+\begin{methoddesc}[IMAP4]{search}{charset, criterion\optional{, ...}}
Search mailbox for matching messages. \var{charset} may be
\code{None}, in which case no \samp{CHARSET} will be specified in the
request to the server. The IMAP protocol requires that at least one
@@ -345,45 +345,45 @@ typ, msgnums = M.search(None, '(FROM "LDJ")')
\end{verbatim}
\end{methoddesc}
-\begin{methoddesc}{select}{\optional{mailbox\optional{, readonly}}}
+\begin{methoddesc}[IMAP4]{select}{\optional{mailbox\optional{, readonly}}}
Select a mailbox. Returned data is the count of messages in
\var{mailbox} (\samp{EXISTS} response). The default \var{mailbox}
is \code{'INBOX'}. If the \var{readonly} flag is set, modifications
to the mailbox are not allowed.
\end{methoddesc}
-\begin{methoddesc}{send}{data}
+\begin{methoddesc}[IMAP4]{send}{data}
Sends \code{data} to the remote server.
You may override this method.
\end{methoddesc}
-\begin{methoddesc}{setacl}{mailbox, who, what}
+\begin{methoddesc}[IMAP4]{setacl}{mailbox, who, what}
Set an \samp{ACL} for \var{mailbox}.
The method is non-standard, but is supported by the \samp{Cyrus} server.
\end{methoddesc}
-\begin{methoddesc}{setannotation}{mailbox, entry, attribute\optional{, ...}}
+\begin{methoddesc}[IMAP4]{setannotation}{mailbox, entry, attribute\optional{, ...}}
Set \samp{ANNOTATION}s for \var{mailbox}.
The method is non-standard, but is supported by the \samp{Cyrus} server.
\versionadded{2.5}
\end{methoddesc}
-\begin{methoddesc}{setquota}{root, limits}
+\begin{methoddesc}[IMAP4]{setquota}{root, limits}
Set the \samp{quota} \var{root}'s resource \var{limits}.
This method is part of the IMAP4 QUOTA extension defined in rfc2087.
\versionadded{2.3}
\end{methoddesc}
-\begin{methoddesc}{shutdown}{}
+\begin{methoddesc}[IMAP4]{shutdown}{}
Close connection established in \code{open}.
You may override this method.
\end{methoddesc}
-\begin{methoddesc}{socket}{}
+\begin{methoddesc}[IMAP4]{socket}{}
Returns socket instance used to connect to server.
\end{methoddesc}
-\begin{methoddesc}{sort}{sort_criteria, charset, search_criterion\optional{, ...}}
+\begin{methoddesc}[IMAP4]{sort}{sort_criteria, charset, search_criterion\optional{, ...}}
The \code{sort} command is a variant of \code{search} with sorting
semantics for the results. Returned data contains a space separated
list of matching message numbers.
@@ -402,11 +402,11 @@ typ, msgnums = M.search(None, '(FROM "LDJ")')
This is an \samp{IMAP4rev1} extension command.
\end{methoddesc}
-\begin{methoddesc}{status}{mailbox, names}
+\begin{methoddesc}[IMAP4]{status}{mailbox, names}
Request named status conditions for \var{mailbox}.
\end{methoddesc}
-\begin{methoddesc}{store}{message_set, command, flag_list}
+\begin{methoddesc}[IMAP4]{store}{message_set, command, flag_list}
Alters flag dispositions for messages in mailbox. \var{command} is
specified by section 6.4.6 of \rfc{2060} as being one of "FLAGS", "+FLAGS",
or "-FLAGS", optionally with a suffix of ".SILENT".
@@ -421,11 +421,11 @@ M.expunge()
\end{verbatim}
\end{methoddesc}
-\begin{methoddesc}{subscribe}{mailbox}
+\begin{methoddesc}[IMAP4]{subscribe}{mailbox}
Subscribe to new mailbox.
\end{methoddesc}
-\begin{methoddesc}{thread}{threading_algorithm, charset,
+\begin{methoddesc}[IMAP4]{thread}{threading_algorithm, charset,
search_criterion\optional{, ...}}
The \code{thread} command is a variant of \code{search} with
threading semantics for the results. Returned data contains a space
@@ -448,18 +448,18 @@ M.expunge()
This is an \samp{IMAP4rev1} extension command. \versionadded{2.4}
\end{methoddesc}
-\begin{methoddesc}{uid}{command, arg\optional{, ...}}
+\begin{methoddesc}[IMAP4]{uid}{command, arg\optional{, ...}}
Execute command args with messages identified by UID, rather than
message number. Returns response appropriate to command. At least
one argument must be supplied; if none are provided, the server will
return an error and an exception will be raised.
\end{methoddesc}
-\begin{methoddesc}{unsubscribe}{mailbox}
+\begin{methoddesc}[IMAP4]{unsubscribe}{mailbox}
Unsubscribe from old mailbox.
\end{methoddesc}
-\begin{methoddesc}{xatom}{name\optional{, arg\optional{, ...}}}
+\begin{methoddesc}[IMAP4]{xatom}{name\optional{, arg\optional{, ...}}}
Allow simple extension commands notified by server in
\samp{CAPABILITY} response.
\end{methoddesc}
@@ -467,7 +467,7 @@ M.expunge()
Instances of \class{IMAP4_SSL} have just one additional method:
-\begin{methoddesc}{ssl}{}
+\begin{methoddesc}[IMAP4_SSL]{ssl}{}
Returns SSLObject instance used for the secure connection with the server.
\end{methoddesc}
@@ -475,12 +475,12 @@ Instances of \class{IMAP4_SSL} have just one additional method:
The following attributes are defined on instances of \class{IMAP4}:
-\begin{memberdesc}{PROTOCOL_VERSION}
+\begin{memberdesc}[IMAP4]{PROTOCOL_VERSION}
The most recent supported protocol in the
\samp{CAPABILITY} response from the server.
\end{memberdesc}
-\begin{memberdesc}{debug}
+\begin{memberdesc}[IMAP4]{debug}
Integer value to control debugging output. The initialize value is
taken from the module variable \code{Debug}. Values greater than
three trace each command.
diff --git a/Doc/lib/liblogging.tex b/Doc/lib/liblogging.tex
index f9c1d72..dabab53 100644
--- a/Doc/lib/liblogging.tex
+++ b/Doc/lib/liblogging.tex
@@ -364,13 +364,13 @@ Loggers have the following attributes and methods. Note that Loggers are
never instantiated directly, but always through the module-level function
\function{logging.getLogger(name)}.
-\begin{datadesc}{propagate}
+\begin{memberdesc}[Logger]{propagate}
If this evaluates to false, logging messages are not passed by this
logger or by child loggers to higher level (ancestor) loggers. The
constructor sets this attribute to 1.
-\end{datadesc}
+\end{memberdesc}
-\begin{methoddesc}{setLevel}{lvl}
+\begin{methoddesc}[Logger]{setLevel}{lvl}
Sets the threshold for this logger to \var{lvl}. Logging messages
which are less severe than \var{lvl} will be ignored. When a logger is
created, the level is set to \constant{NOTSET} (which causes all messages
@@ -393,21 +393,21 @@ messages will be processed. Otherwise, the root's level will be used
as the effective level.
\end{methoddesc}
-\begin{methoddesc}{isEnabledFor}{lvl}
+\begin{methoddesc}[Logger]{isEnabledFor}{lvl}
Indicates if a message of severity \var{lvl} would be processed by
this logger. This method checks first the module-level level set by
\function{logging.disable(lvl)} and then the logger's effective level as
determined by \method{getEffectiveLevel()}.
\end{methoddesc}
-\begin{methoddesc}{getEffectiveLevel}{}
+\begin{methoddesc}[Logger]{getEffectiveLevel}{}
Indicates the effective level for this logger. If a value other than
\constant{NOTSET} has been set using \method{setLevel()}, it is returned.
Otherwise, the hierarchy is traversed towards the root until a value
other than \constant{NOTSET} is found, and that value is returned.
\end{methoddesc}
-\begin{methoddesc}{debug}{msg\optional{, *args\optional{, **kwargs}}}
+\begin{methoddesc}[Logger]{debug}{msg\optional{, *args\optional{, **kwargs}}}
Logs a message with level \constant{DEBUG} on this logger.
The \var{msg} is the message format string, and the \var{args} are the
arguments which are merged into \var{msg} using the string formatting
@@ -462,67 +462,67 @@ above example). In such circumstances, it is likely that specialized
\end{methoddesc}
-\begin{methoddesc}{info}{msg\optional{, *args\optional{, **kwargs}}}
+\begin{methoddesc}[Logger]{info}{msg\optional{, *args\optional{, **kwargs}}}
Logs a message with level \constant{INFO} on this logger.
The arguments are interpreted as for \method{debug()}.
\end{methoddesc}
-\begin{methoddesc}{warning}{msg\optional{, *args\optional{, **kwargs}}}
+\begin{methoddesc}[Logger]{warning}{msg\optional{, *args\optional{, **kwargs}}}
Logs a message with level \constant{WARNING} on this logger.
The arguments are interpreted as for \method{debug()}.
\end{methoddesc}
-\begin{methoddesc}{error}{msg\optional{, *args\optional{, **kwargs}}}
+\begin{methoddesc}[Logger]{error}{msg\optional{, *args\optional{, **kwargs}}}
Logs a message with level \constant{ERROR} on this logger.
The arguments are interpreted as for \method{debug()}.
\end{methoddesc}
-\begin{methoddesc}{critical}{msg\optional{, *args\optional{, **kwargs}}}
+\begin{methoddesc}[Logger]{critical}{msg\optional{, *args\optional{, **kwargs}}}
Logs a message with level \constant{CRITICAL} on this logger.
The arguments are interpreted as for \method{debug()}.
\end{methoddesc}
-\begin{methoddesc}{log}{lvl, msg\optional{, *args\optional{, **kwargs}}}
+\begin{methoddesc}[Logger]{log}{lvl, msg\optional{, *args\optional{, **kwargs}}}
Logs a message with integer level \var{lvl} on this logger.
The other arguments are interpreted as for \method{debug()}.
\end{methoddesc}
-\begin{methoddesc}{exception}{msg\optional{, *args}}
+\begin{methoddesc}[Logger]{exception}{msg\optional{, *args}}
Logs a message with level \constant{ERROR} on this logger.
The arguments are interpreted as for \method{debug()}. Exception info
is added to the logging message. This method should only be called
from an exception handler.
\end{methoddesc}
-\begin{methoddesc}{addFilter}{filt}
+\begin{methoddesc}[Logger]{addFilter}{filt}
Adds the specified filter \var{filt} to this logger.
\end{methoddesc}
-\begin{methoddesc}{removeFilter}{filt}
+\begin{methoddesc}[Logger]{removeFilter}{filt}
Removes the specified filter \var{filt} from this logger.
\end{methoddesc}
-\begin{methoddesc}{filter}{record}
+\begin{methoddesc}[Logger]{filter}{record}
Applies this logger's filters to the record and returns a true value if
the record is to be processed.
\end{methoddesc}
-\begin{methoddesc}{addHandler}{hdlr}
+\begin{methoddesc}[Logger]{addHandler}{hdlr}
Adds the specified handler \var{hdlr} to this logger.
\end{methoddesc}
-\begin{methoddesc}{removeHandler}{hdlr}
+\begin{methoddesc}[Logger]{removeHandler}{hdlr}
Removes the specified handler \var{hdlr} from this logger.
\end{methoddesc}
-\begin{methoddesc}{findCaller}{}
+\begin{methoddesc}[Logger]{findCaller}{}
Finds the caller's source filename and line number. Returns the filename,
line number and function name as a 3-element tuple.
\versionchanged[The function name was added. In earlier versions, the
filename and line number were returned as a 2-element tuple.]{2.5}
\end{methoddesc}
-\begin{methoddesc}{handle}{record}
+\begin{methoddesc}[Logger]{handle}{record}
Handles a record by passing it to all handlers associated with this logger
and its ancestors (until a false value of \var{propagate} is found).
This method is used for unpickled records received from a socket, as well
@@ -530,8 +530,8 @@ as those created locally. Logger-level filtering is applied using
\method{filter()}.
\end{methoddesc}
-\begin{methoddesc}{makeRecord}{name, lvl, fn, lno, msg, args, exc_info
- \optional{, func, extra}}
+\begin{methoddesc}[Logger]{makeRecord}{name, lvl, fn, lno, msg, args, exc_info
+ \optional{, func, extra}}
This is a factory method which can be overridden in subclasses to create
specialized \class{LogRecord} instances.
\versionchanged[\var{func} and \var{extra} were added]{2.5}
@@ -875,66 +875,66 @@ Handlers have the following attributes and methods. Note that
base for more useful subclasses. However, the \method{__init__()}
method in subclasses needs to call \method{Handler.__init__()}.
-\begin{methoddesc}{__init__}{level=\constant{NOTSET}}
+\begin{methoddesc}[Handler]{__init__}{level=\constant{NOTSET}}
Initializes the \class{Handler} instance by setting its level, setting
the list of filters to the empty list and creating a lock (using
\method{createLock()}) for serializing access to an I/O mechanism.
\end{methoddesc}
-\begin{methoddesc}{createLock}{}
+\begin{methoddesc}[Handler]{createLock}{}
Initializes a thread lock which can be used to serialize access to
underlying I/O functionality which may not be threadsafe.
\end{methoddesc}
-\begin{methoddesc}{acquire}{}
+\begin{methoddesc}[Handler]{acquire}{}
Acquires the thread lock created with \method{createLock()}.
\end{methoddesc}
-\begin{methoddesc}{release}{}
+\begin{methoddesc}[Handler]{release}{}
Releases the thread lock acquired with \method{acquire()}.
\end{methoddesc}
-\begin{methoddesc}{setLevel}{lvl}
+\begin{methoddesc}[Handler]{setLevel}{lvl}
Sets the threshold for this handler to \var{lvl}. Logging messages which are
less severe than \var{lvl} will be ignored. When a handler is created, the
level is set to \constant{NOTSET} (which causes all messages to be processed).
\end{methoddesc}
-\begin{methoddesc}{setFormatter}{form}
+\begin{methoddesc}[Handler]{setFormatter}{form}
Sets the \class{Formatter} for this handler to \var{form}.
\end{methoddesc}
-\begin{methoddesc}{addFilter}{filt}
+\begin{methoddesc}[Handler]{addFilter}{filt}
Adds the specified filter \var{filt} to this handler.
\end{methoddesc}
-\begin{methoddesc}{removeFilter}{filt}
+\begin{methoddesc}[Handler]{removeFilter}{filt}
Removes the specified filter \var{filt} from this handler.
\end{methoddesc}
-\begin{methoddesc}{filter}{record}
+\begin{methoddesc}[Handler]{filter}{record}
Applies this handler's filters to the record and returns a true value if
the record is to be processed.
\end{methoddesc}
-\begin{methoddesc}{flush}{}
+\begin{methoddesc}[Handler]{flush}{}
Ensure all logging output has been flushed. This version does
nothing and is intended to be implemented by subclasses.
\end{methoddesc}
-\begin{methoddesc}{close}{}
+\begin{methoddesc}[Handler]{close}{}
Tidy up any resources used by the handler. This version does
nothing and is intended to be implemented by subclasses.
\end{methoddesc}
-\begin{methoddesc}{handle}{record}
+\begin{methoddesc}[Handler]{handle}{record}
Conditionally emits the specified logging record, depending on
filters which may have been added to the handler. Wraps the actual
emission of the record with acquisition/release of the I/O thread
lock.
\end{methoddesc}
-\begin{methoddesc}{handleError}{record}
+\begin{methoddesc}[Handler]{handleError}{record}
This method should be called from handlers when an exception is
encountered during an \method{emit()} call. By default it does nothing,
which means that exceptions get silently ignored. This is what is
@@ -945,12 +945,12 @@ handler if you wish. The specified record is the one which was being
processed when the exception occurred.
\end{methoddesc}
-\begin{methoddesc}{format}{record}
+\begin{methoddesc}[Handler]{format}{record}
Do formatting for a record - if a formatter is set, use it.
Otherwise, use the default formatter for the module.
\end{methoddesc}
-\begin{methoddesc}{emit}{record}
+\begin{methoddesc}[Handler]{emit}{record}
Do whatever it takes to actually log the specified logging record.
This version is intended to be implemented by subclasses and so
raises a \exception{NotImplementedError}.
@@ -1138,9 +1138,6 @@ and \var{port}.
Closes the socket.
\end{methoddesc}
-\begin{methoddesc}{handleError}{}
-\end{methoddesc}
-
\begin{methoddesc}{emit}{}
Pickles the record's attribute dictionary and writes it to the socket in
binary format. If there is an error with the socket, silently drops the
diff --git a/Doc/lib/libmailbox.tex b/Doc/lib/libmailbox.tex
index 24765c8..c3e7ffd 100644
--- a/Doc/lib/libmailbox.tex
+++ b/Doc/lib/libmailbox.tex
@@ -1203,7 +1203,6 @@ correspond:
\end{tableii}
\subsection{Exceptions}
-\label{mailbox-deprecated}
The following exception classes are defined in the \module{mailbox} module:
@@ -1247,7 +1246,7 @@ in preference to them.
Older mailbox objects support only iteration and provide a single public
method:
-\begin{methoddesc}{next}{}
+\begin{methoddesc}[oldmailbox]{next}{}
Return the next message in the mailbox, created with the optional \var{factory}
argument passed into the mailbox object's constructor. By default this is an
\class{rfc822.Message} object (see the \refmodule{rfc822} module). Depending
@@ -1286,13 +1285,13 @@ For maximum portability, messages in a \UNIX-style mailbox are
separated by any line that begins exactly with the string \code{'From
'} (note the trailing space) if preceded by exactly two newlines.
Because of the wide-range of variations in practice, nothing else on
-the From_ line should be considered. However, the current
+the \samp{From_} line should be considered. However, the current
implementation doesn't check for the leading two newlines. This is
usually fine for most applications.
The \class{UnixMailbox} class implements a more strict version of
-From_ line checking, using a regular expression that usually correctly
-matched From_ delimiters. It considers delimiter line to be separated
+\samp{From_} line checking, using a regular expression that usually correctly
+matched \samp{From_} delimiters. It considers delimiter line to be separated
by \samp{From \var{name} \var{time}} lines. For maximum portability,
use the \class{PortableUnixMailbox} class instead. This class is
identical to \class{UnixMailbox} except that individual messages are
diff --git a/Doc/lib/libmimetools.tex b/Doc/lib/libmimetools.tex
index 5e800af..3e4bd4b 100644
--- a/Doc/lib/libmimetools.tex
+++ b/Doc/lib/libmimetools.tex
@@ -76,7 +76,7 @@ open file \var{output}. The block size is currently fixed at 8192.
The \class{Message} class defines the following methods in
addition to the \class{rfc822.Message} methods:
-\begin{methoddesc}{getplist}{}
+\begin{methoddesc}[Message]{getplist}{}
Return the parameter list of the \mailheader{Content-Type} header.
This is a list of strings. For parameters of the form
\samp{\var{key}=\var{value}}, \var{key} is converted to lower case but
@@ -86,34 +86,34 @@ This is a list of strings. For parameters of the form
'spam=2', 'Spam']}.
\end{methoddesc}
-\begin{methoddesc}{getparam}{name}
+\begin{methoddesc}[Message]{getparam}{name}
Return the \var{value} of the first parameter (as returned by
\method{getplist()}) of the form \samp{\var{name}=\var{value}} for the
given \var{name}. If \var{value} is surrounded by quotes of the form
`\code{<}...\code{>}' or `\code{"}...\code{"}', these are removed.
\end{methoddesc}
-\begin{methoddesc}{getencoding}{}
+\begin{methoddesc}[Message]{getencoding}{}
Return the encoding specified in the
\mailheader{Content-Transfer-Encoding} message header. If no such
header exists, return \code{'7bit'}. The encoding is converted to
lower case.
\end{methoddesc}
-\begin{methoddesc}{gettype}{}
+\begin{methoddesc}[Message]{gettype}{}
Return the message type (of the form \samp{\var{type}/\var{subtype}})
as specified in the \mailheader{Content-Type} header. If no such
header exists, return \code{'text/plain'}. The type is converted to
lower case.
\end{methoddesc}
-\begin{methoddesc}{getmaintype}{}
+\begin{methoddesc}[Message]{getmaintype}{}
Return the main type as specified in the \mailheader{Content-Type}
header. If no such header exists, return \code{'text'}. The main
type is converted to lower case.
\end{methoddesc}
-\begin{methoddesc}{getsubtype}{}
+\begin{methoddesc}[Message]{getsubtype}{}
Return the subtype as specified in the \mailheader{Content-Type}
header. If no such header exists, return \code{'plain'}. The subtype
is converted to lower case.
diff --git a/Doc/lib/libmimetypes.tex b/Doc/lib/libmimetypes.tex
index 6c46d6f..af99f08 100644
--- a/Doc/lib/libmimetypes.tex
+++ b/Doc/lib/libmimetypes.tex
@@ -178,49 +178,49 @@ An example usage of the module:
\class{MimeTypes} instances provide an interface which is very like
that of the \refmodule{mimetypes} module.
-\begin{datadesc}{suffix_map}
+\begin{memberdesc}[MimeTypes]{suffix_map}
Dictionary mapping suffixes to suffixes. This is used to allow
recognition of encoded files for which the encoding and the type are
indicated by the same extension. For example, the \file{.tgz}
extension is mapped to \file{.tar.gz} to allow the encoding and type
to be recognized separately. This is initially a copy of the global
\code{suffix_map} defined in the module.
-\end{datadesc}
+\end{memberdesc}
-\begin{datadesc}{encodings_map}
+\begin{memberdesc}[MimeTypes]{encodings_map}
Dictionary mapping filename extensions to encoding types. This is
initially a copy of the global \code{encodings_map} defined in the
module.
-\end{datadesc}
+\end{memberdesc}
-\begin{datadesc}{types_map}
+\begin{memberdesc}[MimeTypes]{types_map}
Dictionary mapping filename extensions to MIME types. This is
initially a copy of the global \code{types_map} defined in the
module.
-\end{datadesc}
+\end{memberdesc}
-\begin{datadesc}{common_types}
+\begin{memberdesc}[MimeTypes]{common_types}
Dictionary mapping filename extensions to non-standard, but commonly
found MIME types. This is initially a copy of the global
\code{common_types} defined in the module.
-\end{datadesc}
+\end{memberdesc}
-\begin{methoddesc}{guess_extension}{type\optional{, strict}}
+\begin{methoddesc}[MimeTypes]{guess_extension}{type\optional{, strict}}
Similar to the \function{guess_extension()} function, using the
tables stored as part of the object.
\end{methoddesc}
-\begin{methoddesc}{guess_type}{url\optional{, strict}}
+\begin{methoddesc}[MimeTypes]{guess_type}{url\optional{, strict}}
Similar to the \function{guess_type()} function, using the tables
stored as part of the object.
\end{methoddesc}
-\begin{methoddesc}{read}{path}
+\begin{methoddesc}[MimeTypes]{read}{path}
Load MIME information from a file named \var{path}. This uses
\method{readfp()} to parse the file.
\end{methoddesc}
-\begin{methoddesc}{readfp}{file}
+\begin{methoddesc}[MimeTypes]{readfp}{file}
Load MIME type information from an open file. The file must have
the format of the standard \file{mime.types} files.
\end{methoddesc}
diff --git a/Doc/lib/libmimewriter.tex b/Doc/lib/libmimewriter.tex
index a9cc09f..74bd9bb 100644
--- a/Doc/lib/libmimewriter.tex
+++ b/Doc/lib/libmimewriter.tex
@@ -31,7 +31,7 @@ writing. Note that a \class{StringIO} object could also be used.
\class{MimeWriter} instances have the following methods:
-\begin{methoddesc}{addheader}{key, value\optional{, prefix}}
+\begin{methoddesc}[MimeWriter]{addheader}{key, value\optional{, prefix}}
Add a header line to the MIME message. The \var{key} is the name of
the header, where the \var{value} obviously provides the value of the
header. The optional argument \var{prefix} determines where the header
@@ -39,14 +39,14 @@ is inserted; \samp{0} means append at the end, \samp{1} is insert at
the start. The default is to append.
\end{methoddesc}
-\begin{methoddesc}{flushheaders}{}
+\begin{methoddesc}[MimeWriter]{flushheaders}{}
Causes all headers accumulated so far to be written out (and
forgotten). This is useful if you don't need a body part at all,
e.g.\ for a subpart of type \mimetype{message/rfc822} that's (mis)used
to store some header-like information.
\end{methoddesc}
-\begin{methoddesc}{startbody}{ctype\optional{, plist\optional{, prefix}}}
+\begin{methoddesc}[MimeWriter]{startbody}{ctype\optional{, plist\optional{, prefix}}}
Returns a file-like object which can be used to write to the
body of the message. The content-type is set to the provided
\var{ctype}, and the optional parameter \var{plist} provides
@@ -55,8 +55,8 @@ functions as in \method{addheader()} except that the default is to
insert at the start.
\end{methoddesc}
-\begin{methoddesc}{startmultipartbody}{subtype\optional{,
- boundary\optional{, plist\optional{, prefix}}}}
+\begin{methoddesc}[MimeWriter]{startmultipartbody}{subtype\optional{,
+ boundary\optional{, plist\optional{, prefix}}}}
Returns a file-like object which can be used to write to the
body of the message. Additionally, this method initializes the
multi-part code, where \var{subtype} provides the multipart subtype,
@@ -66,7 +66,7 @@ multi-part code, where \var{subtype} provides the multipart subtype,
created using \method{nextpart()}.
\end{methoddesc}
-\begin{methoddesc}{nextpart}{}
+\begin{methoddesc}[MimeWriter]{nextpart}{}
Returns a new instance of \class{MimeWriter} which represents an
individual part in a multipart message. This may be used to write the
part as well as used for creating recursively complex multipart
@@ -74,7 +74,7 @@ messages. The message must first be initialized with
\method{startmultipartbody()} before using \method{nextpart()}.
\end{methoddesc}
-\begin{methoddesc}{lastpart}{}
+\begin{methoddesc}[MimeWriter]{lastpart}{}
This is used to designate the last part of a multipart message, and
should \emph{always} be used when writing multipart messages.
\end{methoddesc}
diff --git a/Doc/lib/libmmap.tex b/Doc/lib/libmmap.tex
index 3763d4f..345aeea 100644
--- a/Doc/lib/libmmap.tex
+++ b/Doc/lib/libmmap.tex
@@ -89,18 +89,18 @@ the underlying file. \versionchanged[To map anonymous memory,
Memory-mapped file objects support the following methods:
-\begin{methoddesc}{close}{}
+\begin{methoddesc}[mmap]{close}{}
Close the file. Subsequent calls to other methods of the object
will result in an exception being raised.
\end{methoddesc}
-\begin{methoddesc}{find}{string\optional{, start}}
+\begin{methoddesc}[mmap]{find}{string\optional{, start}}
Returns the lowest index in the object where the substring
\var{string} is found. Returns \code{-1} on failure. \var{start}
is the index at which the search begins, and defaults to zero.
\end{methoddesc}
-\begin{methoddesc}{flush}{\optional{offset, size}}
+\begin{methoddesc}[mmap]{flush}{\optional{offset, size}}
Flushes changes made to the in-memory copy of a file back to disk.
Without use of this call there is no guarantee that changes are
written back before the object is destroyed. If \var{offset} and
@@ -109,36 +109,36 @@ Memory-mapped file objects support the following methods:
is flushed.
\end{methoddesc}
-\begin{methoddesc}{move}{\var{dest}, \var{src}, \var{count}}
+\begin{methoddesc}[mmap]{move}{\var{dest}, \var{src}, \var{count}}
Copy the \var{count} bytes starting at offset \var{src} to the
destination index \var{dest}. If the mmap was created with
\constant{ACCESS_READ}, then calls to move will throw a
\exception{TypeError} exception.
\end{methoddesc}
-\begin{methoddesc}{read}{\var{num}}
+\begin{methoddesc}[mmap]{read}{\var{num}}
Return a string containing up to \var{num} bytes starting from the
current file position; the file position is updated to point after the
bytes that were returned.
\end{methoddesc}
-\begin{methoddesc}{read_byte}{}
+\begin{methoddesc}[mmap]{read_byte}{}
Returns a string of length 1 containing the character at the current
file position, and advances the file position by 1.
\end{methoddesc}
-\begin{methoddesc}{readline}{}
+\begin{methoddesc}[mmap]{readline}{}
Returns a single line, starting at the current file position and up to
the next newline.
\end{methoddesc}
-\begin{methoddesc}{resize}{\var{newsize}}
+\begin{methoddesc}[mmap]{resize}{\var{newsize}}
Resizes the map and the underlying file, if any.
If the mmap was created with \constant{ACCESS_READ} or
\constant{ACCESS_COPY}, resizing the map will throw a \exception{TypeError} exception.
\end{methoddesc}
-\begin{methoddesc}{seek}{pos\optional{, whence}}
+\begin{methoddesc}[mmap]{seek}{pos\optional{, whence}}
Set the file's current position. \var{whence} argument is optional
and defaults to \code{os.SEEK_SET} or \code{0} (absolute file
positioning); other values are \code{os.SEEK_CUR} or \code{1} (seek
@@ -146,16 +146,16 @@ Memory-mapped file objects support the following methods:
(seek relative to the file's end).
\end{methoddesc}
-\begin{methoddesc}{size}{}
+\begin{methoddesc}[mmap]{size}{}
Return the length of the file, which can be larger than the size of
the memory-mapped area.
\end{methoddesc}
-\begin{methoddesc}{tell}{}
+\begin{methoddesc}[mmap]{tell}{}
Returns the current position of the file pointer.
\end{methoddesc}
-\begin{methoddesc}{write}{\var{string}}
+\begin{methoddesc}[mmap]{write}{\var{string}}
Write the bytes in \var{string} into memory at the current position
of the file pointer; the file position is updated to point after the
bytes that were written. If the mmap was created with
@@ -163,7 +163,7 @@ Memory-mapped file objects support the following methods:
\exception{TypeError} exception.
\end{methoddesc}
-\begin{methoddesc}{write_byte}{\var{byte}}
+\begin{methoddesc}[mmap]{write_byte}{\var{byte}}
Write the single-character string \var{byte} into memory at the
current position of the file pointer; the file position is advanced
by \code{1}. If the mmap was created with \constant{ACCESS_READ},
diff --git a/Doc/lib/libmsilib.tex b/Doc/lib/libmsilib.tex
index 13d5556..075103a 100644
--- a/Doc/lib/libmsilib.tex
+++ b/Doc/lib/libmsilib.tex
@@ -121,17 +121,17 @@ MSI routines, and standard table structures.
\subsection{Database Objects\label{database-objects}}
-\begin{methoddesc}{OpenView}{sql}
+\begin{methoddesc}[Database]{OpenView}{sql}
Return a view object, by calling \cfunction{MSIDatabaseOpenView}.
\var{sql} is the SQL statement to execute.
\end{methoddesc}
-\begin{methoddesc}{Commit}{}
+\begin{methoddesc}[Database]{Commit}{}
Commit the changes pending in the current transaction,
by calling \cfunction{MSIDatabaseCommit}.
\end{methoddesc}
-\begin{methoddesc}{GetSummaryInformation}{count}
+\begin{methoddesc}[Database]{GetSummaryInformation}{count}
Return a new summary information object, by calling
\cfunction{MsiGetSummaryInformation}. \var{count} is the maximum number of
updated values.
@@ -145,24 +145,24 @@ MSI routines, and standard table structures.
\subsection{View Objects\label{view-objects}}
-\begin{methoddesc}{Execute}{\optional{params=None}}
+\begin{methoddesc}[View]{Execute}{\optional{params=None}}
Execute the SQL query of the view, through \cfunction{MSIViewExecute}.
\var{params} is an optional record describing actual values
of the parameter tokens in the query.
\end{methoddesc}
-\begin{methoddesc}{GetColumnInfo}{kind}
+\begin{methoddesc}[View]{GetColumnInfo}{kind}
Return a record describing the columns of the view, through
calling \cfunction{MsiViewGetColumnInfo}. \var{kind} can be either
\code{MSICOLINFO_NAMES} or \code{MSICOLINFO_TYPES}.
\end{methoddesc}
-\begin{methoddesc}{Fetch}{}
+\begin{methoddesc}[View]{Fetch}{}
Return a result record of the query, through calling
\cfunction{MsiViewFetch}.
\end{methoddesc}
-\begin{methoddesc}{Modify}{kind, data}
+\begin{methoddesc}[View]{Modify}{kind, data}
Modify the view, by calling \cfunction{MsiViewModify}. \var{kind}
can be one of \code{MSIMODIFY_SEEK}, \code{MSIMODIFY_REFRESH},
\code{MSIMODIFY_INSERT}, \code{MSIMODIFY_UPDATE}, \code{MSIMODIFY_ASSIGN},
@@ -174,7 +174,7 @@ MSI routines, and standard table structures.
\var{data} must be a record describing the new data.
\end{methoddesc}
-\begin{methoddesc}{Close}{}
+\begin{methoddesc}[View]{Close}{}
Close the view, through \cfunction{MsiViewClose}.
\end{methoddesc}
@@ -188,7 +188,7 @@ MSI routines, and standard table structures.
\subsection{Summary Information Objects\label{summary-objects}}
-\begin{methoddesc}{GetProperty}{field}
+\begin{methoddesc}[SummaryInformation]{GetProperty}{field}
Return a property of the summary, through \cfunction{MsiSummaryInfoGetProperty}.
\var{field} is the name of the property, and can be one of the
constants
@@ -200,19 +200,19 @@ MSI routines, and standard table structures.
\code{PID_APPNAME}, or \code{PID_SECURITY}.
\end{methoddesc}
-\begin{methoddesc}{GetPropertyCount}{}
+\begin{methoddesc}[SummaryInformation]{GetPropertyCount}{}
Return the number of summary properties, through
\cfunction{MsiSummaryInfoGetPropertyCount}.
\end{methoddesc}
-\begin{methoddesc}{SetProperty}{field, value}
+\begin{methoddesc}[SummaryInformation]{SetProperty}{field, value}
Set a property through \cfunction{MsiSummaryInfoSetProperty}. \var{field}
can have the same values as in \method{GetProperty}, \var{value}
is the new value of the property. Possible value types are integer
and string.
\end{methoddesc}
-\begin{methoddesc}{Persist}{}
+\begin{methoddesc}[SummaryInformation]{Persist}{}
Write the modified properties to the summary information stream,
using \cfunction{MsiSummaryInfoPersist}.
\end{methoddesc}
@@ -226,27 +226,27 @@ MSI routines, and standard table structures.
\subsection{Record Objects\label{record-objects}}
-\begin{methoddesc}{GetFieldCount}{}
+\begin{methoddesc}[Record]{GetFieldCount}{}
Return the number of fields of the record, through \cfunction{MsiRecordGetFieldCount}.
\end{methoddesc}
-\begin{methoddesc}{SetString}{field, value}
+\begin{methoddesc}[Record]{SetString}{field, value}
Set \var{field} to \var{value} through \cfunction{MsiRecordSetString}.
\var{field} must be an integer; \var{value} a string.
\end{methoddesc}
-\begin{methoddesc}{SetStream}{field, value}
+\begin{methoddesc}[Record]{SetStream}{field, value}
Set \var{field} to the contents of the file named \var{value},
through \cfunction{MsiRecordSetStream}.
\var{field} must be an integer; \var{value} a string.
\end{methoddesc}
-\begin{methoddesc}{SetInteger}{field, value}
+\begin{methoddesc}[Record]{SetInteger}{field, value}
Set \var{field} to \var{value} through \cfunction{MsiRecordSetInteger}.
Both \var{field} and \var{value} must be an integer.
\end{methoddesc}
-\begin{methoddesc}{ClearData}{}
+\begin{methoddesc}[Record]{ClearData}{}
Set all fields of the record to 0, through \cfunction{MsiRecordClearData}.
\end{methoddesc}
@@ -274,7 +274,7 @@ the string inside the exception will contain more detail.
\var{name} is the name of the CAB file in the MSI file.
\end{classdesc}
-\begin{methoddesc}[CAB]{append}{full, logical}
+\begin{methoddesc}[CAB]{append}{full, file, logical}
Add the file with the pathname \var{full} to the CAB file,
under the name \var{logical}. If there is already a file
named \var{logical}, a new file name is created.
@@ -283,7 +283,7 @@ the string inside the exception will contain more detail.
new name of the file inside the CAB file.
\end{methoddesc}
-\begin{methoddesc}[CAB]{append}{database}
+\begin{methoddesc}[CAB]{commit}{database}
Generate a CAB file, add it as a stream to the MSI file,
put it into the \code{Media} table, and remove the generated
file from the disk.
diff --git a/Doc/lib/libmultifile.tex b/Doc/lib/libmultifile.tex
index 4348327..f3f0af7 100644
--- a/Doc/lib/libmultifile.tex
+++ b/Doc/lib/libmultifile.tex
@@ -48,7 +48,7 @@ own pattern for section-divider and end-marker lines.
A \class{MultiFile} instance has the following methods:
-\begin{methoddesc}{readline}{str}
+\begin{methoddesc}[MultiFile]{readline}{str}
Read a line. If the line is data (not a section-divider or end-marker
or real EOF) return it. If the line matches the most-recently-stacked
boundary, return \code{''} and set \code{self.last} to 1 or 0 according as
@@ -58,33 +58,33 @@ underlying stream object, the method raises \exception{Error} unless
all boundaries have been popped.
\end{methoddesc}
-\begin{methoddesc}{readlines}{str}
+\begin{methoddesc}[MultiFile]{readlines}{str}
Return all lines remaining in this part as a list of strings.
\end{methoddesc}
-\begin{methoddesc}{read}{}
+\begin{methoddesc}[MultiFile]{read}{}
Read all lines, up to the next section. Return them as a single
(multiline) string. Note that this doesn't take a size argument!
\end{methoddesc}
-\begin{methoddesc}{seek}{pos\optional{, whence}}
+\begin{methoddesc}[MultiFile]{seek}{pos\optional{, whence}}
Seek. Seek indices are relative to the start of the current section.
The \var{pos} and \var{whence} arguments are interpreted as for a file
seek.
\end{methoddesc}
-\begin{methoddesc}{tell}{}
+\begin{methoddesc}[MultiFile]{tell}{}
Return the file position relative to the start of the current section.
\end{methoddesc}
-\begin{methoddesc}{next}{}
+\begin{methoddesc}[MultiFile]{next}{}
Skip lines to the next section (that is, read lines until a
section-divider or end-marker has been consumed). Return true if
there is such a section, false if an end-marker is seen. Re-enable
the most-recently-pushed boundary.
\end{methoddesc}
-\begin{methoddesc}{is_data}{str}
+\begin{methoddesc}[MultiFile]{is_data}{str}
Return true if \var{str} is data and false if it might be a section
boundary. As written, it tests for a prefix other than \code{'-}\code{-'} at
start of line (which all MIME boundaries have) but it is declared so
@@ -95,7 +95,7 @@ boundary tests; if it always returns false it will merely slow
processing, not cause it to fail.
\end{methoddesc}
-\begin{methoddesc}{push}{str}
+\begin{methoddesc}[MultiFile]{push}{str}
Push a boundary string. When a decorated version of this boundary
is found as an input line, it will be interpreted as a section-divider
or end-marker (depending on the decoration, see \rfc{2045}). All subsequent
@@ -108,12 +108,12 @@ most-recently-pushed boundary will return EOF; encountering any other
boundary will raise an error.
\end{methoddesc}
-\begin{methoddesc}{pop}{}
+\begin{methoddesc}[MultiFile]{pop}{}
Pop a section boundary. This boundary will no longer be interpreted
as EOF.
\end{methoddesc}
-\begin{methoddesc}{section_divider}{str}
+\begin{methoddesc}[MultiFile]{section_divider}{str}
Turn a boundary into a section-divider line. By default, this
method prepends \code{'-}\code{-'} (which MIME section boundaries have) but
it is declared so it can be overridden in derived classes. This
@@ -121,7 +121,7 @@ method need not append LF or CR-LF, as comparison with the result
ignores trailing whitespace.
\end{methoddesc}
-\begin{methoddesc}{end_marker}{str}
+\begin{methoddesc}[MultiFile]{end_marker}{str}
Turn a boundary string into an end-marker line. By default, this
method prepends \code{'-}\code{-'} and appends \code{'-}\code{-'} (like a
MIME-multipart end-of-message marker) but it is declared so it can be
@@ -131,11 +131,11 @@ CR-LF, as comparison with the result ignores trailing whitespace.
Finally, \class{MultiFile} instances have two public instance variables:
-\begin{memberdesc}{level}
+\begin{memberdesc}[MultiFile]{level}
Nesting depth of the current part.
\end{memberdesc}
-\begin{memberdesc}{last}
+\begin{memberdesc}[MultiFile]{last}
True if the last end-of-file was for an end-of-message marker.
\end{memberdesc}
diff --git a/Doc/lib/libmutex.tex b/Doc/lib/libmutex.tex
index 4893690..8c35c96 100644
--- a/Doc/lib/libmutex.tex
+++ b/Doc/lib/libmutex.tex
@@ -35,23 +35,23 @@ acquired.
\class{mutex} objects have following methods:
-\begin{methoddesc}{test}{}
+\begin{methoddesc}[mutex]{test}{}
Check whether the mutex is locked.
\end{methoddesc}
-\begin{methoddesc}{testandset}{}
+\begin{methoddesc}[mutex]{testandset}{}
``Atomic'' test-and-set, grab the lock if it is not set,
and return \code{True}, otherwise, return \code{False}.
\end{methoddesc}
-\begin{methoddesc}{lock}{function, argument}
+\begin{methoddesc}[mutex]{lock}{function, argument}
Execute \code{\var{function}(\var{argument})}, unless the mutex is locked.
In the case it is locked, place the function and argument on the queue.
See \method{unlock} for explanation of when
\code{\var{function}(\var{argument})} is executed in that case.
\end{methoddesc}
-\begin{methoddesc}{unlock}{}
+\begin{methoddesc}[mutex]{unlock}{}
Unlock the mutex if queue is empty, otherwise execute the first element
in the queue.
\end{methoddesc}
diff --git a/Doc/lib/libnetrc.tex b/Doc/lib/libnetrc.tex
index f2a0c1c..f867b34 100644
--- a/Doc/lib/libnetrc.tex
+++ b/Doc/lib/libnetrc.tex
@@ -35,7 +35,7 @@ of the error, \member{filename} is the name of the source file, and
A \class{netrc} instance has the following methods:
-\begin{methoddesc}{authenticators}{host}
+\begin{methoddesc}[netrc]{authenticators}{host}
Return a 3-tuple \code{(\var{login}, \var{account}, \var{password})}
of authenticators for \var{host}. If the netrc file did not
contain an entry for the given host, return the tuple associated with
@@ -43,20 +43,20 @@ the `default' entry. If neither matching host nor default entry is
available, return \code{None}.
\end{methoddesc}
-\begin{methoddesc}{__repr__}{}
+\begin{methoddesc}[netrc]{__repr__}{}
Dump the class data as a string in the format of a netrc file.
(This discards comments and may reorder the entries.)
\end{methoddesc}
Instances of \class{netrc} have public instance variables:
-\begin{memberdesc}{hosts}
+\begin{memberdesc}[netrc]{hosts}
Dictionary mapping host names to \code{(\var{login}, \var{account},
\var{password})} tuples. The `default' entry, if any, is represented
as a pseudo-host by that name.
\end{memberdesc}
-\begin{memberdesc}{macros}
+\begin{memberdesc}[netrc]{macros}
Dictionary mapping macro names to string lists.
\end{memberdesc}
diff --git a/Doc/lib/libnntplib.tex b/Doc/lib/libnntplib.tex
index 10330ed..22236f4 100644
--- a/Doc/lib/libnntplib.tex
+++ b/Doc/lib/libnntplib.tex
@@ -121,13 +121,13 @@ If the server's response indicates an error, the method raises one of
the above exceptions.
-\begin{methoddesc}{getwelcome}{}
+\begin{methoddesc}[NNTP]{getwelcome}{}
Return the welcome message sent by the server in reply to the initial
connection. (This message sometimes contains disclaimers or help
information that may be relevant to the user.)
\end{methoddesc}
-\begin{methoddesc}{set_debuglevel}{level}
+\begin{methoddesc}[NNTP]{set_debuglevel}{level}
Set the instance's debugging level. This controls the amount of
debugging output printed. The default, \code{0}, produces no debugging
output. A value of \code{1} produces a moderate amount of debugging
@@ -137,7 +137,7 @@ logging each line sent and received on the connection (including
message text).
\end{methoddesc}
-\begin{methoddesc}{newgroups}{date, time, \optional{file}}
+\begin{methoddesc}[NNTP]{newgroups}{date, time, \optional{file}}
Send a \samp{NEWGROUPS} command. The \var{date} argument should be a
string of the form \code{'\var{yy}\var{mm}\var{dd}'} indicating the
date, and \var{time} should be a string of the form
@@ -152,7 +152,7 @@ calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
\end{methoddesc}
-\begin{methoddesc}{newnews}{group, date, time, \optional{file}}
+\begin{methoddesc}[NNTP]{newnews}{group, date, time, \optional{file}}
Send a \samp{NEWNEWS} command. Here, \var{group} is a group name or
\code{'*'}, and \var{date} and \var{time} have the same meaning as for
\method{newgroups()}. Return a pair \code{(\var{response},
@@ -165,7 +165,7 @@ calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
\end{methoddesc}
-\begin{methoddesc}{list}{\optional{file}}
+\begin{methoddesc}[NNTP]{list}{\optional{file}}
Send a \samp{LIST} command. Return a pair \code{(\var{response},
\var{list})} where \var{list} is a list of tuples. Each tuple has the
form \code{(\var{group}, \var{last}, \var{first}, \var{flag})}, where
@@ -182,7 +182,7 @@ calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
\end{methoddesc}
-\begin{methoddesc}{descriptions}{grouppattern}
+\begin{methoddesc}[NNTP]{descriptions}{grouppattern}
Send a \samp{LIST NEWSGROUPS} command, where \var{grouppattern} is a wildmat
string as specified in RFC2980 (it's essentially the same as DOS or UNIX
shell wildcard strings). Return a pair \code{(\var{response},
@@ -192,7 +192,7 @@ shell wildcard strings). Return a pair \code{(\var{response},
\versionadded{2.4}
\end{methoddesc}
-\begin{methoddesc}{description}{group}
+\begin{methoddesc}[NNTP]{description}{group}
Get a description for a single group \var{group}. If more than one group
matches (if 'group' is a real wildmat string), return the first match.
If no group matches, return an empty string.
@@ -203,7 +203,7 @@ needed, use \method{descriptions()}.
\versionadded{2.4}
\end{methoddesc}
-\begin{methoddesc}{group}{name}
+\begin{methoddesc}[NNTP]{group}{name}
Send a \samp{GROUP} command, where \var{name} is the group name.
Return a tuple \code{(\var{response}, \var{count}, \var{first},
\var{last}, \var{name})} where \var{count} is the (estimated) number
@@ -212,7 +212,7 @@ the group, \var{last} is the last article number in the group, and
\var{name} is the group name. The numbers are returned as strings.
\end{methoddesc}
-\begin{methoddesc}{help}{\optional{file}}
+\begin{methoddesc}[NNTP]{help}{\optional{file}}
Send a \samp{HELP} command. Return a pair \code{(\var{response},
\var{list})} where \var{list} is a list of help strings.
If the \var{file} parameter is supplied, then the output of the
@@ -223,7 +223,7 @@ calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
\end{methoddesc}
-\begin{methoddesc}{stat}{id}
+\begin{methoddesc}[NNTP]{stat}{id}
Send a \samp{STAT} command, where \var{id} is the message id (enclosed
in \character{<} and \character{>}) or an article number (as a string).
Return a triple \code{(\var{response}, \var{number}, \var{id})} where
@@ -231,15 +231,15 @@ Return a triple \code{(\var{response}, \var{number}, \var{id})} where
message id (enclosed in \character{<} and \character{>}).
\end{methoddesc}
-\begin{methoddesc}{next}{}
+\begin{methoddesc}[NNTP]{next}{}
Send a \samp{NEXT} command. Return as for \method{stat()}.
\end{methoddesc}
-\begin{methoddesc}{last}{}
+\begin{methoddesc}[NNTP]{last}{}
Send a \samp{LAST} command. Return as for \method{stat()}.
\end{methoddesc}
-\begin{methoddesc}{head}{id}
+\begin{methoddesc}[NNTP]{head}{id}
Send a \samp{HEAD} command, where \var{id} has the same meaning as for
\method{stat()}. Return a tuple
\code{(\var{response}, \var{number}, \var{id}, \var{list})}
@@ -248,7 +248,7 @@ and \var{list} is a list of the article's headers (an uninterpreted
list of lines, without trailing newlines).
\end{methoddesc}
-\begin{methoddesc}{body}{id,\optional{file}}
+\begin{methoddesc}[NNTP]{body}{id,\optional{file}}
Send a \samp{BODY} command, where \var{id} has the same meaning as for
\method{stat()}. If the \var{file} parameter is supplied, then
the body is stored in a file. If \var{file} is a string, then
@@ -259,16 +259,16 @@ Return as for \method{head()}. If \var{file} is supplied, then
the returned \var{list} is an empty list.
\end{methoddesc}
-\begin{methoddesc}{article}{id}
+\begin{methoddesc}[NNTP]{article}{id}
Send an \samp{ARTICLE} command, where \var{id} has the same meaning as
for \method{stat()}. Return as for \method{head()}.
\end{methoddesc}
-\begin{methoddesc}{slave}{}
+\begin{methoddesc}[NNTP]{slave}{}
Send a \samp{SLAVE} command. Return the server's \var{response}.
\end{methoddesc}
-\begin{methoddesc}{xhdr}{header, string, \optional{file}}
+\begin{methoddesc}[NNTP]{xhdr}{header, string, \optional{file}}
Send an \samp{XHDR} command. This command is not defined in the RFC
but is a common extension. The \var{header} argument is a header
keyword, e.g. \code{'subject'}. The \var{string} argument should have
@@ -286,7 +286,7 @@ calling \method{write()} on it to store the lines of the command output.
If \var{file} is supplied, then the returned \var{list} is an empty list.
\end{methoddesc}
-\begin{methoddesc}{post}{file}
+\begin{methoddesc}[NNTP]{post}{file}
Post an article using the \samp{POST} command. The \var{file}
argument is an open file object which is read until EOF using its
\method{readline()} method. It should be a well-formed news article,
@@ -294,14 +294,14 @@ including the required headers. The \method{post()} method
automatically escapes lines beginning with \samp{.}.
\end{methoddesc}
-\begin{methoddesc}{ihave}{id, file}
+\begin{methoddesc}[NNTP]{ihave}{id, file}
Send an \samp{IHAVE} command. \var{id} is a message id (enclosed in
\character{<} and \character{>}).
If the response is not an error, treat
\var{file} exactly as for the \method{post()} method.
\end{methoddesc}
-\begin{methoddesc}{date}{}
+\begin{methoddesc}[NNTP]{date}{}
Return a triple \code{(\var{response}, \var{date}, \var{time})},
containing the current date and time in a form suitable for the
\method{newnews()} and \method{newgroups()} methods.
@@ -309,7 +309,7 @@ This is an optional NNTP extension, and may not be supported by all
servers.
\end{methoddesc}
-\begin{methoddesc}{xgtitle}{name, \optional{file}}
+\begin{methoddesc}[NNTP]{xgtitle}{name, \optional{file}}
Process an \samp{XGTITLE} command, returning a pair \code{(\var{response},
\var{list})}, where \var{list} is a list of tuples containing
\code{(\var{name}, \var{title})}.
@@ -327,7 +327,7 @@ RFC2980 says ``It is suggested that this extension be deprecated''. Use
\method{descriptions()} or \method{description()} instead.
\end{methoddesc}
-\begin{methoddesc}{xover}{start, end, \optional{file}}
+\begin{methoddesc}[NNTP]{xover}{start, end, \optional{file}}
Return a pair \code{(\var{resp}, \var{list})}. \var{list} is a list
of tuples, one for each article in the range delimited by the \var{start}
and \var{end} article numbers. Each tuple is of the form
@@ -343,13 +343,13 @@ This is an optional NNTP extension, and may not be supported by all
servers.
\end{methoddesc}
-\begin{methoddesc}{xpath}{id}
+\begin{methoddesc}[NNTP]{xpath}{id}
Return a pair \code{(\var{resp}, \var{path})}, where \var{path} is the
directory path to the article with message ID \var{id}. This is an
optional NNTP extension, and may not be supported by all servers.
\end{methoddesc}
-\begin{methoddesc}{quit}{}
+\begin{methoddesc}[NNTP]{quit}{}
Send a \samp{QUIT} command and close the connection. Once this method
has been called, no other methods of the NNTP object should be called.
\end{methoddesc}
diff --git a/Doc/lib/liboptparse.tex b/Doc/lib/liboptparse.tex
index df96dd4..dd618c8 100644
--- a/Doc/lib/liboptparse.tex
+++ b/Doc/lib/liboptparse.tex
@@ -518,7 +518,7 @@ program, i.e. \code{os.path.basename(sys.argv{[}0])}. The expanded string
is then printed before the detailed option help.
If you don't supply a usage string, \module{optparse} uses a bland but sensible
-default: ``\code{usage: {\%}prog {[}options]"}, which is fine if your script
+default: \code{"usage: {\%}prog {[}options]"}, which is fine if your script
doesn't take any positional arguments.
\item {}
diff --git a/Doc/lib/libos.tex b/Doc/lib/libos.tex
index cbb35f3..638ed6b 100644
--- a/Doc/lib/libos.tex
+++ b/Doc/lib/libos.tex
@@ -1233,7 +1233,8 @@ Availability: Macintosh, \UNIX, Windows.
\end{funcdesc}
\begin{funcdesc}{walk}{top\optional{, topdown\code{=True}
- \optional{, onerror\code{=None}}}}
+ \optional{, onerror\code{=None}\optional{,
+ followlinks\code{=False}}}}}
\index{directory!walking}
\index{directory!traversal}
\function{walk()} generates the file names in a directory tree, by
@@ -1273,6 +1274,18 @@ report the error to continue with the walk, or raise the exception
to abort the walk. Note that the filename is available as the
\code{filename} attribute of the exception object.
+By default, \function{walk()} will not walk down into symbolic links that
+resolve to directories. Set \var{followlinks} to True to visit directories
+pointed to by symlinks, on systems that support them.
+
+\versionadded[The \var{followlinks} parameter]{2.6}
+
+\begin{notice}
+Be aware that setting \var{followlinks} to true can lead to infinite recursion
+if a link points to a parent directory of itself. \function{walk()} does not
+keep track of the directories it visited already.
+\end{notice}
+
\begin{notice}
If you pass a relative pathname, don't change the current working
directory between resumptions of \function{walk()}. \function{walk()}
@@ -1280,15 +1293,6 @@ never changes the current directory, and assumes that its caller
doesn't either.
\end{notice}
-\begin{notice}
-On systems that support symbolic links, links to subdirectories appear
-in \var{dirnames} lists, but \function{walk()} will not visit them
-(infinite loops are hard to avoid when following symbolic links).
-To visit linked directories, you can identify them with
-\code{os.path.islink(\var{path})}, and invoke \code{walk(\var{path})}
-on each directly.
-\end{notice}
-
This example displays the number of bytes taken by non-directory files
in each directory under the starting directory, except that it doesn't
look under any CVS subdirectory:
diff --git a/Doc/lib/libpdb.tex b/Doc/lib/libpdb.tex
index 778a137..45e778c 100644
--- a/Doc/lib/libpdb.tex
+++ b/Doc/lib/libpdb.tex
@@ -378,6 +378,14 @@ command with a \samp{global} command on the same line, e.g.:
(Pdb)
\end{verbatim}
+\item[run \optional{\var{args} ...}]
+Restart the debugged python program. If an argument is supplied, it is
+splitted with "shlex" and the result is used as the new sys.argv.
+History, breakpoints, actions and debugger options are preserved.
+"restart" is an alias for "run".
+
+\versionadded{2.6}
+
\item[q(uit)]
Quit from the debugger.
diff --git a/Doc/lib/libpipes.tex b/Doc/lib/libpipes.tex
index 1815e09..de25fb5 100644
--- a/Doc/lib/libpipes.tex
+++ b/Doc/lib/libpipes.tex
@@ -39,21 +39,21 @@ Example:
Template objects following methods:
-\begin{methoddesc}{reset}{}
+\begin{methoddesc}[Template]{reset}{}
Restore a pipeline template to its initial state.
\end{methoddesc}
-\begin{methoddesc}{clone}{}
+\begin{methoddesc}[Template]{clone}{}
Return a new, equivalent, pipeline template.
\end{methoddesc}
-\begin{methoddesc}{debug}{flag}
+\begin{methoddesc}[Template]{debug}{flag}
If \var{flag} is true, turn debugging on. Otherwise, turn debugging
off. When debugging is on, commands to be executed are printed, and
the shell is given \code{set -x} command to be more verbose.
\end{methoddesc}
-\begin{methoddesc}{append}{cmd, kind}
+\begin{methoddesc}[Template]{append}{cmd, kind}
Append a new action at the end. The \var{cmd} variable must be a valid
bourne shell command. The \var{kind} variable consists of two letters.
@@ -68,17 +68,17 @@ command writes a file on the command line) or \code{'.'} (which means
the command does not write anything, and hence must be last.)
\end{methoddesc}
-\begin{methoddesc}{prepend}{cmd, kind}
+\begin{methoddesc}[Template]{prepend}{cmd, kind}
Add a new action at the beginning. See \method{append()} for explanations
of the arguments.
\end{methoddesc}
-\begin{methoddesc}{open}{file, mode}
+\begin{methoddesc}[Template]{open}{file, mode}
Return a file-like object, open to \var{file}, but read from or
written to by the pipeline. Note that only one of \code{'r'},
\code{'w'} may be given.
\end{methoddesc}
-\begin{methoddesc}{copy}{infile, outfile}
+\begin{methoddesc}[Template]{copy}{infile, outfile}
Copy \var{infile} to \var{outfile} through the pipe.
\end{methoddesc}
diff --git a/Doc/lib/libplatform.tex b/Doc/lib/libplatform.tex
index 810e08b..a2f1913 100644
--- a/Doc/lib/libplatform.tex
+++ b/Doc/lib/libplatform.tex
@@ -80,6 +80,22 @@
Returns a string identifying the compiler used for compiling Python.
\end{funcdesc}
+\begin{funcdesc}{python_branch}{}
+ Returns a string identifying the Python implementation SCM branch.
+ \versionadded{2.6}
+\end{funcdesc}
+
+\begin{funcdesc}{python_implementation}{}
+ Returns a string identifying the Python implementation.
+ Possible return values are: 'CPython', 'IronPython', 'Jython'
+ \versionadded{2.6}
+\end{funcdesc}
+
+\begin{funcdesc}{python_revision}{}
+ Returns a string identifying the Python implementation SCM revision.
+ \versionadded{2.6}
+\end{funcdesc}
+
\begin{funcdesc}{python_version}{}
Returns the Python version as string \code{'major.minor.patchlevel'}
@@ -205,6 +221,7 @@
which defaults to the args given as parameters.
\end{funcdesc}
+% Document linux_distribution()?
\begin{funcdesc}{libc_ver}{executable=sys.executable, lib='',
version='', chunksize=2048}
diff --git a/Doc/lib/libpopen2.tex b/Doc/lib/libpopen2.tex
index fa0c1a6..322a9b9 100644
--- a/Doc/lib/libpopen2.tex
+++ b/Doc/lib/libpopen2.tex
@@ -2,7 +2,6 @@
Subprocesses with accessible I/O streams}
\declaremodule{standard}{popen2}
- \platform{Unix, Windows}
\modulesynopsis{Subprocesses with accessible standard I/O streams.}
\sectionauthor{Drew Csillag}{drew_csillag@geocities.com}
@@ -85,12 +84,12 @@ using \function{popen4()}.
Instances of the \class{Popen3} and \class{Popen4} classes have the
following methods:
-\begin{methoddesc}{poll}{}
+\begin{methoddesc}[Popen3]{poll}{}
Returns \code{-1} if child process hasn't completed yet, or its return
code otherwise.
\end{methoddesc}
-\begin{methoddesc}{wait}{}
+\begin{methoddesc}[Popen3]{wait}{}
Waits for and returns the status code of the child process. The
status code encodes both the return code of the process and
information about whether it exited using the \cfunction{exit()}
@@ -102,24 +101,24 @@ status code are defined in the \refmodule{os} module; see section
The following attributes are also available:
-\begin{memberdesc}{fromchild}
+\begin{memberdesc}[Popen3]{fromchild}
A file object that provides output from the child process. For
\class{Popen4} instances, this will provide both the standard output
and standard error streams.
\end{memberdesc}
-\begin{memberdesc}{tochild}
+\begin{memberdesc}[Popen3]{tochild}
A file object that provides input to the child process.
\end{memberdesc}
-\begin{memberdesc}{childerr}
+\begin{memberdesc}[Popen3]{childerr}
A file object that provides error output from the child process, if
\var{capturestderr} was true for the constructor, otherwise
\code{None}. This will always be \code{None} for \class{Popen4}
instances.
\end{memberdesc}
-\begin{memberdesc}{pid}
+\begin{memberdesc}[Popen3]{pid}
The process ID of the child process.
\end{memberdesc}
diff --git a/Doc/lib/libpoplib.tex b/Doc/lib/libpoplib.tex
index 25570ae..7b2c4a1 100644
--- a/Doc/lib/libpoplib.tex
+++ b/Doc/lib/libpoplib.tex
@@ -23,15 +23,18 @@ servers that use SSL as an underlying protocol layer.
Note that POP3, though widely supported, is obsolescent. The
implementation quality of POP3 servers varies widely, and too many are
quite poor. If your mailserver supports IMAP, you would be better off
-using the \code{\refmodule{imaplib}.\class{IMAP4}} class, as IMAP
+using the \class{\refmodule{imaplib}.IMAP4} class, as IMAP
servers tend to be better implemented.
A single class is provided by the \module{poplib} module:
-\begin{classdesc}{POP3}{host\optional{, port}}
+\begin{classdesc}{POP3}{host\optional{, port\optional{, timeout}}}
This class implements the actual POP3 protocol. The connection is
created when the instance is initialized.
If \var{port} is omitted, the standard POP3 port (110) is used.
+The optional \var{timeout} parameter specifies a timeout in seconds for the
+connection attempt (if not specified, or passed as None, the global default
+timeout setting will be used).
\end{classdesc}
\begin{classdesc}{POP3_SSL}{host\optional{, port\optional{, keyfile\optional{, certfile}}}}
@@ -47,8 +50,9 @@ certificate chain file for the SSL connection.
One exception is defined as an attribute of the \module{poplib} module:
\begin{excdesc}{error_proto}
-Exception raised on any errors. The reason for the exception is
-passed to the constructor as a string.
+Exception raised on any errors from this module (errors from
+\module{socket} module are not caught). The reason for the exception
+is passed to the constructor as a string.
\end{excdesc}
\begin{seealso}
@@ -70,7 +74,7 @@ in lower-case; most return the response text sent by the server.
An \class{POP3} instance has the following methods:
-\begin{methoddesc}{set_debuglevel}{level}
+\begin{methoddesc}[POP3]{set_debuglevel}{level}
Set the instance's debugging level. This controls the amount of
debugging output printed. The default, \code{0}, produces no
debugging output. A value of \code{1} produces a moderate amount of
@@ -79,64 +83,64 @@ debugging output, generally a single line per request. A value of
logging each line sent and received on the control connection.
\end{methoddesc}
-\begin{methoddesc}{getwelcome}{}
+\begin{methoddesc}[POP3]{getwelcome}{}
Returns the greeting string sent by the POP3 server.
\end{methoddesc}
-\begin{methoddesc}{user}{username}
+\begin{methoddesc}[POP3]{user}{username}
Send user command, response should indicate that a password is required.
\end{methoddesc}
-\begin{methoddesc}{pass_}{password}
+\begin{methoddesc}[POP3]{pass_}{password}
Send password, response includes message count and mailbox size.
Note: the mailbox on the server is locked until \method{quit()} is
called.
\end{methoddesc}
-\begin{methoddesc}{apop}{user, secret}
+\begin{methoddesc}[POP3]{apop}{user, secret}
Use the more secure APOP authentication to log into the POP3 server.
\end{methoddesc}
-\begin{methoddesc}{rpop}{user}
+\begin{methoddesc}[POP3]{rpop}{user}
Use RPOP authentication (similar to UNIX r-commands) to log into POP3 server.
\end{methoddesc}
-\begin{methoddesc}{stat}{}
+\begin{methoddesc}[POP3]{stat}{}
Get mailbox status. The result is a tuple of 2 integers:
\code{(\var{message count}, \var{mailbox size})}.
\end{methoddesc}
-\begin{methoddesc}{list}{\optional{which}}
+\begin{methoddesc}[POP3]{list}{\optional{which}}
Request message list, result is in the form
\code{(\var{response}, ['mesg_num octets', ...], \var{octets})}.
If \var{which} is set, it is the message to list.
\end{methoddesc}
-\begin{methoddesc}{retr}{which}
+\begin{methoddesc}[POP3]{retr}{which}
Retrieve whole message number \var{which}, and set its seen flag.
Result is in form \code{(\var{response}, ['line', ...], \var{octets})}.
\end{methoddesc}
-\begin{methoddesc}{dele}{which}
+\begin{methoddesc}[POP3]{dele}{which}
Flag message number \var{which} for deletion. On most servers
deletions are not actually performed until QUIT (the major exception is
Eudora QPOP, which deliberately violates the RFCs by doing pending
deletes on any disconnect).
\end{methoddesc}
-\begin{methoddesc}{rset}{}
+\begin{methoddesc}[POP3]{rset}{}
Remove any deletion marks for the mailbox.
\end{methoddesc}
-\begin{methoddesc}{noop}{}
+\begin{methoddesc}[POP3]{noop}{}
Do nothing. Might be used as a keep-alive.
\end{methoddesc}
-\begin{methoddesc}{quit}{}
+\begin{methoddesc}[POP3]{quit}{}
Signoff: commit changes, unlock mailbox, drop connection.
\end{methoddesc}
-\begin{methoddesc}{top}{which, howmuch}
+\begin{methoddesc}[POP3]{top}{which, howmuch}
Retrieves the message header plus \var{howmuch} lines of the message
after the header of message number \var{which}. Result is in form
\code{(\var{response}, ['line', ...], \var{octets})}.
@@ -148,7 +152,7 @@ Test this method by hand against the POP3 servers you will use before
trusting it.
\end{methoddesc}
-\begin{methoddesc}{uidl}{\optional{which}}
+\begin{methoddesc}[POP3]{uidl}{\optional{which}}
Return message digest (unique id) list.
If \var{which} is specified, result contains the unique id for that
message in the form \code{'\var{response}\ \var{mesgnum}\ \var{uid}},
diff --git a/Doc/lib/libposixfile.tex b/Doc/lib/libposixfile.tex
index 62861f0..5c86f3e 100644
--- a/Doc/lib/libposixfile.tex
+++ b/Doc/lib/libposixfile.tex
@@ -62,8 +62,7 @@ The \module{posixfile} module defines the following functions:
The posixfile object defines the following additional methods:
-\setindexsubitem{(posixfile method)}
-\begin{funcdesc}{lock}{fmt, \optional{len\optional{, start\optional{, whence}}}}
+\begin{methoddesc}[posixfile]{lock}{fmt, \optional{len\optional{, start\optional{, whence}}}}
Lock the specified section of the file that the file object is
referring to. The format is explained
below in a table. The \var{len} argument specifies the length of the
@@ -74,9 +73,9 @@ The posixfile object defines the following additional methods:
\constant{SEEK_CUR} or \constant{SEEK_END}. The default is
\constant{SEEK_SET}. For more information about the arguments refer
to the \manpage{fcntl}{2} manual page on your system.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{flags}{\optional{flags}}
+\begin{methoddesc}[posixfile]{flags}{\optional{flags}}
Set the specified flags for the file that the file object is referring
to. The new flags are ORed with the old flags, unless specified
otherwise. The format is explained below in a table. Without
@@ -84,25 +83,25 @@ The posixfile object defines the following additional methods:
a string indicating the current flags is returned (this is
the same as the \samp{?} modifier). For more information about the
flags refer to the \manpage{fcntl}{2} manual page on your system.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{dup}{}
+\begin{methoddesc}[posixfile]{dup}{}
Duplicate the file object and the underlying file pointer and file
descriptor. The resulting object behaves as if it were newly
opened.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{dup2}{fd}
+\begin{methoddesc}[posixfile]{dup2}{fd}
Duplicate the file object and the underlying file pointer and file
descriptor. The new object will have the given file descriptor.
Otherwise the resulting object behaves as if it were newly opened.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{file}{}
+\begin{methoddesc}[posixfile]{file}{}
Return the standard file object that the posixfile object is based
on. This is sometimes necessary for functions that insist on a
standard file object.
-\end{funcdesc}
+\end{methoddesc}
All methods raise \exception{IOError} when the request fails.
diff --git a/Doc/lib/libposixpath.tex b/Doc/lib/libposixpath.tex
index 0b2da66..7684fa0 100644
--- a/Doc/lib/libposixpath.tex
+++ b/Doc/lib/libposixpath.tex
@@ -58,18 +58,20 @@ Equivalent to \function{exists()} on platforms lacking
\end{funcdesc}
\begin{funcdesc}{expanduser}{path}
-On \UNIX, return the argument with an initial component of \samp{\~} or
-\samp{\~\var{user}} replaced by that \var{user}'s home directory.
-An initial \samp{\~} is replaced by the environment variable
+On \UNIX{} and Windows, return the argument with an initial component of
+\samp{\~} or \samp{\~\var{user}} replaced by that \var{user}'s home directory.
+
+On \UNIX, an initial \samp{\~} is replaced by the environment variable
\envvar{HOME} if it is set; otherwise the current user's home directory
is looked up in the password directory through the built-in module
\refmodule{pwd}\refbimodindex{pwd}.
An initial \samp{\~\var{user}} is looked up directly in the
password directory.
-On Windows, only \samp{\~} is supported; it is replaced by the
-environment variable \envvar{HOME} or by a combination of
-\envvar{HOMEDRIVE} and \envvar{HOMEPATH}.
+On Windows, \envvar{HOME} and \envvar{USERPROFILE} will be used if set,
+otherwise a combination of \envvar{HOMEPATH} and \envvar{HOMEDRIVE} will be
+used. An initial \samp{\~\var{user}} is handled by stripping the last
+directory component from the created user path derived above.
If the expansion fails or if the
path does not begin with a tilde, the path is returned unchanged.
@@ -81,6 +83,9 @@ of the form \samp{\$\var{name}} or \samp{\$\{\var{name}\}} are
replaced by the value of environment variable \var{name}. Malformed
variable names and references to non-existing variables are left
unchanged.
+
+On Windows, \samp{\%\var{name}\%} expansions are supported in addition to
+\samp{\$\var{name}} and \samp{\$\{\var{name}\}}.
\end{funcdesc}
\begin{funcdesc}{getatime}{path}
@@ -184,6 +189,15 @@ operating system).
\versionadded{2.2}
\end{funcdesc}
+\begin{funcdesc}{relpath}{path\optional{, start}}
+Return a relative filepath to \var{path} either from the current
+directory or from an optional \var{start} point.
+
+\var{start} defaults to \member{os.curdir}.
+Availability: Windows, \UNIX.
+\versionadded{2.6}
+\end{funcdesc}
+
\begin{funcdesc}{samefile}{path1, path2}
Return \code{True} if both pathname arguments refer to the same file or
directory (as indicated by device number and i-node number).
@@ -234,7 +248,12 @@ empty string. On systems which do not use drive specifications,
Split the pathname \var{path} into a pair \code{(\var{root}, \var{ext})}
such that \code{\var{root} + \var{ext} == \var{path}},
and \var{ext} is empty or begins with a period and contains
-at most one period.
+at most one period. Leading periods on the basename are
+ignored; \code{\var{splitext}.('.cshrc')} returns
+\code{('.cshrc', '')}.
+
+\versionchanged[Earlier versions could produce an empty root when
+the only period was the first character]{2.6}
\end{funcdesc}
\begin{funcdesc}{splitunc}{path}
diff --git a/Doc/lib/libpprint.tex b/Doc/lib/libpprint.tex
index fd03038..9203b3a 100644
--- a/Doc/lib/libpprint.tex
+++ b/Doc/lib/libpprint.tex
@@ -158,12 +158,12 @@ l/lib/python1.5/test', '/usr/local/lib/python1.5/sunos5', '/usr/local/lib/python
\class{PrettyPrinter} instances have the following methods:
-\begin{methoddesc}{pformat}{object}
+\begin{methoddesc}[PrettyPrinter]{pformat}{object}
Return the formatted representation of \var{object}. This takes into
account the options passed to the \class{PrettyPrinter} constructor.
\end{methoddesc}
-\begin{methoddesc}{pprint}{object}
+\begin{methoddesc}[PrettyPrinter]{pprint}{object}
Print the formatted representation of \var{object} on the configured
stream, followed by a newline.
\end{methoddesc}
@@ -173,7 +173,7 @@ corresponding functions of the same names. Using these methods on an
instance is slightly more efficient since new \class{PrettyPrinter}
objects don't need to be created.
-\begin{methoddesc}{isreadable}{object}
+\begin{methoddesc}[PrettyPrinter]{isreadable}{object}
Determine if the formatted representation of the object is
``readable,'' or can be used to reconstruct the value using
\function{eval()}\bifuncindex{eval}. Note that this returns false for
@@ -182,7 +182,7 @@ recursive objects. If the \var{depth} parameter of the
this returns false.
\end{methoddesc}
-\begin{methoddesc}{isrecursive}{object}
+\begin{methoddesc}[PrettyPrinter]{isrecursive}{object}
Determine if the object requires a recursive representation.
\end{methoddesc}
@@ -190,7 +190,7 @@ This method is provided as a hook to allow subclasses to modify the
way objects are converted to strings. The default implementation uses
the internals of the \function{saferepr()} implementation.
-\begin{methoddesc}{format}{object, context, maxlevels, level}
+\begin{methoddesc}[PrettyPrinter]{format}{object, context, maxlevels, level}
Returns three values: the formatted version of \var{object} as a
string, a flag indicating whether the result is readable, and a flag
indicating whether recursion was detected. The first argument is the
diff --git a/Doc/lib/libqueue.tex b/Doc/lib/libqueue.tex
index 95ad47f..591a910 100644
--- a/Doc/lib/libqueue.tex
+++ b/Doc/lib/libqueue.tex
@@ -45,22 +45,22 @@ other queue organizations (e.g. stack) but the inheritable interface
is not described here. See the source code for details. The public
methods are:
-\begin{methoddesc}{qsize}{}
+\begin{methoddesc}[Queue]{qsize}{}
Return the approximate size of the queue. Because of multithreading
semantics, this number is not reliable.
\end{methoddesc}
-\begin{methoddesc}{empty}{}
+\begin{methoddesc}[Queue]{empty}{}
Return \code{True} if the queue is empty, \code{False} otherwise.
Because of multithreading semantics, this is not reliable.
\end{methoddesc}
-\begin{methoddesc}{full}{}
+\begin{methoddesc}[Queue]{full}{}
Return \code{True} if the queue is full, \code{False} otherwise.
Because of multithreading semantics, this is not reliable.
\end{methoddesc}
-\begin{methoddesc}{put}{item\optional{, block\optional{, timeout}}}
+\begin{methoddesc}[Queue]{put}{item\optional{, block\optional{, timeout}}}
Put \var{item} into the queue. If optional args \var{block} is true
and \var{timeout} is None (the default), block if necessary until a
free slot is available. If \var{timeout} is a positive number, it
@@ -74,11 +74,11 @@ exception (\var{timeout} is ignored in that case).
\end{methoddesc}
-\begin{methoddesc}{put_nowait}{item}
+\begin{methoddesc}[Queue]{put_nowait}{item}
Equivalent to \code{put(\var{item}, False)}.
\end{methoddesc}
-\begin{methoddesc}{get}{\optional{block\optional{, timeout}}}
+\begin{methoddesc}[Queue]{get}{\optional{block\optional{, timeout}}}
Remove and return an item from the queue. If optional args
\var{block} is true and \var{timeout} is None (the default),
block if necessary until an item is available. If \var{timeout} is
@@ -92,14 +92,14 @@ immediately available, else raise the \exception{Empty} exception
\end{methoddesc}
-\begin{methoddesc}{get_nowait}{}
+\begin{methoddesc}[Queue]{get_nowait}{}
Equivalent to \code{get(False)}.
\end{methoddesc}
Two methods are offered to support tracking whether enqueued tasks have
been fully processed by daemon consumer threads.
-\begin{methoddesc}{task_done}{}
+\begin{methoddesc}[Queue]{task_done}{}
Indicate that a formerly enqueued task is complete. Used by queue consumer
threads. For each \method{get()} used to fetch a task, a subsequent call to
\method{task_done()} tells the queue that the processing on the task is complete.
@@ -113,7 +113,7 @@ placed in the queue.
\versionadded{2.5}
\end{methoddesc}
-\begin{methoddesc}{join}{}
+\begin{methoddesc}[Queue]{join}{}
Blocks until all items in the queue have been gotten and processed.
The count of unfinished tasks goes up whenever an item is added to the
diff --git a/Doc/lib/libre.tex b/Doc/lib/libre.tex
index 84e382d..a0b8b51 100644
--- a/Doc/lib/libre.tex
+++ b/Doc/lib/libre.tex
@@ -812,7 +812,7 @@ used for groups that did not participate in the match; it defaults to
\end{methoddesc}
\begin{methoddesc}[MatchObject]{start}{\optional{group}}
-\methodline{end}{\optional{group}}
+\methodline[MatchObject]{end}{\optional{group}}
Return the indices of the start and end of the substring
matched by \var{group}; \var{group} defaults to zero (meaning the whole
matched substring).
diff --git a/Doc/lib/librepr.tex b/Doc/lib/librepr.tex
index 7905112..2876448 100644
--- a/Doc/lib/librepr.tex
+++ b/Doc/lib/librepr.tex
@@ -44,18 +44,18 @@ provide size limits for the representations of different object types,
and methods which format specific object types.
-\begin{memberdesc}{maxlevel}
+\begin{memberdesc}[Repr]{maxlevel}
Depth limit on the creation of recursive representations. The
default is \code{6}.
\end{memberdesc}
-\begin{memberdesc}{maxdict}
-\memberline{maxlist}
-\memberline{maxtuple}
-\memberline{maxset}
-\memberline{maxfrozenset}
-\memberline{maxdeque}
-\memberline{maxarray}
+\begin{memberdesc}[Repr]{maxdict}
+\memberline[Repr]{maxlist}
+\memberline[Repr]{maxtuple}
+\memberline[Repr]{maxset}
+\memberline[Repr]{maxfrozenset}
+\memberline[Repr]{maxdeque}
+\memberline[Repr]{maxarray}
Limits on the number of entries represented for the named object
type. The default is \code{4} for \member{maxdict}, \code{5} for
\member{maxarray}, and \code{6} for the others.
@@ -63,13 +63,13 @@ and methods which format specific object types.
and \member{set}]{2.4}.
\end{memberdesc}
-\begin{memberdesc}{maxlong}
+\begin{memberdesc}[Repr]{maxlong}
Maximum number of characters in the representation for a long
integer. Digits are dropped from the middle. The default is
\code{40}.
\end{memberdesc}
-\begin{memberdesc}{maxstring}
+\begin{memberdesc}[Repr]{maxstring}
Limit on the number of characters in the representation of the
string. Note that the ``normal'' representation of the string is
used as the character source: if escape sequences are needed in the
@@ -77,19 +77,19 @@ and methods which format specific object types.
shortened. The default is \code{30}.
\end{memberdesc}
-\begin{memberdesc}{maxother}
+\begin{memberdesc}[Repr]{maxother}
This limit is used to control the size of object types for which no
specific formatting method is available on the \class{Repr} object.
It is applied in a similar manner as \member{maxstring}. The
default is \code{20}.
\end{memberdesc}
-\begin{methoddesc}{repr}{obj}
+\begin{methoddesc}[Repr]{repr}{obj}
The equivalent to the built-in \function{repr()} that uses the
formatting imposed by the instance.
\end{methoddesc}
-\begin{methoddesc}{repr1}{obj, level}
+\begin{methoddesc}[Repr]{repr1}{obj, level}
Recursive implementation used by \method{repr()}. This uses the
type of \var{obj} to determine which formatting method to call,
passing it \var{obj} and \var{level}. The type-specific methods
@@ -98,7 +98,7 @@ and methods which format specific object types.
call.
\end{methoddesc}
-\begin{methoddescni}{repr_\var{type}}{obj, level}
+\begin{methoddescni}[Repr]{repr_\var{type}}{obj, level}
Formatting methods for specific types are implemented as methods
with a name based on the type name. In the method name, \var{type}
is replaced by
diff --git a/Doc/lib/librexec.tex b/Doc/lib/librexec.tex
index 3e54102..3104004 100644
--- a/Doc/lib/librexec.tex
+++ b/Doc/lib/librexec.tex
@@ -89,20 +89,20 @@ makes use of this and would break were it not available.
\class{RExec} instances support the following methods:
-\begin{methoddesc}{r_eval}{code}
+\begin{methoddesc}[RExec]{r_eval}{code}
\var{code} must either be a string containing a Python expression, or
a compiled code object, which will be evaluated in the restricted
environment's \module{__main__} module. The value of the expression or
code object will be returned.
\end{methoddesc}
-\begin{methoddesc}{r_exec}{code}
+\begin{methoddesc}[RExec]{r_exec}{code}
\var{code} must either be a string containing one or more lines of
Python code, or a compiled code object, which will be executed in the
restricted environment's \module{__main__} module.
\end{methoddesc}
-\begin{methoddesc}{r_execfile}{filename}
+\begin{methoddesc}[RExec]{r_execfile}{filename}
Execute the Python code contained in the file \var{filename} in the
restricted environment's \module{__main__} module.
\end{methoddesc}
@@ -112,17 +112,17 @@ beginning with \samp{r_}, but the code will be granted access to
restricted versions of the standard I/O streams \code{sys.stdin},
\code{sys.stderr}, and \code{sys.stdout}.
-\begin{methoddesc}{s_eval}{code}
+\begin{methoddesc}[RExec]{s_eval}{code}
\var{code} must be a string containing a Python expression, which will
be evaluated in the restricted environment.
\end{methoddesc}
-\begin{methoddesc}{s_exec}{code}
+\begin{methoddesc}[RExec]{s_exec}{code}
\var{code} must be a string containing one or more lines of Python code,
which will be executed in the restricted environment.
\end{methoddesc}
-\begin{methoddesc}{s_execfile}{code}
+\begin{methoddesc}[RExec]{s_execfile}{code}
Execute the Python code contained in the file \var{filename} in the
restricted environment.
\end{methoddesc}
@@ -132,13 +132,13 @@ implicitly called by code executing in the restricted environment.
Overriding these methods in a subclass is used to change the policies
enforced by a restricted environment.
-\begin{methoddesc}{r_import}{modulename\optional{, globals\optional{,
- locals\optional{, fromlist}}}}
+\begin{methoddesc}[RExec]{r_import}{modulename\optional{, globals\optional{,
+ locals\optional{, fromlist}}}}
Import the module \var{modulename}, raising an \exception{ImportError}
exception if the module is considered unsafe.
\end{methoddesc}
-\begin{methoddesc}{r_open}{filename\optional{, mode\optional{, bufsize}}}
+\begin{methoddesc}[RExec]{r_open}{filename\optional{, mode\optional{, bufsize}}}
Method called when \function{open()} is called in the restricted
environment. The arguments are identical to those of \function{open()},
and a file object (or a class instance compatible with file objects)
@@ -148,28 +148,28 @@ the example below for an implementation of a less restrictive
\method{r_open()}.
\end{methoddesc}
-\begin{methoddesc}{r_reload}{module}
+\begin{methoddesc}[RExec]{r_reload}{module}
Reload the module object \var{module}, re-parsing and re-initializing it.
\end{methoddesc}
-\begin{methoddesc}{r_unload}{module}
+\begin{methoddesc}[RExec]{r_unload}{module}
Unload the module object \var{module} (remove it from the
restricted environment's \code{sys.modules} dictionary).
\end{methoddesc}
And their equivalents with access to restricted standard I/O streams:
-\begin{methoddesc}{s_import}{modulename\optional{, globals\optional{,
- locals\optional{, fromlist}}}}
+\begin{methoddesc}[RExec]{s_import}{modulename\optional{, globals\optional{,
+ locals\optional{, fromlist}}}}
Import the module \var{modulename}, raising an \exception{ImportError}
exception if the module is considered unsafe.
\end{methoddesc}
-\begin{methoddesc}{s_reload}{module}
+\begin{methoddesc}[RExec]{s_reload}{module}
Reload the module object \var{module}, re-parsing and re-initializing it.
\end{methoddesc}
-\begin{methoddesc}{s_unload}{module}
+\begin{methoddesc}[RExec]{s_unload}{module}
Unload the module object \var{module}.
% XXX what are the semantics of this?
\end{methoddesc}
@@ -184,7 +184,7 @@ instance won't have any effect; instead, create a subclass of
Instances of the new class will then use those new values. All these
attributes are tuples of strings.
-\begin{memberdesc}{nok_builtin_names}
+\begin{memberdesc}[RExec]{nok_builtin_names}
Contains the names of built-in functions which will \emph{not} be
available to programs running in the restricted environment. The
value for \class{RExec} is \code{('open', 'reload', '__import__')}.
@@ -196,7 +196,7 @@ built-in functions are added to Python, they will also be added to
this module.)
\end{memberdesc}
-\begin{memberdesc}{ok_builtin_modules}
+\begin{memberdesc}[RExec]{ok_builtin_modules}
Contains the names of built-in modules which can be safely imported.
The value for \class{RExec} is \code{('audioop', 'array', 'binascii',
'cmath', 'errno', 'imageop', 'marshal', 'math', 'md5', 'operator',
@@ -205,14 +205,14 @@ The value for \class{RExec} is \code{('audioop', 'array', 'binascii',
applies --- use the value from the base class as a starting point.
\end{memberdesc}
-\begin{memberdesc}{ok_path}
+\begin{memberdesc}[RExec]{ok_path}
Contains the directories which will be searched when an \keyword{import}
is performed in the restricted environment.
The value for \class{RExec} is the same as \code{sys.path} (at the time
the module is loaded) for unrestricted code.
\end{memberdesc}
-\begin{memberdesc}{ok_posix_names}
+\begin{memberdesc}[RExec]{ok_posix_names}
% Should this be called ok_os_names?
Contains the names of the functions in the \refmodule{os} module which will be
available to programs running in the restricted environment. The
@@ -221,14 +221,14 @@ value for \class{RExec} is \code{('error', 'fstat', 'listdir',
'getcwd', 'getuid', 'getgid', 'geteuid', 'getegid')}.
\end{memberdesc}
-\begin{memberdesc}{ok_sys_names}
+\begin{memberdesc}[RExec]{ok_sys_names}
Contains the names of the functions and variables in the \refmodule{sys}
module which will be available to programs running in the restricted
environment. The value for \class{RExec} is \code{('ps1', 'ps2',
'copyright', 'version', 'platform', 'exit', 'maxint')}.
\end{memberdesc}
-\begin{memberdesc}{ok_file_types}
+\begin{memberdesc}[RExec]{ok_file_types}
Contains the file types from which modules are allowed to be loaded.
Each file type is an integer constant defined in the \refmodule{imp} module.
The meaningful values are \constant{PY_SOURCE}, \constant{PY_COMPILED}, and
diff --git a/Doc/lib/librfc822.tex b/Doc/lib/librfc822.tex
index 4ca3734..b59e6ad 100644
--- a/Doc/lib/librfc822.tex
+++ b/Doc/lib/librfc822.tex
@@ -100,7 +100,7 @@ however, some mailers don't follow that format as specified, so
\code{'Mon, 20 Nov 1995 19:12:08 -0500'}. If it succeeds in parsing
the date, \function{parsedate()} returns a 9-tuple that can be passed
directly to \function{time.mktime()}; otherwise \code{None} will be
-returned. Note that fields 6, 7, and 8 of the result tuple are not
+returned. Note that indexes 6, 7, and 8 of the result tuple are not
usable.
\end{funcdesc}
@@ -114,7 +114,7 @@ offset is the opposite of the sign of the \code{time.timezone}
variable for the same timezone; the latter variable follows the
\POSIX{} standard while this module follows \rfc{2822}.) If the input
string has no timezone, the last element of the tuple returned is
-\code{None}. Note that fields 6, 7, and 8 of the result tuple are not
+\code{None}. Note that indexes 6, 7, and 8 of the result tuple are not
usable.
\end{funcdesc}
@@ -142,12 +142,12 @@ switch dates. Not enough to worry about for common use.
A \class{Message} instance has the following methods:
-\begin{methoddesc}{rewindbody}{}
+\begin{methoddesc}[Message]{rewindbody}{}
Seek to the start of the message body. This only works if the file
object is seekable.
\end{methoddesc}
-\begin{methoddesc}{isheader}{line}
+\begin{methoddesc}[Message]{isheader}{line}
Returns a line's canonicalized fieldname (the dictionary key that will
be used to index it) if the line is a legal \rfc{2822} header; otherwise
returns \code{None} (implying that parsing should stop here and the
@@ -155,33 +155,33 @@ line be pushed back on the input stream). It is sometimes useful to
override this method in a subclass.
\end{methoddesc}
-\begin{methoddesc}{islast}{line}
+\begin{methoddesc}[Message]{islast}{line}
Return true if the given line is a delimiter on which Message should
stop. The delimiter line is consumed, and the file object's read
location positioned immediately after it. By default this method just
checks that the line is blank, but you can override it in a subclass.
\end{methoddesc}
-\begin{methoddesc}{iscomment}{line}
+\begin{methoddesc}[Message]{iscomment}{line}
Return \code{True} if the given line should be ignored entirely, just skipped.
By default this is a stub that always returns \code{False}, but you can
override it in a subclass.
\end{methoddesc}
-\begin{methoddesc}{getallmatchingheaders}{name}
+\begin{methoddesc}[Message]{getallmatchingheaders}{name}
Return a list of lines consisting of all headers matching
\var{name}, if any. Each physical line, whether it is a continuation
line or not, is a separate list item. Return the empty list if no
header matches \var{name}.
\end{methoddesc}
-\begin{methoddesc}{getfirstmatchingheader}{name}
+\begin{methoddesc}[Message]{getfirstmatchingheader}{name}
Return a list of lines comprising the first header matching
\var{name}, and its continuation line(s), if any. Return
\code{None} if there is no header matching \var{name}.
\end{methoddesc}
-\begin{methoddesc}{getrawheader}{name}
+\begin{methoddesc}[Message]{getrawheader}{name}
Return a single string consisting of the text after the colon in the
first header matching \var{name}. This includes leading whitespace,
the trailing linefeed, and internal linefeeds and whitespace if there
@@ -189,19 +189,19 @@ any continuation line(s) were present. Return \code{None} if there is
no header matching \var{name}.
\end{methoddesc}
-\begin{methoddesc}{getheader}{name\optional{, default}}
+\begin{methoddesc}[Message]{getheader}{name\optional{, default}}
Like \code{getrawheader(\var{name})}, but strip leading and trailing
whitespace. Internal whitespace is not stripped. The optional
\var{default} argument can be used to specify a different default to
be returned when there is no header matching \var{name}.
\end{methoddesc}
-\begin{methoddesc}{get}{name\optional{, default}}
+\begin{methoddesc}[Message]{get}{name\optional{, default}}
An alias for \method{getheader()}, to make the interface more compatible
with regular dictionaries.
\end{methoddesc}
-\begin{methoddesc}{getaddr}{name}
+\begin{methoddesc}[Message]{getaddr}{name}
Return a pair \code{(\var{full name}, \var{email address})} parsed
from the string returned by \code{getheader(\var{name})}. If no
header matching \var{name} exists, return \code{(None, None)};
@@ -217,7 +217,7 @@ If the header contained
exact same result.
\end{methoddesc}
-\begin{methoddesc}{getaddrlist}{name}
+\begin{methoddesc}[Message]{getaddrlist}{name}
This is similar to \code{getaddr(\var{list})}, but parses a header
containing a list of email addresses (e.g.\ a \mailheader{To} header) and
returns a list of \code{(\var{full name}, \var{email address})} pairs
@@ -229,7 +229,7 @@ are several \mailheader{Cc} headers), all are parsed for addresses.
Any continuation lines the named headers contain are also parsed.
\end{methoddesc}
-\begin{methoddesc}{getdate}{name}
+\begin{methoddesc}[Message]{getdate}{name}
Retrieve a header using \method{getheader()} and parse it into a 9-tuple
compatible with \function{time.mktime()}; note that fields 6, 7, and 8
are not usable. If there is no header matching
@@ -241,7 +241,7 @@ collection of email from many sources, it is still possible that this
function may occasionally yield an incorrect result.
\end{methoddesc}
-\begin{methoddesc}{getdate_tz}{name}
+\begin{methoddesc}[Message]{getdate_tz}{name}
Retrieve a header using \method{getheader()} and parse it into a
10-tuple; the first 9 elements will make a tuple compatible with
\function{time.mktime()}, and the 10th is a number giving the offset
@@ -270,19 +270,19 @@ support the \method{clear()}, \method{copy()}, \method{popitem()}, or
Finally, \class{Message} instances have some public instance variables:
-\begin{memberdesc}{headers}
+\begin{memberdesc}[Message]{headers}
A list containing the entire set of header lines, in the order in
which they were read (except that setitem calls may disturb this
order). Each line contains a trailing newline. The
blank line terminating the headers is not contained in the list.
\end{memberdesc}
-\begin{memberdesc}{fp}
+\begin{memberdesc}[Message]{fp}
The file or file-like object passed at instantiation time. This can
be used to read the message content.
\end{memberdesc}
-\begin{memberdesc}{unixfrom}
+\begin{memberdesc}[Message]{unixfrom}
The \UNIX{} \samp{From~} line, if the message had one, or an empty
string. This is needed to regenerate the message in some contexts,
such as an \code{mbox}-style mailbox file.
@@ -293,34 +293,34 @@ such as an \code{mbox}-style mailbox file.
An \class{AddressList} instance has the following methods:
-\begin{methoddesc}{__len__}{}
+\begin{methoddesc}[AddressList]{__len__}{}
Return the number of addresses in the address list.
\end{methoddesc}
-\begin{methoddesc}{__str__}{}
+\begin{methoddesc}[AddressList]{__str__}{}
Return a canonicalized string representation of the address list.
Addresses are rendered in "name" <host@domain> form, comma-separated.
\end{methoddesc}
-\begin{methoddesc}{__add__}{alist}
+\begin{methoddesc}[AddressList]{__add__}{alist}
Return a new \class{AddressList} instance that contains all addresses
in both \class{AddressList} operands, with duplicates removed (set
union).
\end{methoddesc}
-\begin{methoddesc}{__iadd__}{alist}
+\begin{methoddesc}[AddressList]{__iadd__}{alist}
In-place version of \method{__add__()}; turns this \class{AddressList}
instance into the union of itself and the right-hand instance,
\var{alist}.
\end{methoddesc}
-\begin{methoddesc}{__sub__}{alist}
+\begin{methoddesc}[AddressList]{__sub__}{alist}
Return a new \class{AddressList} instance that contains every address
in the left-hand \class{AddressList} operand that is not present in
the right-hand address operand (set difference).
\end{methoddesc}
-\begin{methoddesc}{__isub__}{alist}
+\begin{methoddesc}[AddressList]{__isub__}{alist}
In-place version of \method{__sub__()}, removing addresses in this
list which are also in \var{alist}.
\end{methoddesc}
@@ -328,7 +328,7 @@ list which are also in \var{alist}.
Finally, \class{AddressList} instances have one public instance variable:
-\begin{memberdesc}{addresslist}
+\begin{memberdesc}[AddressList]{addresslist}
A list of tuple string pairs, one per address. In each member, the
first is the canonicalized name part, the second is the
actual route-address (\character{@}-separated username-host.domain
diff --git a/Doc/lib/libsched.tex b/Doc/lib/libsched.tex
index 6b586a8..75bab7e 100644
--- a/Doc/lib/libsched.tex
+++ b/Doc/lib/libsched.tex
@@ -48,7 +48,7 @@ From print_time 930343700.273
\class{scheduler} instances have the following methods:
-\begin{methoddesc}{enterabs}{time, priority, action, argument}
+\begin{methoddesc}[scheduler]{enterabs}{time, priority, action, argument}
Schedule a new event. The \var{time} argument should be a numeric type
compatible with the return value of the \var{timefunc} function passed
to the constructor. Events scheduled for
@@ -63,23 +63,23 @@ Return value is an event which may be used for later cancellation of
the event (see \method{cancel()}).
\end{methoddesc}
-\begin{methoddesc}{enter}{delay, priority, action, argument}
+\begin{methoddesc}[scheduler]{enter}{delay, priority, action, argument}
Schedule an event for \var{delay} more time units. Other then the
relative time, the other arguments, the effect and the return value
are the same as those for \method{enterabs()}.
\end{methoddesc}
-\begin{methoddesc}{cancel}{event}
+\begin{methoddesc}[scheduler]{cancel}{event}
Remove the event from the queue. If \var{event} is not an event
currently in the queue, this method will raise a
\exception{RuntimeError}.
\end{methoddesc}
-\begin{methoddesc}{empty}{}
+\begin{methoddesc}[scheduler]{empty}{}
Return true if the event queue is empty.
\end{methoddesc}
-\begin{methoddesc}{run}{}
+\begin{methoddesc}[scheduler]{run}{}
Run all scheduled events. This function will wait
(using the \function{delayfunc} function passed to the constructor)
for the next event, then execute it and so on until there are no more
diff --git a/Doc/lib/libselect.tex b/Doc/lib/libselect.tex
index e93f70f..69583d4 100644
--- a/Doc/lib/libselect.tex
+++ b/Doc/lib/libselect.tex
@@ -77,7 +77,7 @@ afterward the whole bitmap has to be linearly scanned again.
\cfunction{select()} is O(highest file descriptor), while
\cfunction{poll()} is O(number of file descriptors).
-\begin{methoddesc}{register}{fd\optional{, eventmask}}
+\begin{methoddesc}[poll]{register}{fd\optional{, eventmask}}
Register a file descriptor with the polling object. Future calls to
the \method{poll()} method will then check whether the file descriptor
has any pending I/O events. \var{fd} can be either an integer, or an
@@ -105,7 +105,7 @@ error, and has the same effect as registering the descriptor exactly
once.
\end{methoddesc}
-\begin{methoddesc}{unregister}{fd}
+\begin{methoddesc}[poll]{unregister}{fd}
Remove a file descriptor being tracked by a polling object. Just like
the \method{register()} method, \var{fd} can be an integer or an
object with a \method{fileno()} method that returns an integer.
@@ -114,7 +114,7 @@ Attempting to remove a file descriptor that was never registered
causes a \exception{KeyError} exception to be raised.
\end{methoddesc}
-\begin{methoddesc}{poll}{\optional{timeout}}
+\begin{methoddesc}[poll]{poll}{\optional{timeout}}
Polls the set of registered file descriptors, and returns a
possibly-empty list containing \code{(\var{fd}, \var{event})} 2-tuples
for the descriptors that have events or errors to report.
diff --git a/Doc/lib/libshlex.tex b/Doc/lib/libshlex.tex
index 3a43648..451615f 100644
--- a/Doc/lib/libshlex.tex
+++ b/Doc/lib/libshlex.tex
@@ -58,7 +58,7 @@ parsing rules. See section~\ref{shlex-objects}.
A \class{shlex} instance has the following methods:
-\begin{methoddesc}{get_token}{}
+\begin{methoddesc}[shlex]{get_token}{}
Return a token. If tokens have been stacked using
\method{push_token()}, pop a token off the stack. Otherwise, read one
from the input stream. If reading encounters an immediate
@@ -66,17 +66,17 @@ end-of-file, \member{self.eof} is returned (the empty string (\code{''})
in non-\POSIX{} mode, and \code{None} in \POSIX{} mode).
\end{methoddesc}
-\begin{methoddesc}{push_token}{str}
+\begin{methoddesc}[shlex]{push_token}{str}
Push the argument onto the token stack.
\end{methoddesc}
-\begin{methoddesc}{read_token}{}
+\begin{methoddesc}[shlex]{read_token}{}
Read a raw token. Ignore the pushback stack, and do not interpret source
requests. (This is not ordinarily a useful entry point, and is
documented here only for the sake of completeness.)
\end{methoddesc}
-\begin{methoddesc}{sourcehook}{filename}
+\begin{methoddesc}[shlex]{sourcehook}{filename}
When \class{shlex} detects a source request (see
\member{source} below) this method is given the following token as
argument, and expected to return a tuple consisting of a filename and
@@ -106,7 +106,7 @@ For more explicit control of source stacking, use the
\method{push_source()} and \method{pop_source()} methods.
\end{methoddesc}
-\begin{methoddesc}{push_source}{stream\optional{, filename}}
+\begin{methoddesc}[shlex]{push_source}{stream\optional{, filename}}
Push an input source stream onto the input stack. If the filename
argument is specified it will later be available for use in error
messages. This is the same method used internally by the
@@ -114,14 +114,14 @@ messages. This is the same method used internally by the
\versionadded{2.1}
\end{methoddesc}
-\begin{methoddesc}{pop_source}{}
+\begin{methoddesc}[shlex]{pop_source}{}
Pop the last-pushed input source from the input stack.
This is the same method used internally when the lexer reaches
\EOF{} on a stacked input stream.
\versionadded{2.1}
\end{methoddesc}
-\begin{methoddesc}{error_leader}{\optional{file\optional{, line}}}
+\begin{methoddesc}[shlex]{error_leader}{\optional{file\optional{, line}}}
This method generates an error message leader in the format of a
\UNIX{} C compiler error label; the format is \code{'"\%s", line \%d: '},
where the \samp{\%s} is replaced with the name of the current source
@@ -137,63 +137,63 @@ Instances of \class{shlex} subclasses have some public instance
variables which either control lexical analysis or can be used for
debugging:
-\begin{memberdesc}{commenters}
+\begin{memberdesc}[shlex]{commenters}
The string of characters that are recognized as comment beginners.
All characters from the comment beginner to end of line are ignored.
Includes just \character{\#} by default.
\end{memberdesc}
-\begin{memberdesc}{wordchars}
+\begin{memberdesc}[shlex]{wordchars}
The string of characters that will accumulate into multi-character
tokens. By default, includes all \ASCII{} alphanumerics and
underscore.
\end{memberdesc}
-\begin{memberdesc}{whitespace}
+\begin{memberdesc}[shlex]{whitespace}
Characters that will be considered whitespace and skipped. Whitespace
bounds tokens. By default, includes space, tab, linefeed and
carriage-return.
\end{memberdesc}
-\begin{memberdesc}{escape}
+\begin{memberdesc}[shlex]{escape}
Characters that will be considered as escape. This will be only used
in \POSIX{} mode, and includes just \character{\textbackslash} by default.
\versionadded{2.3}
\end{memberdesc}
-\begin{memberdesc}{quotes}
+\begin{memberdesc}[shlex]{quotes}
Characters that will be considered string quotes. The token
accumulates until the same quote is encountered again (thus, different
quote types protect each other as in the shell.) By default, includes
\ASCII{} single and double quotes.
\end{memberdesc}
-\begin{memberdesc}{escapedquotes}
+\begin{memberdesc}[shlex]{escapedquotes}
Characters in \member{quotes} that will interpret escape characters
defined in \member{escape}. This is only used in \POSIX{} mode, and
includes just \character{"} by default.
\versionadded{2.3}
\end{memberdesc}
-\begin{memberdesc}{whitespace_split}
+\begin{memberdesc}[shlex]{whitespace_split}
If \code{True}, tokens will only be split in whitespaces. This is useful, for
example, for parsing command lines with \class{shlex}, getting tokens
in a similar way to shell arguments.
\versionadded{2.3}
\end{memberdesc}
-\begin{memberdesc}{infile}
+\begin{memberdesc}[shlex]{infile}
The name of the current input file, as initially set at class
instantiation time or stacked by later source requests. It may
be useful to examine this when constructing error messages.
\end{memberdesc}
-\begin{memberdesc}{instream}
+\begin{memberdesc}[shlex]{instream}
The input stream from which this \class{shlex} instance is reading
characters.
\end{memberdesc}
-\begin{memberdesc}{source}
+\begin{memberdesc}[shlex]{source}
This member is \code{None} by default. If you assign a string to it,
that string will be recognized as a lexical-level inclusion request
similar to the \samp{source} keyword in various shells. That is, the
@@ -204,23 +204,23 @@ become the original input stream. Source requests may be stacked any
number of levels deep.
\end{memberdesc}
-\begin{memberdesc}{debug}
+\begin{memberdesc}[shlex]{debug}
If this member is numeric and \code{1} or more, a \class{shlex}
instance will print verbose progress output on its behavior. If you
need to use this, you can read the module source code to learn the
details.
\end{memberdesc}
-\begin{memberdesc}{lineno}
+\begin{memberdesc}[shlex]{lineno}
Source line number (count of newlines seen so far plus one).
\end{memberdesc}
-\begin{memberdesc}{token}
+\begin{memberdesc}[shlex]{token}
The token buffer. It may be useful to examine this when catching
exceptions.
\end{memberdesc}
-\begin{memberdesc}{eof}
+\begin{memberdesc}[shlex]{eof}
Token used to determine end of file. This will be set to the empty
string (\code{''}), in non-\POSIX{} mode, and to \code{None} in
\POSIX{} mode.
diff --git a/Doc/lib/libshutil.tex b/Doc/lib/libshutil.tex
index ee3b535..5201332 100644
--- a/Doc/lib/libshutil.tex
+++ b/Doc/lib/libshutil.tex
@@ -34,7 +34,9 @@ file type and creator codes will not be correct.
is the buffer size. In particular, a negative \var{length} value
means to copy the data without looping over the source data in
chunks; by default the data is read in chunks to avoid uncontrolled
- memory consumption.
+ memory consumption. Note that if the current file position of the
+ \var{fsrc} object is not 0, only the contents from the current file
+ position to the end of the file will be copied.
\end{funcdesc}
\begin{funcdesc}{copymode}{src, dst}
diff --git a/Doc/lib/libsimplexmlrpc.tex b/Doc/lib/libsimplexmlrpc.tex
index 6b45855..235905e 100644
--- a/Doc/lib/libsimplexmlrpc.tex
+++ b/Doc/lib/libsimplexmlrpc.tex
@@ -15,7 +15,9 @@ CGI environment, using \class{CGIXMLRPCRequestHandler}.
\begin{classdesc}{SimpleXMLRPCServer}{addr\optional{,
requestHandler\optional{,
- logRequests\optional{, allow_none\optional{, encoding}}}}}
+ logRequests\optional{,
+ allow_none\optional{,
+ encoding}}}}}
Create a new server instance. This class
provides methods for registration of functions that can be called by
@@ -28,8 +30,13 @@ CGI environment, using \class{CGIXMLRPCRequestHandler}.
setting this parameter to false will turn off logging.
The \var{allow_none} and \var{encoding} parameters are passed on to
\module{xmlrpclib} and control the XML-RPC responses that will be returned
- from the server.
+ from the server. The \var{bind_and_activate} parameter controls whether
+ \method{server_bind()} and \method{server_activate()} are called immediately
+ by the constructor; it defaults to true. Setting it to false allows code to
+ manipulate the \var{allow_reuse_address} class variable before the address
+ is bound.
\versionchanged[The \var{allow_none} and \var{encoding} parameters were added]{2.5}
+ \versionchanged[The \var{bind_and_activate} parameter was added]{2.6}
\end{classdesc}
\begin{classdesc}{CGIXMLRPCRequestHandler}{\optional{allow_none\optional{, encoding}}}
@@ -101,13 +108,13 @@ simple, stand alone XML-RPC servers.
\end{methoddesc}
-\begin{methoddesc}{register_introspection_functions}{}
+\begin{methoddesc}[SimpleXMLRPCServer]{register_introspection_functions}{}
Registers the XML-RPC introspection functions \code{system.listMethods},
\code{system.methodHelp} and \code{system.methodSignature}.
\versionadded{2.3}
\end{methoddesc}
-\begin{methoddesc}{register_multicall_functions}{}
+\begin{methoddesc}[SimpleXMLRPCServer]{register_multicall_functions}{}
Registers the XML-RPC multicall function system.multicall.
\end{methoddesc}
@@ -171,7 +178,7 @@ print s.system.listMethods()
The \class{CGIXMLRPCRequestHandler} class can be used to
handle XML-RPC requests sent to Python CGI scripts.
-\begin{methoddesc}{register_function}{function\optional{, name}}
+\begin{methoddesc}[CGIXMLRPCRequestHandler]{register_function}{function\optional{, name}}
Register a function that can respond to XML-RPC requests. If
\var{name} is given, it will be the method name associated with
function, otherwise \var{function.__name__} will be used. \var{name}
@@ -180,7 +187,7 @@ characters not legal in Python identifiers, including the period
character.
\end{methoddesc}
-\begin{methoddesc}{register_instance}{instance}
+\begin{methoddesc}[CGIXMLRPCRequestHandler]{register_instance}{instance}
Register an object which is used to expose method names
which have not been registered using \method{register_function()}. If
instance contains a \method{_dispatch()} method, it is called with the
@@ -196,17 +203,17 @@ parameters from the request, and the return value is passed
back to the client.
\end{methoddesc}
-\begin{methoddesc}{register_introspection_functions}{}
+\begin{methoddesc}[CGIXMLRPCRequestHandler]{register_introspection_functions}{}
Register the XML-RPC introspection functions
\code{system.listMethods}, \code{system.methodHelp} and
\code{system.methodSignature}.
\end{methoddesc}
-\begin{methoddesc}{register_multicall_functions}{}
+\begin{methoddesc}[CGIXMLRPCRequestHandler]{register_multicall_functions}{}
Register the XML-RPC multicall function \code{system.multicall}.
\end{methoddesc}
-\begin{methoddesc}{handle_request}{\optional{request_text = None}}
+\begin{methoddesc}[CGIXMLRPCRequestHandler]{handle_request}{\optional{request_text = None}}
Handle a XML-RPC request. If \var{request_text} is given, it
should be the POST data provided by the HTTP server,
otherwise the contents of stdin will be used.
diff --git a/Doc/lib/libsite.tex b/Doc/lib/libsite.tex
index c079790..11858d1 100644
--- a/Doc/lib/libsite.tex
+++ b/Doc/lib/libsite.tex
@@ -28,12 +28,17 @@ the newly added path for configuration files.
A path configuration file is a file whose name has the form
\file{\var{package}.pth} and exists in one of the four directories
-mentioned above; its contents are additional items (one
-per line) to be added to \code{sys.path}. Non-existing items are
-never added to \code{sys.path}, but no check is made that the item
-refers to a directory (rather than a file). No item is added to
-\code{sys.path} more than once. Blank lines and lines beginning with
-\code{\#} are skipped. Lines starting with \code{import} are executed.
+mentioned above; its contents are additional items (one per line) to
+be added to \code{sys.path}. Non-existing items are never added to
+\code{sys.path}, but no check is made that the item refers to a
+directory (rather than a file). No item is added to \code{sys.path}
+more than once. Blank lines and lines beginning with \code{\#} are
+skipped. Lines starting with \code{import} (followed by space or tab)
+are executed.
+
+\versionchanged[A space or tab is now required after the import
+keyword]{2.6}
+
\index{package}
\indexiii{path}{configuration}{file}
diff --git a/Doc/lib/libsmtplib.tex b/Doc/lib/libsmtplib.tex
index a873a9d..26293d6 100644
--- a/Doc/lib/libsmtplib.tex
+++ b/Doc/lib/libsmtplib.tex
@@ -15,13 +15,16 @@ listener daemon. For details of SMTP and ESMTP operation, consult
(\citetitle{SMTP Service Extensions}).
\begin{classdesc}{SMTP}{\optional{host\optional{, port\optional{,
- local_hostname}}}}
+ local_hostname\optional{, timeout}}}}}
A \class{SMTP} instance encapsulates an SMTP connection. It has
methods that support a full repertoire of SMTP and ESMTP
operations. If the optional host and port parameters are given, the
SMTP \method{connect()} method is called with those parameters during
initialization. An \exception{SMTPConnectError} is raised if the
specified host doesn't respond correctly.
+The optional \var{timeout} parameter specifies a timeout in seconds for the
+connection attempt (if not specified, or passed as None, the global
+default timeout setting will be used).
For normal use, you should only require the initialization/connect,
\method{sendmail()}, and \method{quit()} methods. An example is
@@ -31,7 +34,7 @@ included below.
\begin{classdesc}{SMTP_SSL}{\optional{host\optional{, port\optional{,
local_hostname\optional{,
keyfile\optional{,
- certfile}}}}}}
+ certfile\optional{, timeout}}}}}}}
A \class{SMTP_SSL} instance behaves exactly the same as instances of \class{SMTP}.
\class{SMTP_SSL} should be used for situations where SSL is required from
the beginning of the connection and using \method{starttls()} is not appropriate.
@@ -39,6 +42,26 @@ If \var{host} is not specified, the local host is used. If \var{port} is
omitted, the standard SMTP-over-SSL port (465) is used. \var{keyfile} and \var{certfile}
are also optional, and can contain a PEM formatted private key and
certificate chain file for the SSL connection.
+The optional \var{timeout} parameter specifies a timeout in seconds for the
+connection attempt (if not specified, or passed as None, the global
+default timeout setting will be used).
+\end{classdesc}
+
+\begin{classdesc}{LMTP}{\optional{host\optional{, port\optional{,
+ local_hostname}}}}
+
+The LMTP protocol, which is very similar to ESMTP, is heavily based
+on the standard SMTP client. It's common to use Unix sockets for LMTP,
+so our connect() method must support that as well as a regular
+host:port server. To specify a Unix socket, you must use an absolute
+path for \var{host}, starting with a '/'.
+
+Authentication is supported, using the regular SMTP mechanism. When
+using a Unix socket, LMTP generally don't support or require any
+authentication, but your mileage might vary.
+
+\versionadded{2.6}
+
\end{classdesc}
A nice selection of exceptions is defined as well:
@@ -103,13 +126,13 @@ A nice selection of exceptions is defined as well:
An \class{SMTP} instance has the following methods:
-\begin{methoddesc}{set_debuglevel}{level}
+\begin{methoddesc}[SMTP]{set_debuglevel}{level}
Set the debug output level. A true value for \var{level} results in
debug messages for connection and for all messages sent to and
received from the server.
\end{methoddesc}
-\begin{methoddesc}{connect}{\optional{host\optional{, port}}}
+\begin{methoddesc}[SMTP]{connect}{\optional{host\optional{, port}}}
Connect to a host on a given port. The defaults are to connect to the
local host at the standard SMTP port (25).
If the hostname ends with a colon (\character{:}) followed by a
@@ -119,7 +142,7 @@ This method is automatically invoked by the constructor if a
host is specified during instantiation.
\end{methoddesc}
-\begin{methoddesc}{docmd}{cmd, \optional{, argstring}}
+\begin{methoddesc}[SMTP]{docmd}{cmd, \optional{, argstring}}
Send a command \var{cmd} to the server. The optional argument
\var{argstring} is simply concatenated to the command, separated by a
space.
@@ -136,7 +159,7 @@ If the connection to the server is lost while waiting for the reply,
\exception{SMTPServerDisconnected} will be raised.
\end{methoddesc}
-\begin{methoddesc}{helo}{\optional{hostname}}
+\begin{methoddesc}[SMTP]{helo}{\optional{hostname}}
Identify yourself to the SMTP server using \samp{HELO}. The hostname
argument defaults to the fully qualified domain name of the local
host.
@@ -146,7 +169,7 @@ explicitly. It will be implicitly called by the \method{sendmail()}
when necessary.
\end{methoddesc}
-\begin{methoddesc}{ehlo}{\optional{hostname}}
+\begin{methoddesc}[SMTP]{ehlo}{\optional{hostname}}
Identify yourself to an ESMTP server using \samp{EHLO}. The hostname
argument defaults to the fully qualified domain name of the local
host. Examine the response for ESMTP option and store them for use by
@@ -157,13 +180,13 @@ mail, it should not be necessary to call this method explicitly. It
will be implicitly called by \method{sendmail()} when necessary.
\end{methoddesc}
-\begin{methoddesc}{has_extn}{name}
+\begin{methoddesc}[SMTP]{has_extn}{name}
Return \constant{True} if \var{name} is in the set of SMTP service
extensions returned by the server, \constant{False} otherwise.
Case is ignored.
\end{methoddesc}
-\begin{methoddesc}{verify}{address}
+\begin{methoddesc}[SMTP]{verify}{address}
Check the validity of an address on this server using SMTP \samp{VRFY}.
Returns a tuple consisting of code 250 and a full \rfc{822} address
(including human name) if the user address is valid. Otherwise returns
@@ -172,7 +195,7 @@ an SMTP error code of 400 or greater and an error string.
\note{Many sites disable SMTP \samp{VRFY} in order to foil spammers.}
\end{methoddesc}
-\begin{methoddesc}{login}{user, password}
+\begin{methoddesc}[SMTP]{login}{user, password}
Log in on an SMTP server that requires authentication.
The arguments are the username and the password to authenticate with.
If there has been no previous \samp{EHLO} or \samp{HELO} command this
@@ -190,7 +213,7 @@ or may raise the following exceptions:
\end{description}
\end{methoddesc}
-\begin{methoddesc}{starttls}{\optional{keyfile\optional{, certfile}}}
+\begin{methoddesc}[SMTP]{starttls}{\optional{keyfile\optional{, certfile}}}
Put the SMTP connection in TLS (Transport Layer Security) mode. All
SMTP commands that follow will be encrypted. You should then call
\method{ehlo()} again.
@@ -199,8 +222,8 @@ If \var{keyfile} and \var{certfile} are provided, these are passed to
the \refmodule{socket} module's \function{ssl()} function.
\end{methoddesc}
-\begin{methoddesc}{sendmail}{from_addr, to_addrs, msg\optional{,
- mail_options, rcpt_options}}
+\begin{methoddesc}[SMTP]{sendmail}{from_addr, to_addrs, msg\optional{,
+ mail_options, rcpt_options}}
Send mail. The required arguments are an \rfc{822} from-address
string, a list of \rfc{822} to-address strings (a bare string will be
treated as a list with 1 address), and a message string. The caller
@@ -256,7 +279,7 @@ an exception is raised.
\end{methoddesc}
-\begin{methoddesc}{quit}{}
+\begin{methoddesc}[SMTP]{quit}{}
Terminate the SMTP session and close the connection.
\end{methoddesc}
diff --git a/Doc/lib/libsocket.tex b/Doc/lib/libsocket.tex
index 1a231d3..ff0fb87 100644
--- a/Doc/lib/libsocket.tex
+++ b/Doc/lib/libsocket.tex
@@ -14,7 +14,7 @@ For an introduction to socket programming (in C), see the following
papers: \citetitle{An Introductory 4.3BSD Interprocess Communication
Tutorial}, by Stuart Sechrest and \citetitle{An Advanced 4.3BSD
Interprocess Communication Tutorial}, by Samuel J. Leffler et al,
-both in the \citetitle{\UNIX{} Programmer's Manual, Supplementary Documents 1}
+both in the \citetitle{UNIX Programmer's Manual, Supplementary Documents 1}
(sections PS1:7 and PS1:8). The platform-specific reference material
for the various socket-related system calls are also a valuable source
of information on the details of socket semantics. For \UNIX, refer
@@ -170,6 +170,15 @@ supported on this platform.
\versionadded{2.3}
\end{datadesc}
+\begin{funcdesc}{create_connection}{address\optional{, timeout}}
+Connects to the \var{address} received (as usual, a \code{(host, port)}
+pair), with an optional timeout for the connection. Specially useful for
+higher-level protocols, it is not normally used directly from
+application-level code. Passing the optional \var{timeout} parameter
+will set the timeout on the socket instance (if it is not given or
+\code{None}, the global default timeout setting is used).
+\end{funcdesc}
+
\begin{funcdesc}{getaddrinfo}{host, port\optional{, family\optional{,
socktype\optional{, proto\optional{,
flags}}}}}
@@ -548,7 +557,7 @@ are described in \ref{bltin-file-objects}, ``File Objects.'')
The file object references a \cfunction{dup()}ped version of the
socket file descriptor, so the file object and socket object may be
closed or garbage-collected independently.
-The socket must be in blocking mode.
+The socket must be in blocking mode (it can not have a timeout).
\index{I/O control!buffering}The optional \var{mode}
and \var{bufsize} arguments are interpreted the same way as by the
built-in \function{file()} function; see ``Built-in Functions''
@@ -584,6 +593,7 @@ sending the data. See the \UNIX{} manual page
\manpage{recv}{2} for the meaning of the optional argument
\var{flags}; it defaults to zero. (The format of \var{address}
depends on the address family --- see above.)
+\versionadded{2.5}
\end{methoddesc}
\begin{methoddesc}[socket]{recv_into}{buffer\optional{, nbytes\optional{, flags}}}
@@ -593,6 +603,7 @@ If \var{nbytes} is not specified (or 0),
receive up to the size available in the given buffer.
See the \UNIX{} manual page \manpage{recv}{2} for the meaning of the
optional argument \var{flags}; it defaults to zero.
+\versionadded{2.5}
\end{methoddesc}
\begin{methoddesc}[socket]{send}{string\optional{, flags}}
@@ -722,23 +733,23 @@ The socket protocol.
SSL objects have the following methods.
-\begin{methoddesc}{write}{s}
+\begin{methoddesc}[SSL]{write}{s}
Writes the string \var{s} to the on the object's SSL connection.
The return value is the number of bytes written.
\end{methoddesc}
-\begin{methoddesc}{read}{\optional{n}}
+\begin{methoddesc}[SSL]{read}{\optional{n}}
If \var{n} is provided, read \var{n} bytes from the SSL connection, otherwise
read until EOF. The return value is a string of the bytes read.
\end{methoddesc}
-\begin{methoddesc}{server}{}
+\begin{methoddesc}[SSL]{server}{}
Returns a string describing the server's certificate.
Useful for debugging purposes; do not parse the content of this string
because its format can't be parsed unambiguously.
\end{methoddesc}
-\begin{methoddesc}{issuer}{}
+\begin{methoddesc}[SSL]{issuer}{}
Returns a string describing the issuer of the server's certificate.
Useful for debugging purposes; do not parse the content of this string
because its format can't be parsed unambiguously.
diff --git a/Doc/lib/libsqlite3.tex b/Doc/lib/libsqlite3.tex
index aeb60c1..19eed7e 100644
--- a/Doc/lib/libsqlite3.tex
+++ b/Doc/lib/libsqlite3.tex
@@ -210,37 +210,37 @@ the feature again.
A \class{Connection} instance has the following attributes and methods:
\label{sqlite3-Connection-IsolationLevel}
-\begin{memberdesc}{isolation_level}
+\begin{memberdesc}[Connection]{isolation_level}
Get or set the current isolation level. None for autocommit mode or one of
"DEFERRED", "IMMEDIATE" or "EXLUSIVE". See ``Controlling Transactions'',
section~\ref{sqlite3-Controlling-Transactions}, for a more detailed explanation.
\end{memberdesc}
-\begin{methoddesc}{cursor}{\optional{cursorClass}}
+\begin{methoddesc}[Connection]{cursor}{\optional{cursorClass}}
The cursor method accepts a single optional parameter \var{cursorClass}.
If supplied, this must be a custom cursor class that extends
\class{sqlite3.Cursor}.
\end{methoddesc}
-\begin{methoddesc}{execute}{sql, \optional{parameters}}
+\begin{methoddesc}[Connection]{execute}{sql, \optional{parameters}}
This is a nonstandard shortcut that creates an intermediate cursor object by
calling the cursor method, then calls the cursor's \method{execute} method with the
parameters given.
\end{methoddesc}
-\begin{methoddesc}{executemany}{sql, \optional{parameters}}
+\begin{methoddesc}[Connection]{executemany}{sql, \optional{parameters}}
This is a nonstandard shortcut that creates an intermediate cursor object by
calling the cursor method, then calls the cursor's \method{executemany} method with the
parameters given.
\end{methoddesc}
-\begin{methoddesc}{executescript}{sql_script}
+\begin{methoddesc}[Connection]{executescript}{sql_script}
This is a nonstandard shortcut that creates an intermediate cursor object by
calling the cursor method, then calls the cursor's \method{executescript} method with the
parameters given.
\end{methoddesc}
-\begin{methoddesc}{create_function}{name, num_params, func}
+\begin{methoddesc}[Connection]{create_function}{name, num_params, func}
Creates a user-defined function that you can later use from within SQL
statements under the function name \var{name}. \var{num_params} is the number
@@ -255,7 +255,7 @@ Example:
\verbatiminput{sqlite3/md5func.py}
\end{methoddesc}
-\begin{methoddesc}{create_aggregate}{name, num_params, aggregate_class}
+\begin{methoddesc}[Connection]{create_aggregate}{name, num_params, aggregate_class}
Creates a user-defined aggregate function.
@@ -271,7 +271,7 @@ Example:
\verbatiminput{sqlite3/mysumaggr.py}
\end{methoddesc}
-\begin{methoddesc}{create_collation}{name, callable}
+\begin{methoddesc}[Connection]{create_collation}{name, callable}
Creates a collation with the specified \var{name} and \var{callable}. The
callable will be passed two string arguments. It should return -1 if the first
@@ -293,14 +293,14 @@ To remove a collation, call \code{create_collation} with None as callable:
\end{verbatim}
\end{methoddesc}
-\begin{methoddesc}{interrupt}{}
+\begin{methoddesc}[Connection]{interrupt}{}
You can call this method from a different thread to abort any queries that
might be executing on the connection. The query will then abort and the caller
will get an exception.
\end{methoddesc}
-\begin{methoddesc}{set_authorizer}{authorizer_callback}
+\begin{methoddesc}[Connection]{set_authorizer}{authorizer_callback}
This routine registers a callback. The callback is invoked for each attempt to
access a column of a table in the database. The callback should return
@@ -322,7 +322,7 @@ first one. All necessary constants are available in the \module{sqlite3}
module.
\end{methoddesc}
-\begin{memberdesc}{row_factory}
+\begin{memberdesc}[Connection]{row_factory}
You can change this attribute to a callable that accepts the cursor and
the original row as a tuple and will return the real result row. This
way, you can implement more advanced ways of returning results, such
@@ -341,7 +341,7 @@ module.
% XXX what's a db_row-based solution?
\end{memberdesc}
-\begin{memberdesc}{text_factory}
+\begin{memberdesc}[Connection]{text_factory}
Using this attribute you can control what objects are returned for the
TEXT data type. By default, this attribute is set to \class{unicode} and
the \module{sqlite3} module will return Unicode objects for TEXT. If you want to return
@@ -359,7 +359,7 @@ module.
\verbatiminput{sqlite3/text_factory.py}
\end{memberdesc}
-\begin{memberdesc}{total_changes}
+\begin{memberdesc}[Connection]{total_changes}
Returns the total number of database rows that have been modified, inserted,
or deleted since the database connection was opened.
\end{memberdesc}
@@ -372,7 +372,7 @@ module.
A \class{Cursor} instance has the following attributes and methods:
-\begin{methoddesc}{execute}{sql, \optional{parameters}}
+\begin{methoddesc}[Cursor]{execute}{sql, \optional{parameters}}
Executes a SQL statement. The SQL statement may be parametrized (i. e.
placeholders instead of SQL literals). The \module{sqlite3} module supports two kinds of
@@ -394,7 +394,7 @@ This example shows how to use the named style:
\end{methoddesc}
-\begin{methoddesc}{executemany}{sql, seq_of_parameters}
+\begin{methoddesc}[Cursor]{executemany}{sql, seq_of_parameters}
Executes a SQL command against all parameter sequences or mappings found in the
sequence \var{sql}. The \module{sqlite3} module also allows
using an iterator yielding parameters instead of a sequence.
@@ -406,7 +406,7 @@ Here's a shorter example using a generator:
\verbatiminput{sqlite3/executemany_2.py}
\end{methoddesc}
-\begin{methoddesc}{executescript}{sql_script}
+\begin{methoddesc}[Cursor]{executescript}{sql_script}
This is a nonstandard convenience method for executing multiple SQL statements
at once. It issues a COMMIT statement first, then executes the SQL script it
@@ -419,7 +419,7 @@ Example:
\verbatiminput{sqlite3/executescript.py}
\end{methoddesc}
-\begin{memberdesc}{rowcount}
+\begin{memberdesc}[Cursor]{rowcount}
Although the \class{Cursor} class of the \module{sqlite3} module implements this
attribute, the database engine's own support for the determination of "rows
affected"/"rows selected" is quirky.
diff --git a/Doc/lib/libstdtypes.tex b/Doc/lib/libstdtypes.tex
index 66cc476..0c45f18 100644
--- a/Doc/lib/libstdtypes.tex
+++ b/Doc/lib/libstdtypes.tex
@@ -559,25 +559,25 @@ linear concatenation performance across versions and implementations.
These are the string methods which both 8-bit strings and Unicode
objects support:
-\begin{methoddesc}[string]{capitalize}{}
+\begin{methoddesc}[str]{capitalize}{}
Return a copy of the string with only its first character capitalized.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{center}{width\optional{, fillchar}}
+\begin{methoddesc}[str]{center}{width\optional{, fillchar}}
Return centered in a string of length \var{width}. Padding is done
using the specified \var{fillchar} (default is a space).
\versionchanged[Support for the \var{fillchar} argument]{2.4}
\end{methoddesc}
-\begin{methoddesc}[string]{count}{sub\optional{, start\optional{, end}}}
+\begin{methoddesc}[str]{count}{sub\optional{, start\optional{, end}}}
Return the number of occurrences of substring \var{sub} in string
S\code{[\var{start}:\var{end}]}. Optional arguments \var{start} and
\var{end} are interpreted as in slice notation.
\end{methoddesc}
-\begin{methoddesc}[string]{decode}{\optional{encoding\optional{, errors}}}
+\begin{methoddesc}[str]{decode}{\optional{encoding\optional{, errors}}}
Decodes the string using the codec registered for \var{encoding}.
\var{encoding} defaults to the default string encoding. \var{errors}
may be given to set a different error handling scheme. The default is
@@ -589,7 +589,7 @@ may be given to set a different error handling scheme. The default is
\versionchanged[Support for other error handling schemes added]{2.3}
\end{methoddesc}
-\begin{methoddesc}[string]{encode}{\optional{encoding\optional{,errors}}}
+\begin{methoddesc}[str]{encode}{\optional{encoding\optional{,errors}}}
Return an encoded version of the string. Default encoding is the current
default string encoding. \var{errors} may be given to set a different
error handling scheme. The default for \var{errors} is
@@ -604,7 +604,7 @@ For a list of possible encodings, see section~\ref{standard-encodings}.
\code{'backslashreplace'} and other error handling schemes added]{2.3}
\end{methoddesc}
-\begin{methoddesc}[string]{endswith}{suffix\optional{, start\optional{, end}}}
+\begin{methoddesc}[str]{endswith}{suffix\optional{, start\optional{, end}}}
Return \code{True} if the string ends with the specified \var{suffix},
otherwise return \code{False}. \var{suffix} can also be a tuple of
suffixes to look for. With optional \var{start}, test beginning at
@@ -613,13 +613,13 @@ that position. With optional \var{end}, stop comparing at that position.
\versionchanged[Accept tuples as \var{suffix}]{2.5}
\end{methoddesc}
-\begin{methoddesc}[string]{expandtabs}{\optional{tabsize}}
+\begin{methoddesc}[str]{expandtabs}{\optional{tabsize}}
Return a copy of the string where all tab characters are expanded
using spaces. If \var{tabsize} is not given, a tab size of \code{8}
characters is assumed.
\end{methoddesc}
-\begin{methoddesc}[string]{find}{sub\optional{, start\optional{, end}}}
+\begin{methoddesc}[str]{find}{sub\optional{, start\optional{, end}}}
Return the lowest index in the string where substring \var{sub} is
found, such that \var{sub} is contained in the range [\var{start},
\var{end}]. Optional arguments \var{start} and \var{end} are
@@ -627,47 +627,47 @@ interpreted as in slice notation. Return \code{-1} if \var{sub} is
not found.
\end{methoddesc}
-\begin{methoddesc}[string]{index}{sub\optional{, start\optional{, end}}}
+\begin{methoddesc}[str]{index}{sub\optional{, start\optional{, end}}}
Like \method{find()}, but raise \exception{ValueError} when the
substring is not found.
\end{methoddesc}
-\begin{methoddesc}[string]{isalnum}{}
+\begin{methoddesc}[str]{isalnum}{}
Return true if all characters in the string are alphanumeric and there
is at least one character, false otherwise.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{isalpha}{}
+\begin{methoddesc}[str]{isalpha}{}
Return true if all characters in the string are alphabetic and there
is at least one character, false otherwise.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{isdigit}{}
+\begin{methoddesc}[str]{isdigit}{}
Return true if all characters in the string are digits and there
is at least one character, false otherwise.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{islower}{}
+\begin{methoddesc}[str]{islower}{}
Return true if all cased characters in the string are lowercase and
there is at least one cased character, false otherwise.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{isspace}{}
+\begin{methoddesc}[str]{isspace}{}
Return true if there are only whitespace characters in the string and
there is at least one character, false otherwise.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{istitle}{}
+\begin{methoddesc}[str]{istitle}{}
Return true if the string is a titlecased string and there is at least one
character, for example uppercase characters may only follow uncased
characters and lowercase characters only cased ones. Return false
@@ -676,20 +676,20 @@ otherwise.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{isupper}{}
+\begin{methoddesc}[str]{isupper}{}
Return true if all cased characters in the string are uppercase and
there is at least one cased character, false otherwise.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{join}{seq}
+\begin{methoddesc}[str]{join}{seq}
Return a string which is the concatenation of the strings in the
sequence \var{seq}. The separator between elements is the string
providing this method.
\end{methoddesc}
-\begin{methoddesc}[string]{ljust}{width\optional{, fillchar}}
+\begin{methoddesc}[str]{ljust}{width\optional{, fillchar}}
Return the string left justified in a string of length \var{width}.
Padding is done using the specified \var{fillchar} (default is a
space). The original string is returned if
@@ -697,13 +697,13 @@ space). The original string is returned if
\versionchanged[Support for the \var{fillchar} argument]{2.4}
\end{methoddesc}
-\begin{methoddesc}[string]{lower}{}
+\begin{methoddesc}[str]{lower}{}
Return a copy of the string converted to lowercase.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{lstrip}{\optional{chars}}
+\begin{methoddesc}[str]{lstrip}{\optional{chars}}
Return a copy of the string with leading characters removed. The
\var{chars} argument is a string specifying the set of characters
to be removed. If omitted or \code{None}, the \var{chars} argument
@@ -718,7 +718,7 @@ a prefix; rather, all combinations of its values are stripped:
\versionchanged[Support for the \var{chars} argument]{2.2.2}
\end{methoddesc}
-\begin{methoddesc}[string]{partition}{sep}
+\begin{methoddesc}[str]{partition}{sep}
Split the string at the first occurrence of \var{sep}, and return
a 3-tuple containing the part before the separator, the separator
itself, and the part after the separator. If the separator is not
@@ -727,26 +727,26 @@ two empty strings.
\versionadded{2.5}
\end{methoddesc}
-\begin{methoddesc}[string]{replace}{old, new\optional{, count}}
+\begin{methoddesc}[str]{replace}{old, new\optional{, count}}
Return a copy of the string with all occurrences of substring
\var{old} replaced by \var{new}. If the optional argument
\var{count} is given, only the first \var{count} occurrences are
replaced.
\end{methoddesc}
-\begin{methoddesc}[string]{rfind}{sub \optional{,start \optional{,end}}}
+\begin{methoddesc}[str]{rfind}{sub \optional{,start \optional{,end}}}
Return the highest index in the string where substring \var{sub} is
found, such that \var{sub} is contained within s[start,end]. Optional
arguments \var{start} and \var{end} are interpreted as in slice
notation. Return \code{-1} on failure.
\end{methoddesc}
-\begin{methoddesc}[string]{rindex}{sub\optional{, start\optional{, end}}}
+\begin{methoddesc}[str]{rindex}{sub\optional{, start\optional{, end}}}
Like \method{rfind()} but raises \exception{ValueError} when the
substring \var{sub} is not found.
\end{methoddesc}
-\begin{methoddesc}[string]{rjust}{width\optional{, fillchar}}
+\begin{methoddesc}[str]{rjust}{width\optional{, fillchar}}
Return the string right justified in a string of length \var{width}.
Padding is done using the specified \var{fillchar} (default is a space).
The original string is returned if
@@ -754,7 +754,7 @@ The original string is returned if
\versionchanged[Support for the \var{fillchar} argument]{2.4}
\end{methoddesc}
-\begin{methoddesc}[string]{rpartition}{sep}
+\begin{methoddesc}[str]{rpartition}{sep}
Split the string at the last occurrence of \var{sep}, and return
a 3-tuple containing the part before the separator, the separator
itself, and the part after the separator. If the separator is not
@@ -763,7 +763,7 @@ the string itself.
\versionadded{2.5}
\end{methoddesc}
-\begin{methoddesc}[string]{rsplit}{\optional{sep \optional{,maxsplit}}}
+\begin{methoddesc}[str]{rsplit}{\optional{sep \optional{,maxsplit}}}
Return a list of the words in the string, using \var{sep} as the
delimiter string. If \var{maxsplit} is given, at most \var{maxsplit}
splits are done, the \emph{rightmost} ones. If \var{sep} is not specified
@@ -773,7 +773,7 @@ is described in detail below.
\versionadded{2.4}
\end{methoddesc}
-\begin{methoddesc}[string]{rstrip}{\optional{chars}}
+\begin{methoddesc}[str]{rstrip}{\optional{chars}}
Return a copy of the string with trailing characters removed. The
\var{chars} argument is a string specifying the set of characters
to be removed. If omitted or \code{None}, the \var{chars} argument
@@ -788,7 +788,7 @@ a suffix; rather, all combinations of its values are stripped:
\versionchanged[Support for the \var{chars} argument]{2.2.2}
\end{methoddesc}
-\begin{methoddesc}[string]{split}{\optional{sep \optional{,maxsplit}}}
+\begin{methoddesc}[str]{split}{\optional{sep \optional{,maxsplit}}}
Return a list of the words in the string, using \var{sep} as the
delimiter string. If \var{maxsplit} is given, at most \var{maxsplit}
splits are done. (thus, the list will have at most \code{\var{maxsplit}+1}
@@ -811,13 +811,13 @@ Splitting an empty string or a string consisting of just whitespace
returns an empty list.
\end{methoddesc}
-\begin{methoddesc}[string]{splitlines}{\optional{keepends}}
+\begin{methoddesc}[str]{splitlines}{\optional{keepends}}
Return a list of the lines in the string, breaking at line
boundaries. Line breaks are not included in the resulting list unless
\var{keepends} is given and true.
\end{methoddesc}
-\begin{methoddesc}[string]{startswith}{prefix\optional{,
+\begin{methoddesc}[str]{startswith}{prefix\optional{,
start\optional{, end}}}
Return \code{True} if string starts with the \var{prefix}, otherwise
return \code{False}. \var{prefix} can also be a tuple of
@@ -828,7 +828,7 @@ position.
\versionchanged[Accept tuples as \var{prefix}]{2.5}
\end{methoddesc}
-\begin{methoddesc}[string]{strip}{\optional{chars}}
+\begin{methoddesc}[str]{strip}{\optional{chars}}
Return a copy of the string with the leading and trailing characters
removed. The \var{chars} argument is a string specifying the set of
characters to be removed. If omitted or \code{None}, the \var{chars}
@@ -843,21 +843,21 @@ a prefix or suffix; rather, all combinations of its values are stripped:
\versionchanged[Support for the \var{chars} argument]{2.2.2}
\end{methoddesc}
-\begin{methoddesc}[string]{swapcase}{}
+\begin{methoddesc}[str]{swapcase}{}
Return a copy of the string with uppercase characters converted to
lowercase and vice versa.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{title}{}
+\begin{methoddesc}[str]{title}{}
Return a titlecased version of the string: words start with uppercase
characters, all remaining cased characters are lowercase.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{translate}{table\optional{, deletechars}}
+\begin{methoddesc}[str]{translate}{table\optional{, deletechars}}
Return a copy of the string where all characters occurring in the
optional argument \var{deletechars} are removed, and the remaining
characters have been mapped through the given translation table, which
@@ -865,6 +865,13 @@ must be a string of length 256.
You can use the \function{maketrans()} helper function in the
\refmodule{string} module to create a translation table.
+For string objects, set the \var{table} argument to \code{None}
+for translations that only delete characters:
+\begin{verbatim}
+ >>> 'read this short text'.translate(None, 'aeiou')
+ 'rd ths shrt txt'
+\end{verbatim}
+\versionadded[Support for a \code{None} \var{table} argument]{2.6}
For Unicode objects, the \method{translate()} method does not
accept the optional \var{deletechars} argument. Instead, it
@@ -877,13 +884,13 @@ character mapping codec using the \refmodule{codecs} module (see
\module{encodings.cp1251} for an example).
\end{methoddesc}
-\begin{methoddesc}[string]{upper}{}
+\begin{methoddesc}[str]{upper}{}
Return a copy of the string converted to uppercase.
For 8-bit strings, this method is locale-dependent.
\end{methoddesc}
-\begin{methoddesc}[string]{zfill}{width}
+\begin{methoddesc}[str]{zfill}{width}
Return the numeric string left filled with zeros in a string
of length \var{width}. The original string is returned if
\var{width} is less than \code{len(\var{s})}.
@@ -1592,14 +1599,15 @@ A file object is its own iterator, for example \code{iter(\var{f})} returns
iterator, typically in a \keyword{for} loop (for example,
\code{for line in f: print line}), the \method{__next__()} method is
called repeatedly. This method returns the next input line, or raises
-\exception{StopIteration} when \EOF{} is hit. In order to make a
-\keyword{for} loop the most efficient way of looping over the lines of
-a file (a very common operation), the \method{__next__()} method uses a
-hidden read-ahead buffer. As a consequence of using a read-ahead
-buffer, combining \method{__next__()} with other file methods (like
-\method{readline()}) does not work right. However, using
-\method{seek()} to reposition the file to an absolute position will
-flush the read-ahead buffer.
+\exception{StopIteration} when \EOF{} is hit when the file is open for
+reading (behavior is undefined when the file is open for writing). In
+order to make a \keyword{for} loop the most efficient way of looping
+over the lines of a file (a very common operation), the
+\method{__next__()} method uses a hidden read-ahead buffer. As a
+consequence of using a read-ahead buffer, combining \method{__next__()}
+with other file methods (like \method{readline()}) does not work
+right. However, using \method{seek()} to reposition the file to an
+absolute position will flush the read-ahead buffer.
\versionadded{2.3}
\end{methoddesc}
diff --git a/Doc/lib/libstring.tex b/Doc/lib/libstring.tex
index bc1649f..055ac0c 100644
--- a/Doc/lib/libstring.tex
+++ b/Doc/lib/libstring.tex
@@ -419,7 +419,8 @@ parameter cannot be passed in earlier 2.2 versions]{2.2.3}
Delete all characters from \var{s} that are in \var{deletechars} (if
present), and then translate the characters using \var{table}, which
must be a 256-character string giving the translation for each
- character value, indexed by its ordinal.
+ character value, indexed by its ordinal. If \var{table} is \code{None},
+ then only the character deletion step is performed.
\end{funcdesc}
\begin{funcdesc}{upper}{s}
diff --git a/Doc/lib/libsubprocess.tex b/Doc/lib/libsubprocess.tex
index cb30974..4a57350 100644
--- a/Doc/lib/libsubprocess.tex
+++ b/Doc/lib/libsubprocess.tex
@@ -176,16 +176,16 @@ metacharacters, can safely be passed to child processes.
Instances of the \class{Popen} class have the following methods:
-\begin{methoddesc}{poll}{}
+\begin{methoddesc}[Popen]{poll}{}
Check if child process has terminated. Returns returncode
attribute.
\end{methoddesc}
-\begin{methoddesc}{wait}{}
+\begin{methoddesc}[Popen]{wait}{}
Wait for child process to terminate. Returns returncode attribute.
\end{methoddesc}
-\begin{methoddesc}{communicate}{input=None}
+\begin{methoddesc}[Popen]{communicate}{input=None}
Interact with process: Send data to stdin. Read data from stdout and
stderr, until end-of-file is reached. Wait for process to terminate.
The optional \var{input} argument should be a string to be sent to the
@@ -199,29 +199,29 @@ if the data size is large or unlimited.}
The following attributes are also available:
-\begin{memberdesc}{stdin}
+\begin{memberdesc}[Popen]{stdin}
If the \var{stdin} argument is \code{PIPE}, this attribute is a file
object that provides input to the child process. Otherwise, it is
\code{None}.
\end{memberdesc}
-\begin{memberdesc}{stdout}
+\begin{memberdesc}[Popen]{stdout}
If the \var{stdout} argument is \code{PIPE}, this attribute is a file
object that provides output from the child process. Otherwise, it is
\code{None}.
\end{memberdesc}
-\begin{memberdesc}{stderr}
+\begin{memberdesc}[Popen]{stderr}
If the \var{stderr} argument is \code{PIPE}, this attribute is file
object that provides error output from the child process. Otherwise,
it is \code{None}.
\end{memberdesc}
-\begin{memberdesc}{pid}
+\begin{memberdesc}[Popen]{pid}
The process ID of the child process.
\end{memberdesc}
-\begin{memberdesc}{returncode}
+\begin{memberdesc}[Popen]{returncode}
The child return code. A \code{None} value indicates that the process
hasn't terminated yet. A negative value -N indicates that the child
was terminated by signal N (\UNIX{} only).
diff --git a/Doc/lib/libsun.tex b/Doc/lib/libsun.tex
index 1472509..8fcfb6a 100644
--- a/Doc/lib/libsun.tex
+++ b/Doc/lib/libsun.tex
@@ -3,3 +3,5 @@
The modules described in this chapter provide interfaces to features
that are unique to SunOS 5 (also known as Solaris version 2).
+
+\localmoduletable
diff --git a/Doc/lib/libsys.tex b/Doc/lib/libsys.tex
index ac161d9..1284668 100644
--- a/Doc/lib/libsys.tex
+++ b/Doc/lib/libsys.tex
@@ -15,8 +15,8 @@ It is always available.
whether this is a full pathname or not). If the command was
executed using the \programopt{-c} command line option to the
interpreter, \code{argv[0]} is set to the string \code{'-c'}. If no
- script name was passed to the Python interpreter, \code{argv} has
- zero length.
+ script name was passed to the Python interpreter, \code{argv[0]} is
+ the empty string.
\end{datadesc}
\begin{datadesc}{byteorder}
diff --git a/Doc/lib/libtarfile.tex b/Doc/lib/libtarfile.tex
index 96f835f..73c35ed 100644
--- a/Doc/lib/libtarfile.tex
+++ b/Doc/lib/libtarfile.tex
@@ -12,21 +12,24 @@ Some facts and figures:
\begin{itemize}
\item reads and writes \module{gzip} and \module{bzip2} compressed archives.
-\item creates \POSIX{} 1003.1-1990 compliant or GNU tar compatible archives.
-\item reads GNU tar extensions \emph{longname}, \emph{longlink} and
- \emph{sparse}.
-\item stores pathnames of unlimited length using GNU tar extensions.
+\item read/write support for the \POSIX{}.1-1988 (ustar) format.
+\item read/write support for the GNU tar format including \emph{longname} and
+ \emph{longlink} extensions, read-only support for the \emph{sparse}
+ extension.
+\item read/write support for the \POSIX{}.1-2001 (pax) format.
+ \versionadded{2.6}
\item handles directories, regular files, hardlinks, symbolic links, fifos,
character devices and block devices and is able to acquire and
restore file information like timestamp, access permissions and owner.
\item can handle tape devices.
\end{itemize}
-\begin{funcdesc}{open}{\optional{name\optional{, mode
- \optional{, fileobj\optional{, bufsize}}}}}
+\begin{funcdesc}{open}{name\optional{, mode\optional{,
+ fileobj\optional{, bufsize}}}, **kwargs}
Return a \class{TarFile} object for the pathname \var{name}.
- For detailed information on \class{TarFile} objects,
- see \citetitle{TarFile Objects} (section \ref{tarfile-objects}).
+ For detailed information on \class{TarFile} objects and the keyword
+ arguments that are allowed, see \citetitle{TarFile Objects}
+ (section \ref{tarfile-objects}).
\var{mode} has to be a string of the form \code{'filemode[:compression]'},
it defaults to \code{'r'}. Here is a full list of mode combinations:
@@ -130,6 +133,31 @@ Some facts and figures:
\versionadded{2.6}
\end{excdesc}
+\begin{datadesc}{USTAR_FORMAT}
+ \POSIX{}.1-1988 (ustar) format. It supports filenames up to a length of
+ at best 256 characters and linknames up to 100 characters. The maximum
+ file size is 8 gigabytes. This is an old and limited but widely
+ supported format.
+\end{datadesc}
+
+\begin{datadesc}{GNU_FORMAT}
+ GNU tar format. It supports arbitrarily long filenames and linknames and
+ files bigger than 8 gigabytes. It is the defacto standard on GNU/Linux
+ systems.
+\end{datadesc}
+
+\begin{datadesc}{PAX_FORMAT}
+ \POSIX{}.1-2001 (pax) format. It is the most flexible format with
+ virtually no limits. It supports long filenames and linknames, large files
+ and stores pathnames in a portable way. However, not all tar
+ implementations today are able to handle pax archives properly.
+\end{datadesc}
+
+\begin{datadesc}{DEFAULT_FORMAT}
+ The default format for creating archives. This is currently
+ \constant{GNU_FORMAT}.
+\end{datadesc}
+
\begin{seealso}
\seemodule{zipfile}{Documentation of the \refmodule{zipfile}
standard module.}
@@ -152,12 +180,21 @@ tar archive several times. Each archive member is represented by a
\class{TarInfo} object, see \citetitle{TarInfo Objects} (section
\ref{tarinfo-objects}) for details.
-\begin{classdesc}{TarFile}{\optional{name
- \optional{, mode\optional{, fileobj}}}}
- Open an \emph{(uncompressed)} tar archive \var{name}.
+\begin{classdesc}{TarFile}{name=None, mode='r', fileobj=None,
+ format=DEFAULT_FORMAT, tarinfo=TarInfo, dereference=False,
+ ignore_zeros=False, encoding=None, pax_headers=None, debug=0,
+ errorlevel=0}
+
+ All following arguments are optional and can be accessed as instance
+ attributes as well.
+
+ \var{name} is the pathname of the archive. It can be omitted if
+ \var{fileobj} is given. In this case, the file object's \member{name}
+ attribute is used if it exists.
+
\var{mode} is either \code{'r'} to read from an existing archive,
\code{'a'} to append data to an existing file or \code{'w'} to create a new
- file overwriting an existing one. \var{mode} defaults to \code{'r'}.
+ file overwriting an existing one.
If \var{fileobj} is given, it is used for reading or writing data.
If it can be determined, \var{mode} is overridden by \var{fileobj}'s mode.
@@ -165,6 +202,48 @@ tar archive several times. Each archive member is represented by a
\begin{notice}
\var{fileobj} is not closed, when \class{TarFile} is closed.
\end{notice}
+
+ \var{format} controls the archive format. It must be one of the constants
+ \constant{USTAR_FORMAT}, \constant{GNU_FORMAT} or \constant{PAX_FORMAT}
+ that are defined at module level.
+ \versionadded{2.6}
+
+ The \var{tarinfo} argument can be used to replace the default
+ \class{TarInfo} class with a different one.
+ \versionadded{2.6}
+
+ If \var{dereference} is \code{False}, add symbolic and hard links to the
+ archive. If it is \code{True}, add the content of the target files to the
+ archive. This has no effect on systems that do not support symbolic links.
+
+ If \var{ignore_zeros} is \code{False}, treat an empty block as the end of
+ the archive. If it is \var{True}, skip empty (and invalid) blocks and try
+ to get as many members as possible. This is only useful for reading
+ concatenated or damaged archives.
+
+ \var{debug} can be set from \code{0} (no debug messages) up to \code{3}
+ (all debug messages). The messages are written to \code{sys.stderr}.
+
+ If \var{errorlevel} is \code{0}, all errors are ignored when using
+ \method{extract()}. Nevertheless, they appear as error messages in the
+ debug output, when debugging is enabled. If \code{1}, all \emph{fatal}
+ errors are raised as \exception{OSError} or \exception{IOError} exceptions.
+ If \code{2}, all \emph{non-fatal} errors are raised as \exception{TarError}
+ exceptions as well.
+
+ The \var{encoding} argument defines the local character encoding. It
+ defaults to the value from \function{sys.getfilesystemencoding()} or if
+ that is \code{None} to \code{"ascii"}. \var{encoding} is used only in
+ connection with the pax format which stores text data in \emph{UTF-8}. If
+ it is not set correctly, character conversion will fail with a
+ \exception{UnicodeError}.
+ \versionadded{2.6}
+
+ The \var{pax_headers} argument must be a dictionary whose elements are
+ either unicode objects, numbers or strings that can be decoded to unicode
+ using \var{encoding}. This information will be added to the archive as a
+ pax global header.
+ \versionadded{2.6}
\end{classdesc}
\begin{methoddesc}{open}{...}
@@ -279,43 +358,11 @@ tar archive several times. Each archive member is represented by a
\end{methoddesc}
\begin{memberdesc}{posix}
- If true, create a \POSIX{} 1003.1-1990 compliant archive. GNU
- extensions are not used, because they are not part of the \POSIX{}
- standard. This limits the length of filenames to at most 256,
- link names to 100 characters and the maximum file size to 8
- gigabytes. A \exception{ValueError} is raised if a file exceeds
- this limit. If false, create a GNU tar compatible archive. It
- will not be \POSIX{} compliant, but can store files without any
- of the above restrictions.
+ Setting this to \constant{True} is equivalent to setting the
+ \member{format} attribute to \constant{USTAR_FORMAT},
+ \constant{False} is equivalent to \constant{GNU_FORMAT}.
\versionchanged[\var{posix} defaults to \constant{False}]{2.4}
-\end{memberdesc}
-
-\begin{memberdesc}{dereference}
- If false, add symbolic and hard links to archive. If true, add the
- content of the target files to the archive. This has no effect on
- systems that do not support symbolic links.
-\end{memberdesc}
-
-\begin{memberdesc}{ignore_zeros}
- If false, treat an empty block as the end of the archive. If true,
- skip empty (and invalid) blocks and try to get as many members as
- possible. This is only useful for concatenated or damaged
- archives.
-\end{memberdesc}
-
-\begin{memberdesc}{debug=0}
- To be set from \code{0} (no debug messages; the default) up to
- \code{3} (all debug messages). The messages are written to
- \code{sys.stderr}.
-\end{memberdesc}
-
-\begin{memberdesc}{errorlevel}
- If \code{0} (the default), all errors are ignored when using
- \method{extract()}. Nevertheless, they appear as error messages
- in the debug output, when debugging is enabled. If \code{1}, all
- \emph{fatal} errors are raised as \exception{OSError} or
- \exception{IOError} exceptions. If \code{2}, all \emph{non-fatal}
- errors are raised as \exception{TarError} exceptions as well.
+ \deprecated{2.6}{Use the \member{format} attribute instead.}
\end{memberdesc}
%-----------------
@@ -343,12 +390,16 @@ the file's data itself.
invalid.]{2.6}
\end{methoddesc}
-\begin{methoddesc}{tobuf}{posix}
- Create a string buffer from a \class{TarInfo} object.
- See \class{TarFile}'s \member{posix} attribute for information
- on the \var{posix} argument. It defaults to \constant{False}.
+\begin{methoddesc}{fromtarfile}{tarfile}
+ Read the next member from the \class{TarFile} object \var{tarfile} and
+ return it as a \class{TarInfo} object.
+ \versionadded{2.6}
+\end{methoddesc}
- \versionadded[The \var{posix} parameter]{2.5}
+\begin{methoddesc}{tobuf}{\optional{format}}
+ Create a string buffer from a \class{TarInfo} object. See
+ \class{TarFile}'s \member{format} argument for information.
+ \versionchanged[The \var{format} parameter]{2.6}
\end{methoddesc}
A \code{TarInfo} object has the following public data attributes:
diff --git a/Doc/lib/libtelnetlib.tex b/Doc/lib/libtelnetlib.tex
index b8dfeee..269ee9b 100644
--- a/Doc/lib/libtelnetlib.tex
+++ b/Doc/lib/libtelnetlib.tex
@@ -23,13 +23,16 @@ Mark), BRK (Break), IP (Interrupt process), AO (Abort output), AYT
SB (Subnegotiation Begin).
-\begin{classdesc}{Telnet}{\optional{host\optional{, port}}}
+\begin{classdesc}{Telnet}{\optional{host\optional{, port\optional{, timeout}}}}
\class{Telnet} represents a connection to a Telnet server. The
instance is initially not connected by default; the \method{open()}
method must be used to establish a connection. Alternatively, the
host name and optional port number can be passed to the constructor,
to, in which case the connection to the server will be established
before the constructor returns.
+The optional \var{timeout} parameter specifies a timeout in seconds for the
+connection attempt (if not specified, or passed as None, the global default
+timeout setting will be used).
Do not reopen an already connected instance.
@@ -52,7 +55,7 @@ individual descriptions below.
\class{Telnet} instances have the following methods:
-\begin{methoddesc}{read_until}{expected\optional{, timeout}}
+\begin{methoddesc}[Telnet]{read_until}{expected\optional{, timeout}}
Read until a given string, \var{expected}, is encountered or until
\var{timeout} seconds have passed.
@@ -61,17 +64,17 @@ possibly the empty string. Raise \exception{EOFError} if the connection
is closed and no cooked data is available.
\end{methoddesc}
-\begin{methoddesc}{read_all}{}
+\begin{methoddesc}[Telnet]{read_all}{}
Read all data until \EOF; block until connection closed.
\end{methoddesc}
-\begin{methoddesc}{read_some}{}
+\begin{methoddesc}[Telnet]{read_some}{}
Read at least one byte of cooked data unless \EOF{} is hit.
Return \code{''} if \EOF{} is hit. Block if no data is immediately
available.
\end{methoddesc}
-\begin{methoddesc}{read_very_eager}{}
+\begin{methoddesc}[Telnet]{read_very_eager}{}
Read everything that can be without blocking in I/O (eager).
Raise \exception{EOFError} if connection closed and no cooked data
@@ -79,7 +82,7 @@ available. Return \code{''} if no cooked data available otherwise.
Do not block unless in the midst of an IAC sequence.
\end{methoddesc}
-\begin{methoddesc}{read_eager}{}
+\begin{methoddesc}[Telnet]{read_eager}{}
Read readily available data.
Raise \exception{EOFError} if connection closed and no cooked data
@@ -87,7 +90,7 @@ available. Return \code{''} if no cooked data available otherwise.
Do not block unless in the midst of an IAC sequence.
\end{methoddesc}
-\begin{methoddesc}{read_lazy}{}
+\begin{methoddesc}[Telnet]{read_lazy}{}
Process and return data already in the queues (lazy).
Raise \exception{EOFError} if connection closed and no data available.
@@ -95,7 +98,7 @@ Return \code{''} if no cooked data available otherwise. Do not block
unless in the midst of an IAC sequence.
\end{methoddesc}
-\begin{methoddesc}{read_very_lazy}{}
+\begin{methoddesc}[Telnet]{read_very_lazy}{}
Return any data available in the cooked queue (very lazy).
Raise \exception{EOFError} if connection closed and no data available.
@@ -103,7 +106,7 @@ Return \code{''} if no cooked data available otherwise. This method
never blocks.
\end{methoddesc}
-\begin{methoddesc}{read_sb_data}{}
+\begin{methoddesc}[Telnet]{read_sb_data}{}
Return the data collected between a SB/SE pair (suboption begin/end).
The callback should access these data when it was invoked with a
\code{SE} command. This method never blocks.
@@ -111,52 +114,55 @@ The callback should access these data when it was invoked with a
\versionadded{2.3}
\end{methoddesc}
-\begin{methoddesc}{open}{host\optional{, port}}
+\begin{methoddesc}[Telnet]{open}{host\optional{, port\optional{, timeout}}}
Connect to a host.
The optional second argument is the port number, which
defaults to the standard Telnet port (23).
+The optional \var{timeout} parameter specifies a timeout in seconds for the
+connection attempt (if not specified, or passed as None, the global default
+timeout setting will be used).
Do not try to reopen an already connected instance.
\end{methoddesc}
-\begin{methoddesc}{msg}{msg\optional{, *args}}
+\begin{methoddesc}[Telnet]{msg}{msg\optional{, *args}}
Print a debug message when the debug level is \code{>} 0.
If extra arguments are present, they are substituted in the
message using the standard string formatting operator.
\end{methoddesc}
-\begin{methoddesc}{set_debuglevel}{debuglevel}
+\begin{methoddesc}[Telnet]{set_debuglevel}{debuglevel}
Set the debug level. The higher the value of \var{debuglevel}, the
more debug output you get (on \code{sys.stdout}).
\end{methoddesc}
-\begin{methoddesc}{close}{}
+\begin{methoddesc}[Telnet]{close}{}
Close the connection.
\end{methoddesc}
-\begin{methoddesc}{get_socket}{}
+\begin{methoddesc}[Telnet]{get_socket}{}
Return the socket object used internally.
\end{methoddesc}
-\begin{methoddesc}{fileno}{}
+\begin{methoddesc}[Telnet]{fileno}{}
Return the file descriptor of the socket object used internally.
\end{methoddesc}
-\begin{methoddesc}{write}{buffer}
+\begin{methoddesc}[Telnet]{write}{buffer}
Write a string to the socket, doubling any IAC characters.
This can block if the connection is blocked. May raise
\exception{socket.error} if the connection is closed.
\end{methoddesc}
-\begin{methoddesc}{interact}{}
+\begin{methoddesc}[Telnet]{interact}{}
Interaction function, emulates a very dumb Telnet client.
\end{methoddesc}
-\begin{methoddesc}{mt_interact}{}
+\begin{methoddesc}[Telnet]{mt_interact}{}
Multithreaded version of \method{interact()}.
\end{methoddesc}
-\begin{methoddesc}{expect}{list\optional{, timeout}}
+\begin{methoddesc}[Telnet]{expect}{list\optional{, timeout}}
Read until one from a list of a regular expressions matches.
The first argument is a list of regular expressions, either
@@ -178,7 +184,7 @@ or if more than one expression can match the same input, the
results are indeterministic, and may depend on the I/O timing.
\end{methoddesc}
-\begin{methoddesc}{set_option_negotiation_callback}{callback}
+\begin{methoddesc}[Telnet]{set_option_negotiation_callback}{callback}
Each time a telnet option is read on the input flow, this
\var{callback} (if set) is called with the following parameters :
callback(telnet socket, command (DO/DONT/WILL/WONT), option). No other
diff --git a/Doc/lib/libtempfile.tex b/Doc/lib/libtempfile.tex
index 9b4d848..8bc559e 100644
--- a/Doc/lib/libtempfile.tex
+++ b/Doc/lib/libtempfile.tex
@@ -53,7 +53,7 @@ The \var{dir}, \var{prefix} and \var{suffix} parameters are passed to
\begin{funcdesc}{NamedTemporaryFile}{\optional{mode=\code{'w+b'}\optional{,
bufsize=\code{-1}\optional{,
suffix\optional{, prefix\optional{,
- dir}}}}}}
+ dir\optional{, delete}}}}}}}
This function operates exactly as \function{TemporaryFile()} does,
except that the file is guaranteed to have a visible name in the file
system (on \UNIX, the directory entry is not unlinked). That name can
@@ -61,7 +61,27 @@ be retrieved from the \member{name} member of the file object. Whether
the name can be used to open the file a second time, while the
named temporary file is still open, varies across platforms (it can
be so used on \UNIX; it cannot on Windows NT or later).
+If \var{delete} is true (the default), the file is deleted as soon as
+it is closed.
\versionadded{2.3}
+\versionadded[The \var{delete} parameter]{2.6}
+\end{funcdesc}
+
+\begin{funcdesc}{SpooledTemporaryFile}{\optional{max\_size=\code{0},
+ \optional{mode=\code{'w+b'}\optional{,
+ bufsize=\code{-1}\optional{,
+ suffix\optional{, prefix\optional{,
+ dir}}}}}}}
+This function operates exactly as \function{TemporaryFile()} does,
+except that data is spooled in memory until the file size exceeds
+\var{max_size}, or until the file's \function{fileno()} method is
+called, at which point the contents are written to disk and operation
+proceeds as with \function{TemporaryFile()}.
+
+The resulting file has one additional method, \function{rollover()},
+which causes the file to roll over to an on-disk file regardless of
+its size.
+\versionadded{2.6}
\end{funcdesc}
\begin{funcdesc}{mkstemp}{\optional{suffix\optional{,
diff --git a/Doc/lib/libtest.tex b/Doc/lib/libtest.tex
index f30b49b..d258089 100644
--- a/Doc/lib/libtest.tex
+++ b/Doc/lib/libtest.tex
@@ -14,11 +14,11 @@ your tests while \module{test.regrtest} drives the testing suite.
Each module in the \module{test} package whose name starts with
\samp{test_} is a testing suite for a specific module or feature.
-All new tests should be written using the \refmodule{unittest} module;
-using \refmodule{unittest} is not required but makes the tests more
-flexible and maintenance of the tests easier. Some older tests are
-written to use \refmodule{doctest} and a ``traditional'' testing
-style; these styles of tests will not be covered.
+All new tests should be written using the \refmodule{unittest} or
+\refmodule{doctest} module. Some older tests are
+written using a ``traditional'' testing style that compares output
+printed to \code{sys.stdout}; this style of test is considered
+deprecated.
\begin{seealso}
\seemodule{unittest}{Writing PyUnit regression tests.}
@@ -29,8 +29,8 @@ style; these styles of tests will not be covered.
\subsection{Writing Unit Tests for the \module{test} package%
\label{writing-tests}}
-It is preferred that tests for the \module{test} package use the
-\refmodule{unittest} module and follow a few guidelines.
+It is preferred that tests that use the \refmodule{unittest} module
+follow a few guidelines.
One is to name the test module by starting it with \samp{test_} and end it with
the name of the module being tested.
The test methods in the test module should start with \samp{test_} and end with
@@ -196,7 +196,9 @@ regression tests.
This module defines the following exceptions:
\begin{excdesc}{TestFailed}
-Exception to be raised when a test fails.
+Exception to be raised when a test fails. This is deprecated in favor
+of \module{unittest}-based tests and \class{unittest.TestCase}'s
+assertion methods.
\end{excdesc}
\begin{excdesc}{TestSkipped}
@@ -273,18 +275,30 @@ filter settings.
Execute \class{unittest.TestCase} subclasses passed to the function.
The function scans the classes for methods starting with the prefix
\samp{test_} and executes the tests individually.
-This is the preferred way to execute tests.
-\end{funcdesc}
-\begin{funcdesc}{run_suite}{suite\optional{, testclass}}
-Execute the \class{unittest.TestSuite} instance \var{suite}.
-The optional argument \var{testclass} accepts one of the test classes in the
-suite so as to print out more detailed information on where the testing suite
-originated from.
+It is also legal to pass strings as parameters; these should be keys in
+\code{sys.modules}. Each associated module will be scanned by
+\code{unittest.TestLoader.loadTestsFromModule()}. This is usually seen in
+the following \function{test_main()} function:
+
+\begin{verbatim}
+def test_main():
+ test_support.run_unittest(__name__)
+\end{verbatim}
+
+This will run all tests defined in the named module.
\end{funcdesc}
The \module{test.test_support} module defines the following classes:
+\begin{classdesc}{TransientResource}{exc\optional{, **kwargs}}
+Create a context manager that raises \class{ResourceDenied} if the specified
+exception type is raised. Any keyword arguments are treated as name/value
+pairs to be compared against any exception raised with the \code{with}
+statement. Only if all pairs match is \class{ResourceDenied} raised.
+\versionadded{2.6}
+\end{classdesc}
+
\begin{classdesc}{EnvironmentVarGuard}{}
Class used to temporarily set or unset environment variables. Instances can be
used as a context manager.
diff --git a/Doc/lib/libtextwrap.tex b/Doc/lib/libtextwrap.tex
index 38f9b03..8ea25a8 100644
--- a/Doc/lib/libtextwrap.tex
+++ b/Doc/lib/libtextwrap.tex
@@ -54,7 +54,7 @@ edge of the display, while still presenting them in the source code
in indented form.
Note that tabs and spaces are both treated as whitespace, but they are
-not equal: the lines \code{" {} hello"} and \code{"\textbackslash{}thello"}
+not equal: the lines \code{" {} hello"} and \code{"\e thello"}
are considered to have no common leading whitespace. (This behaviour is
new in Python 2.5; older versions of this module incorrectly expanded
tabs before searching for common leading whitespace.)
@@ -115,6 +115,13 @@ replaced by a single space, which is \emph{not} the same as tab
expansion.}
\end{memberdesc}
+\begin{memberdesc}{drop_whitespace}
+(default: \code{True}) If true, whitespace that, after wrapping, happens
+to end up at the beginning or end of a line is dropped (leading whitespace
+in the first line is always preserved, though).
+\versionadded[Whitespace was always dropped in earlier versions]{2.6}
+\end{memberdesc}
+
\begin{memberdesc}{initial_indent}
(default: \code{''}) String that will be prepended to the first line
of wrapped output. Counts towards the length of the first line.
diff --git a/Doc/lib/libthreading.tex b/Doc/lib/libthreading.tex
index 0334750..522ea2f 100644
--- a/Doc/lib/libthreading.tex
+++ b/Doc/lib/libthreading.tex
@@ -15,17 +15,16 @@ situations where \module{threading} cannot be used because
This module defines the following functions and objects:
\begin{funcdesc}{activeCount}{}
-Return the number of currently active \class{Thread} objects.
-The returned count is equal to the length of the list returned by
+Return the number of \class{Thread} objects currently alive. The
+returned count is equal to the length of the list returned by
\function{enumerate()}.
-A function that returns the number of currently active threads.
\end{funcdesc}
-\begin{funcdesc}{Condition}{}
+\begin{funcdescni}{Condition}{}
A factory function that returns a new condition variable object.
A condition variable allows one or more threads to wait until they
are notified by another thread.
-\end{funcdesc}
+\end{funcdescni}
\begin{funcdesc}{currentThread}{}
Return the current \class{Thread} object, corresponding to the
@@ -36,18 +35,18 @@ is returned.
\end{funcdesc}
\begin{funcdesc}{enumerate}{}
-Return a list of all currently active \class{Thread} objects.
-The list includes daemonic threads, dummy thread objects created
-by \function{currentThread()}, and the main thread. It excludes terminated
-threads and threads that have not yet been started.
+Return a list of all \class{Thread} objects currently alive. The list
+includes daemonic threads, dummy thread objects created by
+\function{currentThread()}, and the main thread. It excludes
+terminated threads and threads that have not yet been started.
\end{funcdesc}
-\begin{funcdesc}{Event}{}
+\begin{funcdescni}{Event}{}
A factory function that returns a new event object. An event manages
a flag that can be set to true with the \method{set()} method and
reset to false with the \method{clear()} method. The \method{wait()}
method blocks until the flag is true.
-\end{funcdesc}
+\end{funcdescni}
\begin{classdesc*}{local}{}
A class that represents thread-local data. Thread-local data are data
@@ -82,14 +81,14 @@ acquire it again without blocking; the thread must release it once
for each time it has acquired it.
\end{funcdesc}
-\begin{funcdesc}{Semaphore}{\optional{value}}
+\begin{funcdescni}{Semaphore}{\optional{value}}
A factory function that returns a new semaphore object. A
semaphore manages a counter representing the number of \method{release()}
calls minus the number of \method{acquire()} calls, plus an initial value.
The \method{acquire()} method blocks if necessary until it can return
without making the counter negative. If not given, \var{value} defaults to
1.
-\end{funcdesc}
+\end{funcdescni}
\begin{funcdesc}{BoundedSemaphore}{\optional{value}}
A factory function that returns a new bounded semaphore object. A bounded
@@ -100,12 +99,12 @@ semaphore is released too many times it's a sign of a bug. If not given,
\var{value} defaults to 1.
\end{funcdesc}
-\begin{classdesc*}{Thread}{}
+\begin{classdesc*}{Thread}
A class that represents a thread of control. This class can be safely
subclassed in a limited fashion.
\end{classdesc*}
-\begin{classdesc*}{Timer}{}
+\begin{classdesc*}{Timer}
A thread that executes a function after a specified interval has passed.
\end{classdesc*}
@@ -183,7 +182,7 @@ and may vary across implementations.
All methods are executed atomically.
-\begin{methoddesc}{acquire}{\optional{blocking\code{ = 1}}}
+\begin{methoddesc}[Lock]{acquire}{\optional{blocking\code{ = 1}}}
Acquire a lock, blocking or non-blocking.
When invoked without arguments, block until the lock is
@@ -198,7 +197,7 @@ immediately; otherwise, do the same thing as when called
without arguments, and return true.
\end{methoddesc}
-\begin{methoddesc}{release}{}
+\begin{methoddesc}[Lock]{release}{}
Release a lock.
When the lock is locked, reset it to unlocked, and return. If
@@ -228,7 +227,7 @@ the final \method{release()} (the \method{release()} of the outermost
pair) resets the lock to unlocked and allows another thread blocked in
\method{acquire()} to proceed.
-\begin{methoddesc}{acquire}{\optional{blocking\code{ = 1}}}
+\begin{methoddesc}[RLock]{acquire}{\optional{blocking\code{ = 1}}}
Acquire a lock, blocking or non-blocking.
When invoked without arguments: if this thread already owns
@@ -250,7 +249,7 @@ immediately; otherwise, do the same thing as when called
without arguments, and return true.
\end{methoddesc}
-\begin{methoddesc}{release}{}
+\begin{methoddesc}[RLock]{release}{}
Release a lock, decrementing the recursion level. If after the
decrement it is zero, reset the lock to unlocked (not owned by any
thread), and if any other threads are blocked waiting for the lock to
@@ -526,12 +525,9 @@ calling the thread's \method{start()} method. This invokes the
\method{run()} method in a separate thread of control.
Once the thread's activity is started, the thread is considered
-'alive' and 'active' (these concepts are almost, but not quite
-exactly, the same; their definition is intentionally somewhat
-vague). It stops being alive and active when its \method{run()}
-method terminates -- either normally, or by raising an unhandled
-exception. The \method{isAlive()} method tests whether the thread is
-alive.
+'alive'. It stops being alive when its \method{run()} method terminates
+-- either normally, or by raising an unhandled exception. The
+\method{isAlive()} method tests whether the thread is alive.
Other threads can call a thread's \method{join()} method. This blocks
the calling thread until the thread whose \method{join()} method is
@@ -551,14 +547,13 @@ There is a ``main thread'' object; this corresponds to the
initial thread of control in the Python program. It is not a
daemon thread.
-There is the possibility that ``dummy thread objects'' are
-created. These are thread objects corresponding to ``alien
-threads''. These are threads of control started outside the
-threading module, such as directly from C code. Dummy thread objects
-have limited functionality; they are always considered alive,
-active, and daemonic, and cannot be \method{join()}ed. They are never
-deleted, since it is impossible to detect the termination of alien
-threads.
+There is the possibility that ``dummy thread objects'' are created.
+These are thread objects corresponding to ``alien threads'', which
+are threads of control started outside the threading module, such as
+directly from C code. Dummy thread objects have limited
+functionality; they are always considered alive and daemonic, and
+cannot be \method{join()}ed. They are never deleted, since it is
+impossible to detect the termination of alien threads.
\begin{classdesc}{Thread}{group=None, target=None, name=None,
@@ -646,7 +641,8 @@ name. The initial name is set by the constructor.
Return whether the thread is alive.
Roughly, a thread is alive from the moment the \method{start()} method
-returns until its \method{run()} method terminates.
+returns until its \method{run()} method terminates. The module
+function \function{enumerate()} returns a list of all alive threads.
\end{methoddesc}
\begin{methoddesc}{isDaemon}{}
@@ -659,8 +655,8 @@ This must be called before \method{start()} is called.
The initial value is inherited from the creating thread.
-The entire Python program exits when no active non-daemon
-threads are left.
+The entire Python program exits when no alive non-daemon threads are
+left.
\end{methoddesc}
diff --git a/Doc/lib/libtimeit.tex b/Doc/lib/libtimeit.tex
index 2629439..7f38a7e 100644
--- a/Doc/lib/libtimeit.tex
+++ b/Doc/lib/libtimeit.tex
@@ -31,6 +31,13 @@ To measure the execution time of the first statement, use the
\method{timeit()} method. The \method{repeat()} method is a
convenience to call \method{timeit()} multiple times and return a list
of results.
+
+\versionchanged[The \var{stmt} and \var{setup} parameters can now also
+ take objects that are callable without arguments. This
+ will embed calls to them in a timer function that will
+ then be executed by \method{timeit()}. Note that the timing
+ overhead is a little larger in this case because of the
+ extra function calls]{2.6}
\end{classdesc}
\begin{methoddesc}{print_exc}{\optional{file=\constant{None}}}
@@ -97,12 +104,30 @@ measured. If so, GC can be re-enabled as the first statement in the
\end{methoddesc}
+Starting with version 2.6, the module also defines two convenience functions:
+
+\begin{funcdesc}{repeat}{stmt\optional{, setup\optional{, timer\optional{,
+ repeat\code{=3} \optional{, number\code{=1000000}}}}}}
+Create a \class{Timer} instance with the given statement, setup code and timer
+function and run its \method{repeat} method with the given repeat count and
+\var{number} executions.
+\versionadded{2.6}
+\end{funcdesc}
+
+\begin{funcdesc}{timeit}{stmt\optional{, setup\optional{, timer\optional{,
+ number\code{=1000000}}}}}
+Create a \class{Timer} instance with the given statement, setup code and timer
+function and run its \method{timeit} method with \var{number} executions.
+\versionadded{2.6}
+\end{funcdesc}
+
+
\subsection{Command Line Interface}
When called as a program from the command line, the following form is used:
\begin{verbatim}
-python timeit.py [-n N] [-r N] [-s S] [-t] [-c] [-h] [statement ...]
+python -m timeit [-n N] [-r N] [-s S] [-t] [-c] [-h] [statement ...]
\end{verbatim}
where the following options are understood:
diff --git a/Doc/lib/libturtle.tex b/Doc/lib/libturtle.tex
index 6161cd9..fa8f0dd 100644
--- a/Doc/lib/libturtle.tex
+++ b/Doc/lib/libturtle.tex
@@ -261,7 +261,7 @@ The only method which is more powerful as a method is
\function{degrees()}, which takes an optional argument letting
you specify the number of units corresponding to a full circle:
-\begin{methoddesc}{degrees}{\optional{fullcircle}}
+\begin{methoddesc}[Turtle]{degrees}{\optional{fullcircle}}
\var{fullcircle} is by default 360. This can cause the pen to have any
angular units whatever: give \var{fullcircle} 2*$\pi$ for radians, or
400 for gradians.
diff --git a/Doc/lib/libunittest.tex b/Doc/lib/libunittest.tex
index 350abae..fa198c7 100644
--- a/Doc/lib/libunittest.tex
+++ b/Doc/lib/libunittest.tex
@@ -91,7 +91,7 @@ specific class.
\end{seealso}
-\subsection{Basic example \label{minimal-example}}
+\subsection{Basic example \label{unittest-minimal-example}}
The \module{unittest} module provides a rich set of tools for
constructing and running tests. This section demonstrates that a
@@ -290,6 +290,7 @@ Often, many small test cases will use the same fixture. In this case,
we would end up subclassing \class{SimpleWidgetTestCase} into many
small one-method classes such as
\class{DefaultWidgetSizeTestCase}. This is time-consuming and
+
discouraging, so in the same vein as JUnit, \module{unittest} provides
a simpler mechanism:
@@ -540,7 +541,7 @@ easier.}
\begin{funcdesc}{main}{\optional{module\optional{,
defaultTest\optional{, argv\optional{,
- testRunner\optional{, testRunner}}}}}}
+ testRunner\optional{, testLoader}}}}}}
A command-line program that runs a set of tests; this is primarily
for making test modules conveniently executable. The simplest use
for this function is to include the following line at the end of a
@@ -550,6 +551,9 @@ easier.}
if __name__ == '__main__':
unittest.main()
\end{verbatim}
+
+ The \var{testRunner} argument can either be a test runner class or
+ an already created instance of it.
\end{funcdesc}
In some cases, the existing tests may have been written using the
@@ -615,14 +619,14 @@ The test code can use any of the following methods to check for and
report failures.
\begin{methoddesc}[TestCase]{assert_}{expr\optional{, msg}}
-\methodline{failUnless}{expr\optional{, msg}}
+\methodline[TestCase]{failUnless}{expr\optional{, msg}}
Signal a test failure if \var{expr} is false; the explanation for
the error will be \var{msg} if given, otherwise it will be
\constant{None}.
\end{methoddesc}
\begin{methoddesc}[TestCase]{assertEqual}{first, second\optional{, msg}}
-\methodline{failUnlessEqual}{first, second\optional{, msg}}
+\methodline[TestCase]{failUnlessEqual}{first, second\optional{, msg}}
Test that \var{first} and \var{second} are equal. If the values do
not compare equal, the test will fail with the explanation given by
\var{msg}, or \constant{None}. Note that using \method{failUnlessEqual()}
@@ -633,7 +637,7 @@ report failures.
\end{methoddesc}
\begin{methoddesc}[TestCase]{assertNotEqual}{first, second\optional{, msg}}
-\methodline{failIfEqual}{first, second\optional{, msg}}
+\methodline[TestCase]{failIfEqual}{first, second\optional{, msg}}
Test that \var{first} and \var{second} are not equal. If the values
do compare equal, the test will fail with the explanation given by
\var{msg}, or \constant{None}. Note that using \method{failIfEqual()}
@@ -645,7 +649,7 @@ report failures.
\begin{methoddesc}[TestCase]{assertAlmostEqual}{first, second\optional{,
places\optional{, msg}}}
-\methodline{failUnlessAlmostEqual}{first, second\optional{,
+\methodline[TestCase]{failUnlessAlmostEqual}{first, second\optional{,
places\optional{, msg}}}
Test that \var{first} and \var{second} are approximately equal
by computing the difference, rounding to the given number of \var{places},
@@ -657,7 +661,7 @@ report failures.
\begin{methoddesc}[TestCase]{assertNotAlmostEqual}{first, second\optional{,
places\optional{, msg}}}
-\methodline{failIfAlmostEqual}{first, second\optional{,
+\methodline[TestCase]{failIfAlmostEqual}{first, second\optional{,
places\optional{, msg}}}
Test that \var{first} and \var{second} are not approximately equal
by computing the difference, rounding to the given number of \var{places},
@@ -668,7 +672,7 @@ report failures.
\end{methoddesc}
\begin{methoddesc}[TestCase]{assertRaises}{exception, callable, \moreargs}
-\methodline{failUnlessRaises}{exception, callable, \moreargs}
+\methodline[TestCase]{failUnlessRaises}{exception, callable, \moreargs}
Test that an exception is raised when \var{callable} is called with
any positional or keyword arguments that are also passed to
\method{assertRaises()}. The test passes if \var{exception} is
diff --git a/Doc/lib/liburllib2.tex b/Doc/lib/liburllib2.tex
index 542a7b8..f6ff513 100644
--- a/Doc/lib/liburllib2.tex
+++ b/Doc/lib/liburllib2.tex
@@ -588,7 +588,7 @@ The same as \method{http_error_301()}, but called for the
\class{HTTPCookieProcessor} instances have one attribute:
-\begin{memberdesc}{cookiejar}
+\begin{memberdesc}[HTTPCookieProcessor]{cookiejar}
The \class{cookielib.CookieJar} in which cookies are stored.
\end{memberdesc}
@@ -817,7 +817,10 @@ Use of Basic HTTP Authentication:
import urllib2
# Create an OpenerDirector with support for Basic HTTP Authentication...
auth_handler = urllib2.HTTPBasicAuthHandler()
-auth_handler.add_password('realm', 'host', 'username', 'password')
+auth_handler.add_password(realm='PDQ Application',
+ uri='https://mahler:8092/site-updates.py',
+ user='klem',
+ passwd='kadidd!ehopper')
opener = urllib2.build_opener(auth_handler)
# ...and install it globally so it can be used with urlopen.
urllib2.install_opener(opener)
diff --git a/Doc/lib/liburlparse.tex b/Doc/lib/liburlparse.tex
index 76622d5..16f38a0 100644
--- a/Doc/lib/liburlparse.tex
+++ b/Doc/lib/liburlparse.tex
@@ -157,7 +157,7 @@ The \var{allow_fragments} argument has the same meaning and default as
for \function{urlparse()}.
\note{If \var{url} is an absolute URL (that is, starting with \code{//}
- or \code{scheme://}, the \var{url}'s host name and/or scheme
+ or \code{scheme://}), the \var{url}'s host name and/or scheme
will be present in the result. For example:}
\begin{verbatim}
diff --git a/Doc/lib/libwebbrowser.tex b/Doc/lib/libwebbrowser.tex
index 11d77a1..50366ba 100644
--- a/Doc/lib/libwebbrowser.tex
+++ b/Doc/lib/libwebbrowser.tex
@@ -154,20 +154,20 @@ webbrowser.open_new(url)
Browser controllers provide two methods which parallel two of the
module-level convenience functions:
-\begin{funcdesc}{open}{url\optional{, new\optional{, autoraise=1}}}
+\begin{methoddesc}[controller]{open}{url\optional{, new\optional{, autoraise=1}}}
Display \var{url} using the browser handled by this controller.
If \var{new} is 1, a new browser window is opened if possible.
If \var{new} is 2, a new browser page ("tab") is opened if possible.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{open_new}{url}
+\begin{methoddesc}[controller]{open_new}{url}
Open \var{url} in a new window of the browser handled by this
controller, if possible, otherwise, open \var{url} in the only
browser window. Alias \function{open_new}.
-\end{funcdesc}
+\end{methoddesc}
-\begin{funcdesc}{open_new_tab}{url}
+\begin{methoddesc}[controller]{open_new_tab}{url}
Open \var{url} in a new page ("tab") of the browser handled by this
controller, if possible, otherwise equivalent to \function{open_new}.
\versionadded{2.5}
-\end{funcdesc}
+\end{methoddesc}
diff --git a/Doc/lib/libwinreg.tex b/Doc/lib/libwinreg.tex
index 3853997..1a38964 100644
--- a/Doc/lib/libwinreg.tex
+++ b/Doc/lib/libwinreg.tex
@@ -151,7 +151,7 @@ This module offers the following functions:
An application should only call \function{FlushKey()} if it requires absolute
certainty that registry changes are on disk.
- \emph{If you don't know whether a \function{FlushKey()} call is required, it
+ \note{If you don't know whether a \function{FlushKey()} call is required, it
probably isn't.}
\end{funcdesc}
@@ -393,14 +393,14 @@ This module offers the following functions:
\method{Detach()} method to return the integer handle, and
also disconnect the Windows handle from the handle object.
-\begin{methoddesc}{Close}{}
+\begin{methoddesc}[PyHKEY]{Close}{}
Closes the underlying Windows handle.
If the handle is already closed, no error is raised.
\end{methoddesc}
-\begin{methoddesc}{Detach}{}
+\begin{methoddesc}[PyHKEY]{Detach}{}
Detaches the Windows handle from the handle object.
The result is an integer (or long on 64 bit Windows) that holds
diff --git a/Doc/lib/libxmlrpclib.tex b/Doc/lib/libxmlrpclib.tex
index 1aa2dd5..2a6f3f6 100644
--- a/Doc/lib/libxmlrpclib.tex
+++ b/Doc/lib/libxmlrpclib.tex
@@ -134,12 +134,12 @@ may be either returned data in a conformant type or a \class{Fault} or
Servers that support the XML introspection API support some common
methods grouped under the reserved \member{system} member:
-\begin{methoddesc}{system.listMethods}{}
+\begin{methoddesc}[ServerProxy]{system.listMethods}{}
This method returns a list of strings, one for each (non-system)
method supported by the XML-RPC server.
\end{methoddesc}
-\begin{methoddesc}{system.methodSignature}{name}
+\begin{methoddesc}[ServerProxy]{system.methodSignature}{name}
This method takes one parameter, the name of a method implemented by
the XML-RPC server.It returns an array of possible signatures for this
method. A signature is an array of types. The first of these types is
@@ -159,7 +159,7 @@ returned. In Python this means that the type of the returned
value will be something other that list.
\end{methoddesc}
-\begin{methoddesc}{system.methodHelp}{name}
+\begin{methoddesc}[ServerProxy]{system.methodHelp}{name}
This method takes one parameter, the name of a method implemented by
the XML-RPC server. It returns a documentation string describing the
use of that method. If no such string is available, an empty string is
@@ -184,7 +184,7 @@ implemented in the obvious ways.
It also has the following method, supported mainly for internal use by
the unmarshalling code:
-\begin{methoddesc}{encode}{out}
+\begin{methoddesc}[Boolean]{encode}{out}
Write the XML-RPC encoding of this Boolean item to the out stream object.
\end{methoddesc}
@@ -197,11 +197,11 @@ ISO 8601 time/date string, or a {}\class{\refmodule{datetime}.datetime},
instance. It has the following methods, supported mainly for internal use
by the marshalling/unmarshalling code:
-\begin{methoddesc}{decode}{string}
+\begin{methoddesc}[DateTime]{decode}{string}
Accept a string as the instance's new time value.
\end{methoddesc}
-\begin{methoddesc}{encode}{out}
+\begin{methoddesc}[DateTime]{encode}{out}
Write the XML-RPC encoding of this \class{DateTime} item to the
\var{out} stream object.
\end{methoddesc}
@@ -242,11 +242,11 @@ It also supports certain of Python's built-in operators through a
A \class{Fault} object encapsulates the content of an XML-RPC fault tag.
Fault objects have the following members:
-\begin{memberdesc}{faultCode}
+\begin{memberdesc}[Fault]{faultCode}
A string indicating the fault type.
\end{memberdesc}
-\begin{memberdesc}{faultString}
+\begin{memberdesc}[Fault]{faultString}
A string containing a diagnostic message associated with the fault.
\end{memberdesc}
@@ -258,19 +258,19 @@ underlying transport layer (such as a 404 `not found' error if the
server named by the URI does not exist). It has the following
members:
-\begin{memberdesc}{url}
+\begin{memberdesc}[ProtocolError]{url}
The URI or URL that triggered the error.
\end{memberdesc}
-\begin{memberdesc}{errcode}
+\begin{memberdesc}[ProtocolError]{errcode}
The error code.
\end{memberdesc}
-\begin{memberdesc}{errmsg}
+\begin{memberdesc}[ProtocolError]{errmsg}
The error message or diagnostic string.
\end{memberdesc}
-\begin{memberdesc}{headers}
+\begin{memberdesc}[ProtocolError]{headers}
A string containing the headers of the HTTP/HTTPS request that
triggered the error.
\end{memberdesc}
diff --git a/Doc/lib/libzipfile.tex b/Doc/lib/libzipfile.tex
index 06a236c..6cdd1d3 100644
--- a/Doc/lib/libzipfile.tex
+++ b/Doc/lib/libzipfile.tex
@@ -141,6 +141,34 @@ cat myzip.zip >> python.exe
Return a list of archive members by name.
\end{methoddesc}
+\begin{methoddesc}{open}{name\optional{, mode\optional{, pwd}}}
+ Extract a member from the archive as a file-like object (ZipExtFile).
+ \var{name} is the name of the file in the archive. The \var{mode}
+ parameter, if included, must be one of the following: \code{'r'} (the
+ default), \code{'U'}, or \code{'rU'}. Choosing \code{'U'} or
+ \code{'rU'} will enable universal newline support in the read-only
+ object. \var{pwd} is the password used for encrypted files.
+ \begin{notice}
+ The file-like object is read-only and provides the following methods:
+ \method{read()}, \method{readline()}, \method{readlines()},
+ \method{__iter__()}, \method{next()}.
+ \end{notice}
+ \begin{notice}
+ If the ZipFile was created by passing in a file-like object as the
+ first argument to the constructor, then the object returned by
+ \method{open()} shares the ZipFile's file pointer. Under these
+ circumstances, the object returned by \method{open()} should not
+ be used after any additional operations are performed on the
+ ZipFile object. If the ZipFile was created by passing in a string
+ (the filename) as the first argument to the constructor, then
+ \method{open()} will create a new file object that will be held
+ by the ZipExtFile, allowing it to operate independently of the
+ ZipFile.
+ \end{notice}
+
+ \versionadded{2.6}
+\end{methoddesc}
+
\begin{methoddesc}{printdir}{}
Print a table of contents for the archive to \code{sys.stdout}.
\end{methoddesc}
diff --git a/Doc/lib/libzlib.tex b/Doc/lib/libzlib.tex
index 876f8c0..3cc7b3c 100644
--- a/Doc/lib/libzlib.tex
+++ b/Doc/lib/libzlib.tex
@@ -131,7 +131,7 @@ compress a set of data that share a common initial prefix.
Decompression objects support the following methods, and two attributes:
-\begin{memberdesc}{unused_data}
+\begin{memberdesc}[Decompress]{unused_data}
A string which contains any bytes past the end of the compressed data.
That is, this remains \code{""} until the last byte that contains
compression data is available. If the whole string turned out to
@@ -145,7 +145,7 @@ decompression object's \method{decompress} method until the
\member{unused_data} attribute is no longer the empty string.
\end{memberdesc}
-\begin{memberdesc}{unconsumed_tail}
+\begin{memberdesc}[Decompress]{unconsumed_tail}
A string that contains any data that was not consumed by the last
\method{decompress} call because it exceeded the limit for the
uncompressed data buffer. This data has not yet been seen by the zlib
diff --git a/Doc/mac/libframework.tex b/Doc/mac/libframework.tex
index 692c31f..edc76c1 100644
--- a/Doc/mac/libframework.tex
+++ b/Doc/mac/libframework.tex
@@ -189,8 +189,6 @@ null-event is passed (so you can look at mouse position, etc).
Window objects have the following methods, among others:
-\setindexsubitem{(Window method)}
-
\begin{methoddesc}[Window]{open}{}
Override this method to open a window. Store the MacOS window-id in
\member{self.wid} and call the \method{do_postopen()} method to
@@ -218,7 +216,7 @@ event.
An update event for the window was received. Redraw the window.
\end{methoddesc}
-\begin{methoddesc}{do_activate}{activate, event}
+\begin{methoddesc}[Window]{do_activate}{activate, event}
The window was activated (\code{\var{activate} == 1}) or deactivated
(\code{\var{activate} == 0}). Handle things like focus highlighting,
etc.
diff --git a/Doc/mac/libmacic.tex b/Doc/mac/libmacic.tex
index 6d3a0d7..f8006f3 100644
--- a/Doc/mac/libmacic.tex
+++ b/Doc/mac/libmacic.tex
@@ -68,14 +68,14 @@ Besides the dictionary interface, \class{IC} objects have the
following methods:
-\begin{methoddesc}{launchurl}{url\optional{, hint}}
+\begin{methoddesc}[IC]{launchurl}{url\optional{, hint}}
Parse the given URL, launch the correct application and pass it the
URL. The optional \var{hint} can be a scheme name such as
\code{'mailto:'}, in which case incomplete URLs are completed with this
scheme. If \var{hint} is not provided, incomplete URLs are invalid.
\end{methoddesc}
-\begin{methoddesc}{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
+\begin{methoddesc}[IC]{parseurl}{data\optional{, start\optional{, end\optional{, hint}}}}
Find an URL somewhere in \var{data} and return start position, end
position and the URL. The optional \var{start} and \var{end} can be
used to limit the search, so for instance if a user clicks in a long
@@ -85,7 +85,7 @@ user clicked. As above, \var{hint} is an optional scheme used to
complete incomplete URLs.
\end{methoddesc}
-\begin{methoddesc}{mapfile}{file}
+\begin{methoddesc}[IC]{mapfile}{file}
Return the mapping entry for the given \var{file}, which can be passed
as either a filename or an \function{FSSpec()} result, and which
need not exist.
@@ -106,7 +106,7 @@ postprocessing application, \var{mimetype} is the MIME type of this
file and \var{entryname} is the name of this entry.
\end{methoddesc}
-\begin{methoddesc}{maptypecreator}{type, creator\optional{, filename}}
+\begin{methoddesc}[IC]{maptypecreator}{type, creator\optional{, filename}}
Return the mapping entry for files with given 4-character \var{type} and
\var{creator} codes. The optional \var{filename} may be specified to
further help finding the correct entry (if the creator code is
@@ -115,7 +115,7 @@ further help finding the correct entry (if the creator code is
The mapping entry is returned in the same format as for \var{mapfile}.
\end{methoddesc}
-\begin{methoddesc}{settypecreator}{file}
+\begin{methoddesc}[IC]{settypecreator}{file}
Given an existing \var{file}, specified either as a filename or as an
\function{FSSpec()} result, set its creator and type correctly based
on its extension. The finder is told about the change, so the finder
diff --git a/Doc/mac/undoc.tex b/Doc/mac/undoc.tex
index 72abadf..96e4900 100644
--- a/Doc/mac/undoc.tex
+++ b/Doc/mac/undoc.tex
@@ -21,7 +21,7 @@ touch with
\modulesynopsis{Helper module for BuildApplet, BuildApplication and
macfreeze.}
-\deprecated{2.4}
+\deprecated{2.4}{}
\section{\module{cfmfile} --- Code Fragment Resource module}
\declaremodule{standard}{cfmfile}
@@ -33,7 +33,7 @@ accompanying ``cfrg'' resources. It can parse them and merge them, and is
used by BuildApplication to combine all plugin modules to a single
executable.
-\deprecated{2.4}
+\deprecated{2.4}{}
\section{\module{icopen} --- Internet Config replacement for \method{open()}}
\declaremodule{standard}{icopen}
diff --git a/Doc/mac/using.tex b/Doc/mac/using.tex
index b21a98e..ca522c6 100644
--- a/Doc/mac/using.tex
+++ b/Doc/mac/using.tex
@@ -2,7 +2,7 @@
\sectionauthor{Bob Savage}{bobsavage@mac.com}
Python on a Macintosh running Mac OS X is in principle very similar to
-Python on any other \UNIX platform, but there are a number of additional
+Python on any other \UNIX{} platform, but there are a number of additional
features such as the IDE and the Package Manager that are worth pointing out.
Python on Mac OS 9 or earlier can be quite different from Python on
@@ -13,206 +13,166 @@ for the latest 2.3 release for Mac OS 9 and related documentation.
\section{Getting and Installing MacPython \label{getting-OSX}}
-Mac OS X 10.3 comes with Python 2.3 pre-installed by Apple.
-This installation does not come with the IDE and other additions, however,
-so to get these you need to install the \program{MacPython for Panther additions}
-from the MacPython website, \url{http://www.cwi.nl/\textasciitilde jack/macpython}.
-
-For MacPython 2.4, or for any MacPython on earlier releases of Mac OS X,
-you need to install a full distribution from the same website.
+Mac OS X 10.4 comes with Python 2.3 pre-installed by Apple. However, you are
+encouraged to install the most recent version of Python from the Python website
+(\url{http://www.python.org}). A ``universal binary'' build of Python 2.5, which
+runs natively on the Mac's new Intel and legacy PPC CPU's, is available there.
What you get after installing is a number of things:
\begin{itemize}
- \item A \file{MacPython-2.3} folder in your \file{Applications}
- folder. In here you find the PythonIDE Integrated Development Environment;
- PythonLauncher, which handles double-clicking Python scripts from
- the Finder; and the Package Manager.
-
- \item A fairly standard \UNIX{} commandline Python interpreter in
- \file{/usr/local/bin/python}, but without the usual
- \file{/usr/local/lib/python}.
-
- \item A framework \file{/Library/Frameworks/Python.framework}, where
- all the action really is, but which you usually do not have to be aware of.
+\item A \file{MacPython 2.5} folder in your \file{Applications} folder. In here
+ you find IDLE, the development environment that is a standard part of official
+ Python distributions; PythonLauncher, which handles double-clicking Python
+ scripts from the Finder; and the ``Build Applet'' tool, which allows you to
+ package Python scripts as standalone applications on your system.
+
+\item A framework \file{/Library/Frameworks/Python.framework}, which includes
+ the Python executable and libraries. The installer adds this location to your
+ shell path. To uninstall MacPython, you can simply remove these three
+ things. A symlink to the Python executable is placed in /usr/local/bin/.
\end{itemize}
-To uninstall MacPython you can simply remove these three things.
+The Apple-provided build of Python is installed in
+\file{/System/Library/Frameworks/Python.framework} and \file{/usr/bin/python},
+respectively. You should never modify or delete these, as they are
+Apple-controlled and are used by Apple- or third-party software.
-If you use the ``additions'' installer to install on top of an existing
-Apple-Python you will not get the framework and the commandline interpreter,
-as they have been installed by Apple already, in
-\file{/System/Library/Frameworks/Python.framework} and
-\file{/usr/bin/python}, respectively. You should in principle never modify
-or delete these, as they are Apple-controlled and may be used by Apple- or
-third-party software.
+IDLE includes a help menu that allows you to access Python documentation. If you
+are completely new to Python you should start reading the tutorial introduction
+in that document.
-PythonIDE contains an Apple Help Viewer book called "MacPython Help"
-which you can access through its help menu. If you are completely new to
-Python you should start reading the IDE introduction in that document.
+If you are familiar with Python on other \UNIX{} platforms you should read the
+section on running Python scripts from the \UNIX{} shell.
-If you are familiar with Python on other \UNIX{} platforms you should
-read the section on running Python scripts from the \UNIX{} shell.
\subsection{How to run a Python script}
-Your best way to get started with Python on Mac OS X is through the PythonIDE
-integrated development environment, see section \ref{IDE} and use the Help
-menu when the IDE is running.
+Your best way to get started with Python on Mac OS X is through the IDLE
+integrated development environment, see section \ref{IDE} and use the Help menu
+when the IDE is running.
-If you want to run Python scripts from the Terminal window command line
-or from the Finder you first need an editor to create your script.
-Mac OS X comes with a number of standard \UNIX{} command line editors,
-\program{vim} and \program{emacs} among them. If you want a more Mac-like
-editor \program{BBEdit} or \program{TextWrangler} from Bare Bones Software
-(see \url{http://www.barebones.com/products/bbedit/index.shtml}) are
-good choices. \program{AppleWorks} or any other
-word processor that can save files in ASCII is also a possibility, including
-\program{TextEdit} which is included with OS X.
+If you want to run Python scripts from the Terminal window command line or from
+the Finder you first need an editor to create your script. Mac OS X comes with a
+number of standard \UNIX{} command line editors, \program{vim} and
+\program{emacs} among them. If you want a more Mac-like editor, \program{BBEdit}
+or \program{TextWrangler} from Bare Bones Software (see
+\url{http://www.barebones.com/products/bbedit/index.shtml}) are good choices, as
+is \program{TextMate} (see \url{http://macromates.com/}). Other editors include
+\program{Gvim} (\url{http://macvim.org}) and \program{Aquamacs}
+(\url{http://aquamacs.org}).
To run your script from the Terminal window you must make sure that
-\file{/usr/local/bin} is in your shell search path.
+\file{/usr/local/bin} is in your shell search path.
To run your script from the Finder you have two options:
+
\begin{itemize}
- \item Drag it to \program{PythonLauncher}
- \item Select \program{PythonLauncher} as the default application
- to open your script (or any .py script) through the finder Info window
- and double-click it.
+\item Drag it to \program{PythonLauncher}
+\item Select \program{PythonLauncher} as the default application to open your
+ script (or any .py script) through the finder Info window and double-click it.
+ \program{PythonLauncher} has various preferences to control how your script is
+ launched. Option-dragging allows you to change these for one invocation, or
+ use its Preferences menu to change things globally.
\end{itemize}
-PythonLauncher has various preferences to control how your script is launched.
-Option-dragging allows you to change these for one invocation, or use its
-Preferences menu to change things globally.
\subsection{Running scripts with a GUI \label{osx-gui-scripts}}
-There is one Mac OS X quirk that you need to be aware of: programs
-that talk to the Aqua window manager (in other words, anything that has a GUI)
-need to be run in a special way. Use \program{pythonw} instead of \program{python}
-to start such scripts.
+With older versions of Python, there is one Mac OS X quirk that you need to be
+aware of: programs that talk to the Aqua window manager (in other words,
+anything that has a GUI) need to be run in a special way. Use \program{pythonw}
+instead of \program{python} to start such scripts.
-\subsection{configuration}
+With Python 2.5, you can use either \program{python} or \program{pythonw}.
-MacPython honours all standard \UNIX{} environment variables such as
-\envvar{PYTHONPATH}, but setting these variables for programs started
-from the Finder is non-standard
-as the Finder does not read your \file{.profile} or \file{.cshrc} at startup.
-You need to create a file \file{\textasciitilde /.MacOSX/environment.plist}.
-See Apple's Technical Document QA1067 for details.
+\subsection{Configuration}
-Installing additional Python packages is most easily done through the
-Package Manager, see the MacPython Help Book for details.
+Python on OS X honors all standard \UNIX{} environment variables such as
+\envvar{PYTHONPATH}, but setting these variables for programs started from the
+Finder is non-standard as the Finder does not read your \file{.profile} or
+\file{.cshrc} at startup. You need to create a file \file{\textasciitilde
+ /.MacOSX/environment.plist}. See Apple's Technical Document QA1067 for
+details.
+
+For more information on installation Python packages in MacPython, see section
+\ref{mac-package-manager}, ``Installing Additional Python Packages.''
\section{The IDE\label{IDE}}
-The \program{Python IDE} (Integrated Development Environment) is a
-separate application that acts as a text editor for your Python code,
-a class browser, a graphical debugger, and more.
-
-The online Python Help contains a quick walkthrough of the IDE that
-shows the major features and how to use them.
-
-\subsection{Using the ``Python Interactive'' window}
-
-Use this window like you would use a normal \UNIX{} command line
-interpreter.
-
-\subsection{Writing a Python Script \label{IDEwrite}}
-
-In addition to using the \program{Python IDE} interactively, you can
-also type out a complete Python program, saving it incrementally, and
-execute it or smaller selections of it.
-
-You can create a new script, open a previously saved script, and save
-your currently open script by selecting the appropriate item in the
-``File'' menu. Dropping a Python script onto the
-\program{Python IDE} will open it for editing.
-
-When the \program{Python IDE} saves a script, it uses the creator code
-settings which are available by clicking on the small black triangle
-on the top right of the document window, and selecting ``save
-options''. The default is to save the file with the \program{Python
-IDE} as the creator, this means that you can open the file for editing
-by simply double-clicking on its icon. You might want to change this
-behaviour so that it will be opened by the
-\program{PythonLauncher}, and run. To do this simply choose
-``PythonLauncher'' from the ``save options''. Note that these
-options are associated with the \emph{file} not the application.
-
-
-\subsection{Executing a script from within the IDE
- \label{IDEexecution}}
-
-You can run the script in the frontmost window of the \program{Python
-IDE} by hitting the run all button. You should be aware, however that
-if you use the Python convention \samp{if __name__ == "__main__":} the
-script will \emph{not} be ``__main__'' by default. To get that
-behaviour you must select the ``Run as __main__'' option from the
-small black triangle on the top right of the document window. Note
-that this option is associated with the \emph{file} not the
-application. It \emph{will} stay active after a save, however; to shut
-this feature off simply select it again.
-
-
-\subsection{``Save as'' versus ``Save as Applet''
- \label{IDEapplet}}
-
-When you are done writing your Python script you have the option of
-saving it as an ``applet'' (by selecting ``Save as applet'' from the
-``File'' menu). This has a significant advantage in that you can drop
-files or folders onto it, to pass them to the applet the way
-command-line users would type them onto the command-line to pass them
-as arguments to the script. However, you should make sure to save the
-applet as a separate file, do not overwrite the script you are
-writing, because you will not be able to edit it again.
-
-Accessing the items passed to the applet via ``drag-and-drop'' is done
-using the standard \member{sys.argv} mechanism. See the general
-documentation for more
-% need to link to the appropriate place in non-Mac docs
-
-Note that saving a script as an applet will not make it runnable on a
-system without a Python installation.
-
-%\subsection{Debugger}
-% **NEED INFO HERE**
-
-%\subsection{Module Browser}
-% **NEED INFO HERE**
-
-%\subsection{Profiler}
-% **NEED INFO HERE**
-% end IDE
-
-%\subsection{The ``Scripts'' menu}
-% **NEED INFO HERE**
-
-\section{The Package Manager}
-
-Historically MacPython came with a number of useful extension packages
-included, because most Macintosh users do not have access to a development
-environment and C compiler. For Mac OS X that bundling is no longer done,
-but a new mechanism has been made available to allow easy access to
-extension packages.
-
-The Python Package Manager helps you installing additional packages
-that enhance Python. It determines the exact MacOS version and Python
-version you have and uses that information to download a database that
-has packages that are tested and tried on that combination. In other
-words: if something is in your Package Manager window but does not work
-you are free to blame the database maintainer.
-
-PackageManager then checks which of the packages you have installed and
-which ones are not. This should also work when you have installed packages
-outside of PackageManager. You can select packages and install them,
-and PackageManager will work out the requirements and install these too.
-
-Often PackageManager will list a package in two flavors: binary and
-source. Binary should always work, source will only work if you have
-installed the Apple Developer Tools. PackageManager will warn you about
-this, and also about other external dependencies.
-
-PackageManager is available as a separate application and also as a
-function of the IDE, through the File->Package Manager menu entry.
+MacPython ships with the standard IDLE development environment. A good
+introduction to using IDLE can be found at
+\url{http://hkn.eecs.berkeley.edu/~dyoo/python/idle_intro/index.html}.
+
+
+\section{Installing Additional Python Packages \label{mac-package-manager}}
+
+There are several methods to install additional Python packages:
+
+\begin{itemize}
+\item \url{http://pythonmac.org/packages/} contains selected compiled packages
+ for Python 2.5, 2.4, and 2.3.
+\item Packages can be installed via the standard Python distutils mode
+ (\samp{python setup.py install}).
+\item Many packages can also be installed via the \program{setuptools}
+ extension.
+\end{itemize}
+
+
+\section{GUI Programming on the Mac}
+
+There are several options for building GUI applications on the Mac with Python.
+
+\emph{PyObjC} is a Python binding to Apple's Objective-C/Cocoa framework, which
+is the foundation of most modern Mac development. Information on PyObjC is
+available from \url{http://pybojc.sourceforge.net}.
+
+The standard Python GUI toolkit is \module{Tkinter}, based on the cross-platform
+Tk toolkit (\url{http://www.tcl.tk}). An Aqua-native version of Tk is bundled
+with OS X by Apple, and the latest version can be downloaded and installed from
+\url{http://www.activestate.com}; it can also be built from source.
+
+\emph{wxPython} is another popular cross-platform GUI toolkit that runs natively
+on Mac OS X. Packages and documentation are available from
+\url{http://www.wxpython.org}.
+
+\emph{PyQt} is another popular cross-platform GUI toolkit that runs natively on
+Mac OS X. More information can be found at
+\url{http://www.riverbankcomputing.co.uk/pyqt/}.
+
+
+\section{Distributing Python Applications on the Mac}
+
+The ``Build Applet'' tool that is placed in the MacPython 2.5 folder is fine for
+packaging small Python scripts on your own machine to run as a standard Mac
+application. This tool, however, is not robust enough to distribute Python
+applications to other users.
+
+The standard tool for deploying standalone Python applications on the Mac is
+\program{py2app}. More information on installing and using py2app can be found
+at \url{http://undefined.org/python/\#py2app}.
+
+\section{Application Scripting}
+
+Python can also be used to script other Mac applications via Apple's Open
+Scripting Architecture (OSA); see
+\url{http://appscript.sourceforge.net}. Appscript is a high-level, user-friendly
+Apple event bridge that allows you to control scriptable Mac OS X applications
+using ordinary Python scripts. Appscript makes Python a serious alternative to
+Apple's own \emph{AppleScript} language for automating your Mac. A related
+package, \emph{PyOSA}, is an OSA language component for the Python scripting
+language, allowing Python code to be executed by any OSA-enabled application
+(Script Editor, Mail, iTunes, etc.). PyOSA makes Python a full peer to
+AppleScript.
+
+\section{Other Resources}
+
+The MacPython mailing list is an excellent support resource for Python users and
+developers on the Mac:
+
+\url{http://www.python.org/community/sigs/current/pythonmac-sig/}
+
+Another useful resource is the MacPython wiki:
+
+\url{http://wiki.python.org/moin/MacPython}
diff --git a/Doc/ref/ref1.tex b/Doc/ref/ref1.tex
index 15bcf36..6234716 100644
--- a/Doc/ref/ref1.tex
+++ b/Doc/ref/ref1.tex
@@ -93,7 +93,7 @@ grammar notation. This uses the following style of definition:
\index{syntax}
\index{notation}
-\begin{productionlist}
+\begin{productionlist}[*]
\production{name}{\token{lc_letter} (\token{lc_letter} | "_")*}
\production{lc_letter}{"a"..."z"}
\end{productionlist}
diff --git a/Doc/ref/ref3.tex b/Doc/ref/ref3.tex
index 40b2ebd..8340e17 100644
--- a/Doc/ref/ref3.tex
+++ b/Doc/ref/ref3.tex
@@ -218,7 +218,7 @@ when using mixed operands.
\indexii{integer}{representation}
\item[Floating point numbers]
-These represent machine-level double precision floating point numbers.
+These represent machine-level double precision floating point numbers.
You are at the mercy of the underlying machine architecture (and
C or Java implementation) for the accepted range and handling of overflow.
Python does not support single-precision floating point numbers; the
@@ -470,7 +470,7 @@ parameter list.
\obindex{function}
\obindex{user-defined function}
-Special attributes:
+Special attributes:
\begin{tableiii}{lll}{member}{Attribute}{Meaning}{}
\lineiii{__doc__}{The function's documentation string, or
@@ -860,12 +860,12 @@ but they are mentioned here for completeness.
\begin{description}
\item[Code objects]
-Code objects represent \emph{byte-compiled} executable Python code, or
+Code objects represent \emph{byte-compiled} executable Python code, or
\emph{bytecode}.
The difference between a code
object and a function object is that the function object contains an
explicit reference to the function's globals (the module in which it
-was defined), while a code object contains no context;
+was defined), while a code object contains no context;
also the default argument values are stored in the function object,
not in the code object (because they represent values calculated at
run-time). Unlike function objects, code objects are immutable and
@@ -1069,7 +1069,7 @@ by the built-in \function{classmethod()} constructor.
%=========================================================================
\section{New-style and classic classes}
-Classes and instances come in two flavors: old-style or classic, and new-style.
+Classes and instances come in two flavors: old-style or classic, and new-style.
Up to Python 2.1, old-style classes were the only flavour available to the
user. The concept of (old-style) class is unrelated to the concept of type: if
@@ -1244,7 +1244,7 @@ description...}>} should be returned. The return value must be a
string object.
If a class defines \method{__repr__()} but not \method{__str__()},
then \method{__repr__()} is also used when an ``informal'' string
-representation of instances of that class is required.
+representation of instances of that class is required.
This is typically used for debugging, so it is important that the
representation is information-rich and unambiguous.
@@ -1280,10 +1280,14 @@ follows:
\code{\var{x}!=\var{y}} calls \code{\var{x}.__ne__(\var{y})},
\code{\var{x}>\var{y}} calls \code{\var{x}.__gt__(\var{y})}, and
\code{\var{x}>=\var{y}} calls \code{\var{x}.__ge__(\var{y})}.
-These methods can return any value, but if the comparison operator is
-used in a Boolean context, the return value should be interpretable as
-a Boolean value, else a \exception{TypeError} will be raised.
-By convention, \code{False} is used for false and \code{True} for true.
+
+A rich comparison method may return the singleton \code{NotImplemented} if it
+does not implement the operation for a given pair of arguments.
+By convention, \code{False} and \code{True} are returned for a successful
+comparison. However, these methods can return any value, so if the
+comparison operator is used in a Boolean context (e.g., in the condition
+of an \code{if} statement), Python will call \function{bool()} on the
+value to determine if the result is true or false.
There are no implied relationships among the comparison operators.
The truth of \code{\var{x}==\var{y}} does not imply that \code{\var{x}!=\var{y}}
@@ -1297,9 +1301,7 @@ the right argument does); rather, \method{__lt__()} and
\method{__ge__()} are each other's reflection, and \method{__eq__()}
and \method{__ne__()} are their own reflection.
-Arguments to rich comparison methods are never coerced. A rich
-comparison method may return \code{NotImplemented} if it does not
-implement the operation for a given pair of arguments.
+Arguments to rich comparison methods are never coerced.
\end{methoddesc}
\begin{methoddesc}[object]{__cmp__}{self, other}
@@ -1399,7 +1401,7 @@ instead of the normal mechanism (i.e.\ store the value in the instance
dictionary). \var{name} is the attribute name, \var{value} is the
value to be assigned to it.
-If \method{__setattr__()} wants to assign to an instance attribute, it
+If \method{__setattr__()} wants to assign to an instance attribute, it
should not simply execute \samp{self.\var{name} = value} --- this
would cause a recursive call to itself. Instead, it should insert the
value in the dictionary of instance attributes, e.g.,
@@ -1422,8 +1424,8 @@ The following methods only apply to new-style classes.
\begin{methoddesc}[object]{__getattribute__}{self, name}
Called unconditionally to implement attribute accesses for instances
-of the class. If the class also defines \method{__getattr__()}, the latter
-will not be called unless \method{__getattribute__()} either calls it
+of the class. If the class also defines \method{__getattr__()}, the latter
+will not be called unless \method{__getattribute__()} either calls it
explicitly or raises an \exception{AttributeError}.
This method should return the (computed) attribute
value or raise an \exception{AttributeError} exception.
@@ -1475,7 +1477,7 @@ descriptor.
The default behavior for attribute access is to get, set, or delete the
attribute from an object's dictionary. For instance, \code{a.x} has a
lookup chain starting with \code{a.__dict__['x']}, then
-\code{type(a).__dict__['x']}, and continuing
+\code{type(a).__dict__['x']}, and continuing
through the base classes of \code{type(a)} excluding metaclasses.
However, if the looked-up value is an object defining one of the descriptor
@@ -1489,14 +1491,14 @@ The starting point for descriptor invocation is a binding, \code{a.x}.
How the arguments are assembled depends on \code{a}:
\begin{itemize}
-
+
\item[Direct Call] The simplest and least common call is when user code
directly invokes a descriptor method: \code{x.__get__(a)}.
\item[Instance Binding] If binding to a new-style object instance,
\code{a.x} is transformed into the call:
\code{type(a).__dict__['x'].__get__(a, type(a))}.
-
+
\item[Class Binding] If binding to a new-style class, \code{A.x}
is transformed into the call: \code{A.__dict__['x'].__get__(None, A)}.
@@ -1505,7 +1507,7 @@ How the arguments are assembled depends on \code{a}:
\code{obj.__class__.__mro__} for the base class \code{A} immediately
preceding \code{B} and then invokes the descriptor with the call:
\code{A.__dict__['m'].__get__(obj, A)}.
-
+
\end{itemize}
For instance bindings, the precedence of descriptor invocation depends
@@ -1518,7 +1520,7 @@ descriptors can be overridden by instances.
Python methods (including \function{staticmethod()} and \function{classmethod()})
are implemented as non-data descriptors. Accordingly, instances can
redefine and override methods. This allows individual instances to acquire
-behaviors that differ from other instances of the same class.
+behaviors that differ from other instances of the same class.
The \function{property()} function is implemented as a data descriptor.
Accordingly, instances cannot override the behavior of a property.
@@ -1536,14 +1538,14 @@ definition. The \var{__slots__} declaration takes a sequence of instance
variables and reserves just enough space in each instance to hold a value
for each variable. Space is saved because \var{__dict__} is not created for
each instance.
-
+
\begin{datadesc}{__slots__}
This class variable can be assigned a string, iterable, or sequence of strings
with variable names used by instances. If defined in a new-style class,
\var{__slots__} reserves space for the declared variables
and prevents the automatic creation of \var{__dict__} and \var{__weakref__}
for each instance.
-\versionadded{2.2}
+\versionadded{2.2}
\end{datadesc}
\noindent
@@ -1555,23 +1557,23 @@ Notes on using \var{__slots__}
variables not listed in the \var{__slots__} definition. Attempts to assign
to an unlisted variable name raises \exception{AttributeError}. If dynamic
assignment of new variables is desired, then add \code{'__dict__'} to the
-sequence of strings in the \var{__slots__} declaration.
+sequence of strings in the \var{__slots__} declaration.
\versionchanged[Previously, adding \code{'__dict__'} to the \var{__slots__}
declaration would not enable the assignment of new attributes not
-specifically listed in the sequence of instance variable names]{2.3}
+specifically listed in the sequence of instance variable names]{2.3}
\item Without a \var{__weakref__} variable for each instance, classes
defining \var{__slots__} do not support weak references to its instances.
If weak reference support is needed, then add \code{'__weakref__'} to the
-sequence of strings in the \var{__slots__} declaration.
+sequence of strings in the \var{__slots__} declaration.
\versionchanged[Previously, adding \code{'__weakref__'} to the \var{__slots__}
-declaration would not enable support for weak references]{2.3}
+declaration would not enable support for weak references]{2.3}
\item \var{__slots__} are implemented at the class level by creating
descriptors (\ref{descriptors}) for each variable name. As a result,
class attributes cannot be used to set default values for instance
variables defined by \var{__slots__}; otherwise, the class attribute would
-overwrite the descriptor assignment.
+overwrite the descriptor assignment.
\item If a class defines a slot also defined in a base class, the instance
variable defined by the base class slot is inaccessible (except by retrieving
@@ -1580,14 +1582,19 @@ program undefined. In the future, a check may be added to prevent this.
\item The action of a \var{__slots__} declaration is limited to the class
where it is defined. As a result, subclasses will have a \var{__dict__}
-unless they also define \var{__slots__}.
+unless they also define \var{__slots__}.
\item \var{__slots__} do not work for classes derived from ``variable-length''
-built-in types such as \class{long}, \class{str} and \class{tuple}.
+built-in types such as \class{long}, \class{str} and \class{tuple}.
\item Any non-string iterable may be assigned to \var{__slots__}.
Mappings may also be used; however, in the future, special meaning may
-be assigned to the values corresponding to each key.
+be assigned to the values corresponding to each key.
+
+\item \var{__class__} assignment works only if both classes have the
+same \var{__slots__}.
+\versionchanged[Previously, \var{__class__} assignment raised an error
+if either new or old class had \var{__slots__}]{2.6}
\end{itemize}
@@ -1613,7 +1620,7 @@ the role of a factory function.
This variable can be any callable accepting arguments for \code{name},
\code{bases}, and \code{dict}. Upon class creation, the callable is
used instead of the built-in \function{type()}.
-\versionadded{2.2}
+\versionadded{2.2}
\end{datadesc}
The appropriate metaclass is determined by the following precedence rules:
@@ -1630,7 +1637,7 @@ type).
\item Otherwise, the old-style, classic metaclass (types.ClassType) is used.
-\end{itemize}
+\end{itemize}
The potential uses for metaclasses are boundless. Some ideas that have
been explored including logging, interface checking, automatic delegation,
@@ -1663,15 +1670,15 @@ defined to handle simple, but not extended slices.) It is also recommended
that mappings provide the methods \method{keys()}, \method{values()},
\method{items()}, \method{has_key()}, \method{get()}, \method{clear()},
\method{setdefault()}, \method{iterkeys()}, \method{itervalues()},
-\method{iteritems()}, \method{pop()}, \method{popitem()},
+\method{iteritems()}, \method{pop()}, \method{popitem()},
\method{copy()}, and \method{update()} behaving similar to those for
Python's standard dictionary objects. The \module{UserDict} module
provides a \class{DictMixin} class to help create those methods
from a base set of \method{__getitem__()}, \method{__setitem__()},
-\method{__delitem__()}, and \method{keys()}.
+\method{__delitem__()}, and \method{keys()}.
Mutable sequences should provide
methods \method{append()}, \method{count()}, \method{index()},
-\method{extend()},
+\method{extend()},
\method{insert()}, \method{pop()}, \method{remove()}, \method{reverse()}
and \method{sort()}, like Python standard list objects. Finally,
sequence types should implement addition (meaning concatenation) and
@@ -1694,12 +1701,12 @@ through the values.
\ttindex{items()}
\ttindex{iterkeys()}
\ttindex{itervalues()}
- \ttindex{iteritems()}
+ \ttindex{iteritems()}
\ttindex{has_key()}
\ttindex{get()}
\ttindex{setdefault()}
- \ttindex{pop()}
- \ttindex{popitem()}
+ \ttindex{pop()}
+ \ttindex{popitem()}
\ttindex{clear()}
\ttindex{copy()}
\ttindex{update()}
@@ -1707,7 +1714,7 @@ through the values.
\withsubitem{(sequence object method)}{
\ttindex{append()}
\ttindex{count()}
- \ttindex{extend()}
+ \ttindex{extend()}
\ttindex{index()}
\ttindex{insert()}
\ttindex{pop()}
@@ -1721,7 +1728,7 @@ through the values.
\ttindex{__rmul__()}
\ttindex{__imul__()}
\ttindex{__contains__()}
- \ttindex{__iter__()}}
+ \ttindex{__iter__()}}
\withsubitem{(numeric object method)}
\begin{methoddesc}[container object]{__len__}{self}
@@ -1744,7 +1751,7 @@ raised; if of a value outside the set of indexes for the sequence
(after any special interpretation of negative values),
\exception{IndexError} should be raised.
For mapping types, if \var{key} is missing (not in the container),
-\exception{KeyError} should be raised.
+\exception{KeyError} should be raised.
\note{\keyword{for} loops expect that an
\exception{IndexError} will be raised for illegal indexes to allow
proper detection of the end of the sequence.}
@@ -1943,7 +1950,7 @@ the alternate context; \exception{TypeError} will be raised instead.
\methodline[numeric object]{__rmul__}{self, other}
\methodline[numeric object]{__rdiv__}{self, other}
\methodline[numeric object]{__rtruediv__}{self, other}
-\methodline[numeric object]{__rfloordiv__}{self, other}
+\methodline[numeric object]{__rfloordiv__}{self, other}
\methodline[numeric object]{__rmod__}{self, other}
\methodline[numeric object]{__rdivmod__}{self, other}
\methodline[numeric object]{__rpow__}{self, other}
@@ -1964,7 +1971,7 @@ operands are of different types.\footnote{
For operands of the same type, it is assumed that if the
non-reflected method (such as \method{__add__()}) fails the
operation is not supported, which is why the reflected method
- is not called.}
+ is not called.}
For instance, to evaluate the expression \var{x}\code{-}\var{y},
where \var{y} is an instance of a class that has an
\method{__rsub__()} method, \code{\var{y}.__rsub__(\var{x})}
@@ -1989,7 +1996,7 @@ complicated).
\methodline[numeric object]{__idiv__}{self, other}
\methodline[numeric object]{__itruediv__}{self, other}
\methodline[numeric object]{__ifloordiv__}{self, other}
-\methodline[numeric object]{__imod__}{self, other}
+\methodline[numeric object]{__imod__}{self, other}
\methodline[numeric object]{__ipow__}{self, other\optional{, modulo}}
\methodline[numeric object]{__ilshift__}{self, other}
\methodline[numeric object]{__irshift__}{self, other}
diff --git a/Doc/ref/ref5.tex b/Doc/ref/ref5.tex
index 0b4e978..9a4fe3a 100644
--- a/Doc/ref/ref5.tex
+++ b/Doc/ref/ref5.tex
@@ -56,7 +56,7 @@ categorized syntactically as atoms. The syntax for atoms is:
\production{enclosure}
{\token{parenth_form} | \token{list_display}}
\productioncont{| \token{generator_expression} | \token{dict_display}}
- \productioncont{| \token{string_conversion}}
+ \productioncont{| \token{string_conversion} | \token{yield_atom}}
\end{productionlist}
@@ -65,6 +65,7 @@ categorized syntactically as atoms. The syntax for atoms is:
\index{identifier}
An identifier occurring as an atom is a name. See
+section \ref{identifiers} for lexical definition and
section~\ref{naming} for documentation of naming and binding.
When the name is bound to an object, evaluation of the atom yields
@@ -154,22 +155,20 @@ A list display is a possibly empty series of expressions enclosed in
square brackets:
\begin{productionlist}
- \production{test}
- {\token{or_test} | \token{lambda_form}}
- \production{testlist}
- {\token{test} ( "," \token{test} )* [ "," ]}
\production{list_display}
- {"[" [\token{listmaker}] "]"}
- \production{listmaker}
- {\token{expression} ( \token{list_for}
- | ( "," \token{expression} )* [","] )}
- \production{list_iter}
- {\token{list_for} | \token{list_if}}
+ {"[" [\token{expression_list} | \token{list_comprehension}] "]"}
+ \production{list_comprehension}
+ {\token{expression} \token{list_for}}
\production{list_for}
- {"for" \token{expression_list} "in" \token{testlist}
+ {"for" \token{target_list} "in" \token{old_expression_list}
[\token{list_iter}]}
+ \production{old_expression_list}
+ {\token{old_expression}
+ [("," \token{old_expression})+ [","]]}
+ \production{list_iter}
+ {\token{list_for} | \token{list_if}}
\production{list_if}
- {"if" \token{test} [\token{list_iter}]}
+ {"if" \token{old_expression} [\token{list_iter}]}
\end{productionlist}
A list display yields a new list object. Its contents are specified
@@ -200,19 +199,18 @@ A generator expression is a compact generator notation in parentheses:
\begin{productionlist}
\production{generator_expression}
- {"(" \token{test} \token{genexpr_for} ")"}
+ {"(" \token{expression} \token{genexpr_for} ")"}
\production{genexpr_for}
- {"for" \token{expression_list} "in" \token{test}
+ {"for" \token{target_list} "in" \token{or_test}
[\token{genexpr_iter}]}
\production{genexpr_iter}
{\token{genexpr_for} | \token{genexpr_if}}
\production{genexpr_if}
- {"if" \token{test} [\token{genexpr_iter}]}
+ {"if" \token{old_expression} [\token{genexpr_iter}]}
\end{productionlist}
A generator expression yields a new generator object.
\obindex{generator}
-\obindex{generator expression}
It consists of a single expression followed by at least one
\keyword{for} clause and zero or more \keyword{for} or \keyword{if}
clauses. The iterating values of the new generator are those that
@@ -268,6 +266,142 @@ stored for a given key value prevails.
\indexii{immutable}{object}
+\subsection{Yield expressions\label{yieldexpr}}
+\kwindex{yield}
+\indexii{yield}{expression}
+\indexii{generator}{function}
+
+\begin{productionlist}
+ \production{yield_atom}
+ {"(" \token{yield_expression} ")"}
+ \production{yield_expression}
+ {"yield" [\token{expression_list}]}
+\end{productionlist}
+
+\versionadded{2.5}
+
+The \keyword{yield} expression is only used when defining a generator
+function, and can only be used in the body of a function definition.
+Using a \keyword{yield} expression in a function definition is
+sufficient to cause that definition to create a generator function
+instead of a normal function.
+
+When a generator function is called, it returns an iterator known as a
+generator. That generator then controls the execution of a generator
+function. The execution starts when one of the generator's methods is
+called. At that time, the execution proceeds to the first
+\keyword{yield} expression, where it is suspended again, returning the
+value of \grammartoken{expression_list} to generator's caller. By
+suspended we mean that all local state is retained, including the
+current bindings of local variables, the instruction pointer, and the
+internal evaluation stack. When the execution is resumed by calling
+one of the generator's methods, the function can proceed exactly as
+if the \keyword{yield} expression was just another external call.
+The value of the \keyword{yield} expression after resuming depends on
+the method which resumed the execution.
+
+\index{coroutine}
+
+All of this makes generator functions quite similar to coroutines; they
+yield multiple times, they have more than one entry point and their
+execution can be suspended. The only difference is that a generator
+function cannot control where should the execution continue after it
+yields; the control is always transfered to the generator's caller.
+
+\obindex{generator}
+
+The following generator's methods can be used to control the execution
+of a generator function:
+
+\exindex{StopIteration}
+
+\begin{methoddesc}[generator]{next}{}
+ Starts the execution of a generator function or resumes it at the
+ last executed \keyword{yield} expression. When a generator function
+ is resumed with a \method{next()} method, the current \keyword{yield}
+ expression always evaluates to \constant{None}. The execution then
+ continues to the next \keyword{yield} expression, where the generator
+ is suspended again, and the value of the
+ \grammartoken{expression_list} is returned to \method{next()}'s
+ caller. If the generator exits without yielding another value, a
+ \exception{StopIteration} exception is raised.
+\end{methoddesc}
+
+\begin{methoddesc}[generator]{send}{value}
+ Resumes the execution and ``sends'' a value into the generator
+ function. The \code{value} argument becomes the result of the
+ current \keyword{yield} expression. The \method{send()} method
+ returns the next value yielded by the generator, or raises
+ \exception{StopIteration} if the generator exits without yielding
+ another value.
+ When \method{send()} is called to start the generator, it must be
+ called with \constant{None} as the argument, because there is no
+ \keyword{yield} expression that could receieve the value.
+\end{methoddesc}
+
+\begin{methoddesc}[generator]{throw}
+ {type\optional{, value\optional{, traceback}}}
+ Raises an exception of type \code{type} at the point where generator
+ was paused, and returns the next value yielded by the generator
+ function. If the generator exits without yielding another value, a
+ \exception{StopIteration} exception is raised. If the generator
+ function does not catch the passed-in exception, or raises a
+ different exception, then that exception propagates to the caller.
+\end{methoddesc}
+
+\exindex{GeneratorExit}
+
+\begin{methoddesc}[generator]{close}{}
+ Raises a \exception{GeneratorExit} at the point where the generator
+ function was paused. If the generator function then raises
+ \exception{StopIteration} (by exiting normally, or due to already
+ being closed) or \exception{GeneratorExit} (by not catching the
+ exception), close returns to its caller. If the generator yields a
+ value, a \exception{RuntimeError} is raised. If the generator raises
+ any other exception, it is propagated to the caller. \method{close}
+ does nothing if the generator has already exited due to an exception
+ or normal exit.
+\end{methoddesc}
+
+Here is a simple example that demonstrates the behavior of generators
+and generator functions:
+
+\begin{verbatim}
+>>> def echo(value=None):
+... print "Execution starts when 'next()' is called for the first time."
+... try:
+... while True:
+... try:
+... value = (yield value)
+... except GeneratorExit:
+... # never catch GeneratorExit
+... raise
+... except Exception, e:
+... value = e
+... finally:
+... print "Don't forget to clean up when 'close()' is called."
+...
+>>> generator = echo(1)
+>>> print generator.next()
+Execution starts when 'next()' is called for the first time.
+1
+>>> print generator.next()
+None
+>>> print generator.send(2)
+2
+>>> generator.throw(TypeError, "spam")
+TypeError('spam',)
+>>> generator.close()
+Don't forget to clean up when 'close()' is called.
+\end{verbatim}
+
+\begin{seealso}
+ \seepep{0342}{Coroutines via Enhanced Generators}
+ {The proposal to enhance the API and syntax of generators,
+ making them usable as simple coroutines.}
+\end{seealso}
+
+
\section{Primaries\label{primaries}}
\index{primary}
@@ -430,9 +564,8 @@ series of arguments:
\begin{productionlist}
\production{call}
- {\token{primary} "(" [\token{argument_list} [","]] ")"}
- {\token{primary} "(" [\token{argument_list} [","] |
- \token{test} \token{genexpr_for} ] ")"}
+ {\token{primary} "(" [\token{argument_list} [","]}
+ \productioncont{ | \token{expression} \token{genexpr_for}] ")"}
\production{argument_list}
{\token{positional_arguments} ["," \token{keyword_arguments}]}
\productioncont{ ["," "*" \token{expression}]}
@@ -765,10 +898,9 @@ The shifting operations have lower priority than the arithmetic
operations:
\begin{productionlist}
- % The empty groups below prevent conversion to guillemets.
\production{shift_expr}
{\token{a_expr}
- | \token{shift_expr} ( "<{}<" | ">{}>" ) \token{a_expr}}
+ | \token{shift_expr} ( "<<" | ">>" ) \token{a_expr}}
\end{productionlist}
These operators accept plain or long integers as arguments. The
@@ -966,14 +1098,18 @@ truth value.
\section{Boolean operations\label{Booleans}}
+\indexii{Conditional}{expression}
\indexii{Boolean}{operation}
Boolean operations have the lowest priority of all Python operations:
\begin{productionlist}
\production{expression}
- {\token{or_test} [\token{if} \token{or_test} \token{else}
- \token{test}] | \token{lambda_form}}
+ {\token{conditional_expression} | \token{lambda_form}}
+ \production{old_expression}
+ {\token{or_test} | \token{old_lambda_form}}
+ \production{conditional_expression}
+ {\token{or_test} ["if" \token{or_test} "else" \token{expression}]}
\production{or_test}
{\token{and_test} | \token{or_test} "or" \token{and_test}}
\production{and_test}
@@ -1025,6 +1161,8 @@ not \code{''}.)
\begin{productionlist}
\production{lambda_form}
{"lambda" [\token{parameter_list}]: \token{expression}}
+ \production{old_lambda_form}
+ {"lambda" [\token{parameter_list}]: \token{old_expression}}
\end{productionlist}
Lambda forms (lambda expressions) have the same syntactic position as
diff --git a/Doc/ref/ref6.tex b/Doc/ref/ref6.tex
index e92a63d..60e7b02 100644
--- a/Doc/ref/ref6.tex
+++ b/Doc/ref/ref6.tex
@@ -106,7 +106,8 @@ objects:
\begin{productionlist}
\production{assignment_stmt}
- {(\token{target_list} "=")+ \token{expression_list}}
+ {(\token{target_list} "=")+
+ (\token{expression_list} | \token{yield_expression})}
\production{target_list}
{\token{target} ("," \token{target})* [","]}
\production{target}
@@ -271,11 +272,11 @@ operation and an assignment statement:
\begin{productionlist}
\production{augmented_assignment_stmt}
- {\token{target} \token{augop} \token{expression_list}}
+ {\token{target} \token{augop}
+ (\token{expression_list} | \token{yield_expression})}
\production{augop}
{"+=" | "-=" | "*=" | "/=" | "\%=" | "**="}
- % The empty groups below prevent conversion to guillemets.
- \productioncont{| ">{}>=" | "<{}<=" | "\&=" | "\textasciicircum=" | "|="}
+ \productioncont{| ">>=" | "<<=" | "\&=" | "\textasciicircum=" | "|="}
\end{productionlist}
(See section~\ref{primaries} for the syntax definitions for the last
@@ -404,7 +405,7 @@ to include an \grammartoken{expression_list}. In that context, a bare
\begin{productionlist}
\production{yield_stmt}
- {"yield" \token{expression_list}}
+ {\token{yield_expression}}
\end{productionlist}
\index{generator!function}
@@ -573,15 +574,19 @@ It continues with the next cycle of the nearest enclosing loop.
\production{import_stmt}
{"import" \token{module} ["as" \token{name}]
( "," \token{module} ["as" \token{name}] )*}
- \productioncont{| "from" \token{module} "import" \token{identifier}
+ \productioncont{| "from" \token{relative_module} "import" \token{identifier}
["as" \token{name}]}
\productioncont{ ( "," \token{identifier} ["as" \token{name}] )*}
- \productioncont{| "from" \token{module} "import" "(" \token{identifier}
- ["as" \token{name}]}
+ \productioncont{| "from" \token{relative_module} "import" "("
+ \token{identifier} ["as" \token{name}]}
\productioncont{ ( "," \token{identifier} ["as" \token{name}] )* [","] ")"}
\productioncont{| "from" \token{module} "import" "*"}
\production{module}
{(\token{identifier} ".")* \token{identifier}}
+ \production{relative_module}
+ {"."* \token{module} | "."+}
+ \production{name}
+ {\token{identifier}}
\end{productionlist}
Import statements are executed in two steps: (1) find a module, and
@@ -700,8 +705,10 @@ before the release in which the feature becomes standard.
\begin{productionlist}[*]
\production{future_statement}
- {"from" "__future__" "import" feature ["as" name] ("," feature ["as" name])*}
- \productioncont{| "from" "__future__" "import" "(" feature ["as" name] ("," feature ["as" name])* [","] ")"}
+ {"from" "__future__" "import" feature ["as" name]}
+ \productioncont{ ("," feature ["as" name])*}
+ \productioncont{| "from" "__future__" "import" "(" feature ["as" name]}
+ \productioncont{ ("," feature ["as" name])* [","] ")"}
\production{feature}{identifier}
\production{name}{identifier}
\end{productionlist}
@@ -718,9 +725,10 @@ lines that can appear before a future statement are:
\end{itemize}
-The features recognized by Python 2.3 are \samp{generators},
-\samp{division} and \samp{nested_scopes}. \samp{generators} and
-\samp{nested_scopes} are redundant in 2.3 because they are always
+The features recognized by Python 2.5 are \samp{absolute_import},
+\samp{division}, \samp{generators}, \samp{nested_scopes} and
+\samp{with_statement}. \samp{generators} and \samp{nested_scopes}
+are redundant in Python version 2.3 and above because they are always
enabled.
A future statement is recognized and treated specially at compile
diff --git a/Doc/ref/ref7.tex b/Doc/ref/ref7.tex
index 6bc0b08..02f96a4 100644
--- a/Doc/ref/ref7.tex
+++ b/Doc/ref/ref7.tex
@@ -313,7 +313,7 @@ be encapsulated for convenient reuse.
\begin{productionlist}
\production{with_stmt}
- {"with" \token{expression} ["as" target] ":" \token{suite}}
+ {"with" \token{expression} ["as" \token{target}] ":" \token{suite}}
\end{productionlist}
The execution of the \keyword{with} statement proceeds as follows:
diff --git a/Doc/texinputs/python.sty b/Doc/texinputs/python.sty
index 3ce62f4..494323e 100644
--- a/Doc/texinputs/python.sty
+++ b/Doc/texinputs/python.sty
@@ -612,7 +612,7 @@
\newenvironment{cfuncdesc}[4][\py@badkey]{
\begin{fulllineitems}
\cfuncline{#2}{#3}{#4}
- \ifx#1\@undefined\else%
+ \ifx\@undefined#1\relax\else%
\emph{Return value: \textbf{#1}.}\\
\fi
}{\end{fulllineitems}}
@@ -629,7 +629,7 @@
\newenvironment{ctypedesc}[2][\py@badkey]{
\begin{fulllineitems}
\item[\bfcode{#2}%
- \ifx#1\@undefined%
+ \ifx\@undefined#1\relax%
\index{#2@{\py@idxcode{#2}} (C type)}
\else%
\index{#2@{\py@idxcode{#1}} (C type)}
@@ -712,7 +712,7 @@
% \begin{methoddesc}[classname]{methodname}{args}
\newcommand{\methodline}[3][\@undefined]{
\methodlineni{#2}{#3}
- \ifx#1\@undefined
+ \ifx\@undefined#1\relax
\index{#2@{\py@idxcode{#2()}} (\py@thisclass\ method)}
\else
\index{#2@{\py@idxcode{#2()}} (#1 method)}
@@ -720,7 +720,7 @@
}
\newenvironment{methoddesc}[3][\@undefined]{
\begin{fulllineitems}
- \ifx#1\@undefined
+ \ifx\@undefined#1\relax
\methodline{#2}{#3}
\else
\def\py@thisclass{#1}
@@ -740,7 +740,7 @@
% object data attribute --------------------------------------------------
% \begin{memberdesc}[classname]{membername}
\newcommand{\memberline}[2][\py@classbadkey]{%
- \ifx#1\@undefined
+ \ifx\@undefined#1\relax
\memberlineni{#2}
\index{#2@{\py@idxcode{#2}} (\py@thisclass\ attribute)}
\else
@@ -750,7 +750,7 @@
}
\newenvironment{memberdesc}[2][\py@classbadkey]{
\begin{fulllineitems}
- \ifx#1\@undefined
+ \ifx\@undefined#1\relax
\memberline{#2}
\else
\def\py@thisclass{#1}
@@ -1046,14 +1046,14 @@
% \versionchanged[short explanation]{2.0}
%
\newcommand{\versionadded}[2][\py@badkey]{%
- \ifx#1\@undefined%
+ \ifx\@undefined#1\relax%
{ New in version #2. }%
\else%
{ New in version #2:\ #1. }%
\fi%
}
\newcommand{\versionchanged}[2][\py@badkey]{%
- \ifx#1\@undefined%
+ \ifx\@undefined#1\relax%
{ Changed in version #2. }%
\else%
{ Changed in version #2:\ #1. }%
diff --git a/Doc/tut/tut.tex b/Doc/tut/tut.tex
index 4abd0bd..a5e535d 100644
--- a/Doc/tut/tut.tex
+++ b/Doc/tut/tut.tex
@@ -813,7 +813,7 @@ Traceback (most recent call last):
IndexError: string index out of range
\end{verbatim}
-The best way to remember how slices work is to think of the indices as
+One way to remember how slices work is to think of the indices as
pointing \emph{between} characters, with the left edge of the first
character numbered 0. Then the right edge of the last character of a
string of \var{n} characters has index \var{n}, for example:
@@ -4312,8 +4312,7 @@ class DerivedClassName(Base1, Base2, Base3):
<statement-N>
\end{verbatim}
-The only rule necessary to explain the semantics is the resolution
-rule used for class attribute references. This is depth-first,
+For old-style classes, the only rule is depth-first,
left-to-right. Thus, if an attribute is not found in
\class{DerivedClassName}, it is searched in \class{Base1}, then
(recursively) in the base classes of \class{Base1}, and only if it is
@@ -4328,16 +4327,26 @@ a name conflict with an attribute of \class{Base2}. The depth-first
rule makes no differences between direct and inherited attributes of
\class{Base1}.)
-It is clear that indiscriminate use of multiple inheritance is a
-maintenance nightmare, given the reliance in Python on conventions to
-avoid accidental name conflicts. A well-known problem with multiple
-inheritance is a class derived from two classes that happen to have a
-common base class. While it is easy enough to figure out what happens
-in this case (the instance will have a single copy of ``instance
-variables'' or data attributes used by the common base class), it is
-not clear that these semantics are in any way useful.
+For new-style classes, the method resolution order changes dynamically
+to support cooperative calls to \function{super()}. This approach
+is known in some other multiple-inheritance languages as call-next-method
+and is more powerful than the super call found in single-inheritance languages.
+
+With new-style classes, dynamic ordering is necessary because all
+cases of multiple inheritance exhibit one or more diamond relationships
+(where one at least one of the parent classes can be accessed through
+multiple paths from the bottommost class). For example, all new-style
+classes inherit from \class{object}, so any case of multiple inheritance
+provides more than one path to reach \class{object}. To keep the
+base classes from being accessed more than once, the dynamic algorithm
+linearizes the search order in a way that preserves the left-to-right
+ordering specified in each class, that calls each parent only once, and
+that is monotonic (meaning that a class can be subclassed without affecting
+the precedence order of its parents). Taken together, these properties
+make it possible to design reliable and extensible classes with
+multiple inheritance. For more detail, see
+\url{http://www.python.org/download/releases/2.3/mro/}.
-%% XXX Add rules for new-style MRO?
\section{Private Variables \label{private}}
diff --git a/Doc/whatsnew/whatsnew23.tex b/Doc/whatsnew/whatsnew23.tex
index 72fd306..7c92be2 100644
--- a/Doc/whatsnew/whatsnew23.tex
+++ b/Doc/whatsnew/whatsnew23.tex
@@ -896,7 +896,7 @@ by Kevin Altis, Dave Cole, Andrew McNamara, Skip Montanaro, Cliff Wells.
\end{seealso}
%======================================================================
-\section{PEP 307: Pickle Enhancements \label{section-pep305}}
+\section{PEP 307: Pickle Enhancements \label{section-pep307}}
The \module{pickle} and \module{cPickle} modules received some
attention during the 2.3 development cycle. In 2.2, new-style classes
diff --git a/Doc/whatsnew/whatsnew24.tex b/Doc/whatsnew/whatsnew24.tex
index 096b1ec..399bc0e 100644
--- a/Doc/whatsnew/whatsnew24.tex
+++ b/Doc/whatsnew/whatsnew24.tex
@@ -1291,7 +1291,7 @@ default is 2.
[1, 2, 3]
>>> list(i2) # Run the second iterator to exhaustion
[1, 2, 3]
->\end{verbatim}
+\end{verbatim}
Note that \function{tee()} has to keep copies of the values returned
by the iterator; in the worst case, it may need to keep all of them.
diff --git a/Doc/whatsnew/whatsnew25.tex b/Doc/whatsnew/whatsnew25.tex
index fce3927..b2f7380 100644
--- a/Doc/whatsnew/whatsnew25.tex
+++ b/Doc/whatsnew/whatsnew25.tex
@@ -1294,6 +1294,17 @@ the function is 6 times faster.
(Contributed by Alan McIntyre and committed at the NeedForSpeed sprint.)
% Patch 1442927
+\item It's now illegal to mix iterating over a file
+with \code{for line in \var{file}} and calling
+the file object's \method{read()}/\method{readline()}/\method{readlines()}
+methods. Iteration uses an internal buffer and the
+\method{read*()} methods don't use that buffer.
+Instead they would return the data following the buffer, causing the
+data to appear out of order. Mixing iteration and these methods will
+now trigger a \exception{ValueError} from the \method{read*()} method.
+(Implemented by Thomas Wouters.)
+% Patch 1397960
+
\item The \module{struct} module now compiles structure format
strings into an internal representation and caches this
representation, yielding a 20\% speedup. (Contributed by Bob Ippolito
@@ -1704,8 +1715,8 @@ article about them is at \url{http://www.linuxjournal.com/article/7356}.
In Python code, netlink addresses are represented as a tuple of 2 integers,
\code{(\var{pid}, \var{group_mask})}.
-Two new methods on socket objects, \method{recv_buf(\var{buffer})} and
-\method{recvfrom_buf(\var{buffer})}, store the received data in an object
+Two new methods on socket objects, \method{recv_into(\var{buffer})} and
+\method{recvfrom_into(\var{buffer})}, store the received data in an object
that supports the buffer protocol instead of returning the data as a
string. This means you can put the data directly into an array or a
memory-mapped file.
diff --git a/Doc/whatsnew/whatsnew26.tex b/Doc/whatsnew/whatsnew26.tex
index 3fa9b69..3543d9d 100644
--- a/Doc/whatsnew/whatsnew26.tex
+++ b/Doc/whatsnew/whatsnew26.tex
@@ -2,6 +2,46 @@
\usepackage{distutils}
% $Id$
+% Rules for maintenance:
+%
+% * Anyone can add text to this document. Do not spend very much time
+% on the wording of your changes, because your text will probably
+% get rewritten to some degree.
+%
+% * The maintainer will go through Misc/NEWS periodically and add
+% changes; it's therefore more important to add your changes to
+% Misc/NEWS than to this file.
+%
+% * This is not a complete list of every single change; completeness
+% is the purpose of Misc/NEWS. Some changes I consider too small
+% or esoteric to include. If such a change is added to the text,
+% I'll just remove it. (This is another reason you shouldn't spend
+% too much time on writing your addition.)
+%
+% * If you want to draw your new text to the attention of the
+% maintainer, add 'XXX' to the beginning of the paragraph or
+% section.
+%
+% * It's OK to just add a fragmentary note about a change. For
+% example: "XXX Describe the transmogrify() function added to the
+% socket module." The maintainer will research the change and
+% write the necessary text.
+%
+% * You can comment out your additions if you like, but it's not
+% necessary (especially when a final release is some months away).
+%
+% * Credit the author of a patch or bugfix. Just the name is
+% sufficient; the e-mail address isn't necessary.
+%
+% * It's helpful to add the bug/patch number as a comment:
+%
+% % Patch 12345
+% XXX Describe the transmogrify() function added to the socket
+% module.
+% (Contributed by P.Y. Developer.)
+%
+% This saves the maintainer the effort of going through the SVN log
+% when researching a change.
\title{What's New in Python 2.6}
\release{0.0}
@@ -29,6 +69,9 @@ rationale, refer to the PEP for a particular new feature.
% Large, PEP-level features and changes should be described here.
+% Should there be a new section here for 3k migration?
+% Or perhaps a more general section describing module changes/deprecation?
+% sets module deprecated
%======================================================================
\section{Other Language Changes}
@@ -37,7 +80,13 @@ Here are all of the changes that Python 2.6 makes to the core Python
language.
\begin{itemize}
-\item TBD
+
+% Bug 1569356
+\item An obscure change: when you use the the \function{locals()}
+function inside a \keyword{class} statement, the resulting dictionary
+no longer returns free variables. (Free variables, in this case, are
+variables referred to in the \keyword{class} statement
+that aren't attributes of the class.)
\end{itemize}
@@ -47,7 +96,10 @@ language.
\begin{itemize}
-\item Optimizations should be described here.
+% Patch 1624059
+\item Internally, a bit is now set in type objects to indicate some of
+the standard built-in types. This speeds up checking if an object is
+a subclass of one of these types. (Contributed by Neal Norwitz.)
\end{itemize}
@@ -67,6 +119,71 @@ details.
\begin{itemize}
+\item New data type in the \module{collections} module:
+\class{NamedTuple(\var{typename}, \var{fieldnames})} is a factory function that
+creates subclasses of the standard tuple whose fields are accessible
+by name as well as index. For example:
+
+\begin{verbatim}
+var_type = collections.NamedTuple('variable',
+ 'id name type size')
+var = var_type(1, 'frequency', 'int', 4)
+
+print var[0], var.id # Equivalent
+print var[2], var.type # Equivalent
+\end{verbatim}
+
+(Contributed by Raymond Hettinger.)
+
+\item New method in the \module{curses} module:
+for a window, \method{chgat()} changes the display characters for a
+certain number of characters on a single line.
+
+\begin{verbatim}
+# Boldface text starting at y=0,x=21
+# and affecting the rest of the line.
+stdscr.chgat(0,21, curses.A_BOLD)
+\end{verbatim}
+
+(Contributed by Fabian Kreutz.)
+
+\item New function in the \module{heapq} module:
+\function{merge(iter1, iter2, ...)}
+takes any number of iterables that return data
+\emph{in sorted order},
+and
+returns a new iterator that returns the contents of
+all the iterators, also in sorted order. For example:
+
+\begin{verbatim}
+heapq.merge([1, 3, 5, 9], [2, 8, 16]) ->
+ [1, 2, 3, 5, 8, 9, 16]
+\end{verbatim}
+
+(Contributed by Raymond Hettinger.)
+
+\item New function in the \module{itertools} module:
+\function{izip_longest(iter1, iter2, ...\optional{, fillvalue})}
+makes tuples from each of the elements; if some of the iterables
+are shorter than others, the missing values
+are set to \var{fillvalue}. For example:
+
+\begin{verbatim}
+itertools.izip_longest([1,2,3], [1,2,3,4,5]) ->
+ [(1, 1), (2, 2), (3, 3), (None, 4), (None, 5)]
+\end{verbatim}
+
+(Contributed by Raymond Hettinger.)
+
+% Patch #1490190
+\item New functions in the \module{posix} module: \function{chflags()}
+and \function{lchflags()} are wrappers for the corresponding system
+calls (where they're available). Constants for the flag values are
+defined in the \module{stat} module; some possible values include
+\constant{UF_IMMUTABLE} to signal the file may not be changed and
+\constant{UF_APPEND} to indicate that data can only be appended to the
+file. (Contributed by M. Levinson.)
+
\item The \module{smtplib} module now supports SMTP over
SSL thanks to the addition of the \class{SMTP_SSL} class.
This class supports an interface identical to the existing \class{SMTP}