[Stackless-checkins] r51275 - in stackless/trunk: Doc/api/api.tex Doc/api/exceptions.tex Doc/api/intro.tex Doc/api/refcounts.dat Doc/commontex/boilerplate.tex Doc/dist/dist.tex Doc/doc/doc.tex Doc/ext/newtypes.tex Doc/ext/windows.tex Doc/howto/doanddont.tex Doc/inst/inst.tex Doc/lib/email.tex Doc/lib/emailgenerator.tex Doc/lib/lib.tex Doc/lib/libanydbm.tex Doc/lib/libbase64.tex Doc/lib/libbinascii.tex Doc/lib/libbsddb.tex Doc/lib/libcompileall.tex Doc/lib/libcsv.tex Doc/lib/libctypes.tex Doc/lib/libfuncs.tex Doc/lib/libgettext.tex Doc/lib/libimp.tex Doc/lib/libinspect.tex Doc/lib/liblogging.tex Doc/lib/libmailbox.tex Doc/lib/libmimetypes.tex Doc/lib/libnew.tex Doc/lib/liboptparse.tex Doc/lib/libossaudiodev.tex Doc/lib/libpickle.tex Doc/lib/libpkgutil.tex Doc/lib/libposixpath.tex Doc/lib/librandom.tex Doc/lib/libre.tex Doc/lib/libreadline.tex Doc/lib/libshelve.tex Doc/lib/libsocket.tex Doc/lib/libsocksvr.tex Doc/lib/libsqlite3.tex Doc/lib/libstdtypes.tex Doc/lib/libstringio.tex Doc/lib/l! ibsubprocess.tex Doc/lib/libsys.tex Doc/lib/libtime.tex Doc/lib/libturtle.tex Doc/lib/libtypes.tex Doc/lib/libundoc.tex Doc/lib/libunicodedata.tex Doc/lib/liburllib.tex Doc/lib/liburllib2.tex Doc/lib/libuuid.tex Doc/lib/libweakref.tex Doc/lib/libwebbrowser.tex Doc/lib/libzipfile.tex Doc/lib/sqlite3/complete_statement.py Doc/lib/tkinter.tex Doc/mac/libmacfs.tex Doc/mac/libmacos.tex Doc/mac/using.tex Doc/ref/ref3.tex Doc/whatsnew/whatsnew20.tex Doc/whatsnew/whatsnew21.tex Doc/whatsnew/whatsnew23.tex Doc/whatsnew/whatsnew24.tex Doc/whatsnew/whatsnew25.tex Include/patchlevel.h Include/pyerrors.h Include/weakrefobject.h Lib/binhex.py Lib/bsddb/test/test_basics.py Lib/compiler/future.py Lib/compiler/transformer.py Lib/ctypes/__init__.py Lib/ctypes/test/test_varsize_struct.py Lib/ctypes/util.py Lib/distutils/__init__.py Lib/distutils/msvccompiler.py Lib/doctest.py Lib/email/__init__.py Lib/email/message.py Lib/email/test/test_email.py Lib/email/test/test_email_renamed.py Lib/email! /utils.py Lib/encodings/mbcs.py Lib/gzip.py Lib/httplib.py Lib/idlelib/CREDITS.txt Lib/idlelib/CallTipWindow.py Lib/idlelib/CallTips.py Lib/idlelib/CodeContext.py Lib/idlelib/ColorDelegator.py Lib/idlelib/EditorWindow.py Lib/idlelib/NEWS.txt Lib/idlelib/ParenMatch.py Lib/idlelib/PyShell.py Lib/idlelib/ScriptBinding.py Lib/id
richard.tew
python-checkins at python.org
Mon Aug 14 12:39:05 CEST 2006
Author: richard.tew
Date: Mon Aug 14 12:38:35 2006
New Revision: 51275
Added:
stackless/trunk/Lib/test/crashers/recursion_limit_too_high.py
- copied unchanged from r51065, python/trunk/Lib/test/crashers/recursion_limit_too_high.py
stackless/trunk/Lib/xml/ (props changed)
- copied from r51065, python/trunk/Lib/xml/
stackless/trunk/Mac/Modules/MacOS.c
- copied unchanged from r51065, python/trunk/Mac/Modules/MacOS.c
stackless/trunk/Misc/README.coverity
- copied unchanged from r51065, python/trunk/Misc/README.coverity
stackless/trunk/Misc/README.klocwork
- copied unchanged from r51065, python/trunk/Misc/README.klocwork
stackless/trunk/Modules/_typesmodule.c
- copied unchanged from r51065, python/trunk/Modules/_typesmodule.c
stackless/trunk/PC/os2emx/python25.def
- copied unchanged from r51065, python/trunk/PC/os2emx/python25.def
stackless/trunk/PCbuild/build_ssl.bat
- copied unchanged from r51065, python/trunk/PCbuild/build_ssl.bat
Removed:
stackless/trunk/Lib/xml.py
stackless/trunk/Lib/xmlcore/
stackless/trunk/Mac/Modules/macosmodule.c
stackless/trunk/PC/os2emx/python24.def
Modified:
stackless/trunk/Doc/api/api.tex
stackless/trunk/Doc/api/exceptions.tex
stackless/trunk/Doc/api/intro.tex
stackless/trunk/Doc/api/refcounts.dat
stackless/trunk/Doc/commontex/boilerplate.tex
stackless/trunk/Doc/dist/dist.tex
stackless/trunk/Doc/doc/doc.tex
stackless/trunk/Doc/ext/newtypes.tex
stackless/trunk/Doc/ext/windows.tex
stackless/trunk/Doc/howto/doanddont.tex
stackless/trunk/Doc/inst/inst.tex
stackless/trunk/Doc/lib/email.tex
stackless/trunk/Doc/lib/emailgenerator.tex
stackless/trunk/Doc/lib/lib.tex
stackless/trunk/Doc/lib/libanydbm.tex
stackless/trunk/Doc/lib/libbase64.tex
stackless/trunk/Doc/lib/libbinascii.tex
stackless/trunk/Doc/lib/libbsddb.tex
stackless/trunk/Doc/lib/libcompileall.tex
stackless/trunk/Doc/lib/libcsv.tex
stackless/trunk/Doc/lib/libctypes.tex
stackless/trunk/Doc/lib/libfuncs.tex
stackless/trunk/Doc/lib/libgettext.tex
stackless/trunk/Doc/lib/libimp.tex
stackless/trunk/Doc/lib/libinspect.tex
stackless/trunk/Doc/lib/liblogging.tex
stackless/trunk/Doc/lib/libmailbox.tex
stackless/trunk/Doc/lib/libmimetypes.tex
stackless/trunk/Doc/lib/libnew.tex
stackless/trunk/Doc/lib/liboptparse.tex
stackless/trunk/Doc/lib/libossaudiodev.tex
stackless/trunk/Doc/lib/libpickle.tex
stackless/trunk/Doc/lib/libpkgutil.tex
stackless/trunk/Doc/lib/libposixpath.tex
stackless/trunk/Doc/lib/librandom.tex
stackless/trunk/Doc/lib/libre.tex
stackless/trunk/Doc/lib/libreadline.tex
stackless/trunk/Doc/lib/libshelve.tex
stackless/trunk/Doc/lib/libsocket.tex
stackless/trunk/Doc/lib/libsocksvr.tex
stackless/trunk/Doc/lib/libsqlite3.tex
stackless/trunk/Doc/lib/libstdtypes.tex
stackless/trunk/Doc/lib/libstringio.tex
stackless/trunk/Doc/lib/libsubprocess.tex
stackless/trunk/Doc/lib/libsys.tex
stackless/trunk/Doc/lib/libtime.tex
stackless/trunk/Doc/lib/libturtle.tex
stackless/trunk/Doc/lib/libtypes.tex
stackless/trunk/Doc/lib/libundoc.tex
stackless/trunk/Doc/lib/libunicodedata.tex
stackless/trunk/Doc/lib/liburllib.tex
stackless/trunk/Doc/lib/liburllib2.tex
stackless/trunk/Doc/lib/libuuid.tex
stackless/trunk/Doc/lib/libweakref.tex
stackless/trunk/Doc/lib/libwebbrowser.tex
stackless/trunk/Doc/lib/libzipfile.tex
stackless/trunk/Doc/lib/sqlite3/complete_statement.py
stackless/trunk/Doc/lib/tkinter.tex
stackless/trunk/Doc/mac/libmacfs.tex
stackless/trunk/Doc/mac/libmacos.tex
stackless/trunk/Doc/mac/using.tex
stackless/trunk/Doc/ref/ref3.tex
stackless/trunk/Doc/whatsnew/whatsnew20.tex
stackless/trunk/Doc/whatsnew/whatsnew21.tex
stackless/trunk/Doc/whatsnew/whatsnew23.tex
stackless/trunk/Doc/whatsnew/whatsnew24.tex
stackless/trunk/Doc/whatsnew/whatsnew25.tex
stackless/trunk/Include/patchlevel.h
stackless/trunk/Include/pyerrors.h
stackless/trunk/Include/weakrefobject.h
stackless/trunk/Lib/binhex.py
stackless/trunk/Lib/bsddb/test/test_basics.py
stackless/trunk/Lib/compiler/future.py
stackless/trunk/Lib/compiler/transformer.py
stackless/trunk/Lib/ctypes/__init__.py
stackless/trunk/Lib/ctypes/test/test_varsize_struct.py
stackless/trunk/Lib/ctypes/util.py
stackless/trunk/Lib/distutils/__init__.py
stackless/trunk/Lib/distutils/msvccompiler.py
stackless/trunk/Lib/doctest.py
stackless/trunk/Lib/email/__init__.py
stackless/trunk/Lib/email/message.py
stackless/trunk/Lib/email/test/test_email.py
stackless/trunk/Lib/email/test/test_email_renamed.py
stackless/trunk/Lib/email/utils.py
stackless/trunk/Lib/encodings/mbcs.py
stackless/trunk/Lib/gzip.py
stackless/trunk/Lib/httplib.py
stackless/trunk/Lib/idlelib/CREDITS.txt
stackless/trunk/Lib/idlelib/CallTipWindow.py
stackless/trunk/Lib/idlelib/CallTips.py
stackless/trunk/Lib/idlelib/CodeContext.py
stackless/trunk/Lib/idlelib/ColorDelegator.py
stackless/trunk/Lib/idlelib/EditorWindow.py
stackless/trunk/Lib/idlelib/NEWS.txt
stackless/trunk/Lib/idlelib/ParenMatch.py
stackless/trunk/Lib/idlelib/PyShell.py
stackless/trunk/Lib/idlelib/ScriptBinding.py
stackless/trunk/Lib/idlelib/config-keys.def
stackless/trunk/Lib/idlelib/idlever.py
stackless/trunk/Lib/idlelib/keybindingDialog.py
stackless/trunk/Lib/idlelib/macosxSupport.py
stackless/trunk/Lib/inspect.py
stackless/trunk/Lib/lib-tk/Tkinter.py
stackless/trunk/Lib/lib-tk/turtle.py
stackless/trunk/Lib/logging/handlers.py
stackless/trunk/Lib/mailbox.py
stackless/trunk/Lib/optparse.py
stackless/trunk/Lib/os.py
stackless/trunk/Lib/pdb.py
stackless/trunk/Lib/pkgutil.py
stackless/trunk/Lib/popen2.py
stackless/trunk/Lib/pydoc.py
stackless/trunk/Lib/shutil.py
stackless/trunk/Lib/socket.py
stackless/trunk/Lib/struct.py
stackless/trunk/Lib/subprocess.py
stackless/trunk/Lib/tarfile.py
stackless/trunk/Lib/test/crashers/README (props changed)
stackless/trunk/Lib/test/crashers/bogus_code_obj.py
stackless/trunk/Lib/test/crashers/gc_inspection.py
stackless/trunk/Lib/test/crashers/recursive_call.py
stackless/trunk/Lib/test/output/test_ossaudiodev
stackless/trunk/Lib/test/string_tests.py
stackless/trunk/Lib/test/test_bsddb.py
stackless/trunk/Lib/test/test_compiler.py
stackless/trunk/Lib/test/test_defaultdict.py
stackless/trunk/Lib/test/test_dis.py
stackless/trunk/Lib/test/test_doctest.py
stackless/trunk/Lib/test/test_email_codecs.py
stackless/trunk/Lib/test/test_filecmp.py
stackless/trunk/Lib/test/test_generators.py
stackless/trunk/Lib/test/test_getargs2.py
stackless/trunk/Lib/test/test_grammar.py
stackless/trunk/Lib/test/test_inspect.py
stackless/trunk/Lib/test/test_iterlen.py
stackless/trunk/Lib/test/test_mailbox.py
stackless/trunk/Lib/test/test_mimetools.py
stackless/trunk/Lib/test/test_mimetypes.py
stackless/trunk/Lib/test/test_minidom.py
stackless/trunk/Lib/test/test_optparse.py
stackless/trunk/Lib/test/test_ossaudiodev.py
stackless/trunk/Lib/test/test_sax.py
stackless/trunk/Lib/test/test_shutil.py
stackless/trunk/Lib/test/test_signal.py
stackless/trunk/Lib/test/test_socket.py
stackless/trunk/Lib/test/test_subprocess.py
stackless/trunk/Lib/test/test_sys.py
stackless/trunk/Lib/test/test_time.py
stackless/trunk/Lib/test/test_traceback.py
stackless/trunk/Lib/test/test_urllib2.py
stackless/trunk/Lib/test/test_uuid.py
stackless/trunk/Lib/test/test_winreg.py
stackless/trunk/Lib/test/test_xml_etree.py
stackless/trunk/Lib/test/test_xml_etree_c.py
stackless/trunk/Lib/traceback.py
stackless/trunk/Lib/types.py
stackless/trunk/Lib/urllib.py
stackless/trunk/Lib/urllib2.py
stackless/trunk/Lib/uuid.py
stackless/trunk/Lib/xml/dom/ (props changed)
stackless/trunk/Lib/xml/parsers/ (props changed)
stackless/trunk/Lib/xml/sax/ (props changed)
stackless/trunk/Lib/zipfile.py
stackless/trunk/Mac/BuildScript/README.txt
stackless/trunk/Mac/BuildScript/scripts/postflight.patch-profile
stackless/trunk/Mac/IDLE/config-main.def
stackless/trunk/Mac/PythonLauncher/FileSettings.m
stackless/trunk/Makefile.pre.in
stackless/trunk/Misc/ACKS
stackless/trunk/Misc/NEWS
stackless/trunk/Misc/README.OpenBSD (props changed)
stackless/trunk/Misc/RPM/python-2.5.spec
stackless/trunk/Misc/build.sh
stackless/trunk/Misc/python-config.in
stackless/trunk/Modules/_bsddb.c
stackless/trunk/Modules/_codecsmodule.c
stackless/trunk/Modules/_ctypes/_ctypes.c
stackless/trunk/Modules/_ctypes/callbacks.c
stackless/trunk/Modules/_ctypes/callproc.c
stackless/trunk/Modules/_ctypes/cfield.c
stackless/trunk/Modules/_ctypes/ctypes.h
stackless/trunk/Modules/_ctypes/libffi/configure
stackless/trunk/Modules/_ctypes/libffi/configure.ac
stackless/trunk/Modules/_ctypes/stgdict.c
stackless/trunk/Modules/_cursesmodule.c
stackless/trunk/Modules/_sqlite/cursor.c
stackless/trunk/Modules/_sqlite/util.c
stackless/trunk/Modules/_sqlite/util.h
stackless/trunk/Modules/_struct.c
stackless/trunk/Modules/_testcapimodule.c
stackless/trunk/Modules/_tkinter.c
stackless/trunk/Modules/_weakref.c
stackless/trunk/Modules/bz2module.c
stackless/trunk/Modules/cPickle.c
stackless/trunk/Modules/collectionsmodule.c
stackless/trunk/Modules/config.c.in
stackless/trunk/Modules/fcntlmodule.c
stackless/trunk/Modules/itertoolsmodule.c
stackless/trunk/Modules/main.c
stackless/trunk/Modules/posixmodule.c
stackless/trunk/Modules/readline.c
stackless/trunk/Modules/socketmodule.c
stackless/trunk/Modules/spwdmodule.c
stackless/trunk/Modules/timemodule.c
stackless/trunk/Modules/unicodedata.c
stackless/trunk/Modules/zlib/README (props changed)
stackless/trunk/Objects/codeobject.c
stackless/trunk/Objects/complexobject.c
stackless/trunk/Objects/dictobject.c
stackless/trunk/Objects/fileobject.c
stackless/trunk/Objects/frameobject.c
stackless/trunk/Objects/funcobject.c
stackless/trunk/Objects/listsort.txt
stackless/trunk/Objects/longobject.c
stackless/trunk/Objects/setobject.c
stackless/trunk/Objects/stringobject.c
stackless/trunk/Objects/typeobject.c
stackless/trunk/Objects/unicodeobject.c
stackless/trunk/Objects/weakrefobject.c
stackless/trunk/PC/_winreg.c
stackless/trunk/PC/config.c
stackless/trunk/PC/getpathp.c
stackless/trunk/PC/os2emx/Makefile
stackless/trunk/PC/os2emx/README.os2emx
stackless/trunk/PC/os2emx/config.c
stackless/trunk/PC/os2emx/pyconfig.h
stackless/trunk/PC/winsound.c
stackless/trunk/PCbuild/_ssl.vcproj
stackless/trunk/PCbuild/build_ssl.py
stackless/trunk/PCbuild/pythoncore.vcproj
stackless/trunk/PCbuild/readme.txt
stackless/trunk/Python/ast.c
stackless/trunk/Python/compile.c
stackless/trunk/Python/errors.c
stackless/trunk/Python/future.c
stackless/trunk/Python/getargs.c
stackless/trunk/Python/getopt.c
stackless/trunk/Python/import.c
stackless/trunk/Python/mactoolboxglue.c
stackless/trunk/Python/mystrtoul.c
stackless/trunk/Python/pyarena.c
stackless/trunk/Python/pystate.c
stackless/trunk/Python/pythonrun.c
stackless/trunk/Python/symtable.c
stackless/trunk/Python/sysmodule.c
stackless/trunk/Python/thread.c
stackless/trunk/Python/thread_os2.h
stackless/trunk/README
stackless/trunk/Tools/buildbot/kill_python.c
stackless/trunk/Tools/faqwiz/faqw.py
stackless/trunk/Tools/msi/uuids.py
stackless/trunk/Tools/scripts/README
stackless/trunk/Tools/webchecker/webchecker.py
stackless/trunk/configure
stackless/trunk/configure.in
stackless/trunk/pyconfig.h.in
Log:
Merged in the changes from 2.5b2 to 2.5b3 from the Python trunk. This was up to changelist 51065. A note for future merging efforts using tortoise svn, I need to specify the start revision (in this case the revision that 2.5b2 was branched to the tag at), otherwise it seems to do some strange backwards weirdo merge.
Modified: stackless/trunk/Doc/api/api.tex
==============================================================================
--- stackless/trunk/Doc/api/api.tex (original)
+++ stackless/trunk/Doc/api/api.tex Mon Aug 14 12:38:35 2006
@@ -48,11 +48,6 @@
\input{newtypes}
-% \chapter{Debugging \label{debugging}}
-%
-% XXX Explain Py_DEBUG, Py_TRACE_REFS, Py_REF_DEBUG.
-
-
\appendix
\chapter{Reporting Bugs}
\input{reportingbugs}
Modified: stackless/trunk/Doc/api/exceptions.tex
==============================================================================
--- stackless/trunk/Doc/api/exceptions.tex (original)
+++ stackless/trunk/Doc/api/exceptions.tex Mon Aug 14 12:38:35 2006
@@ -259,10 +259,14 @@
argument. It is mostly for internal use.
\end{cfuncdesc}
-\begin{cfuncdesc}{int}{PyErr_Warn}{PyObject *category, char *message}
+\begin{cfuncdesc}{int}{PyErr_WarnEx}{PyObject *category, char *message, int stacklevel}
Issue a warning message. The \var{category} argument is a warning
category (see below) or \NULL; the \var{message} argument is a
- message string.
+ message string. \var{stacklevel} is a positive number giving a
+ number of stack frames; the warning will be issued from the
+ currently executing line of code in that stack frame. A \var{stacklevel}
+ of 1 is the function calling \cfunction{PyErr_WarnEx()}, 2 is
+ the function above that, and so forth.
This function normally prints a warning message to \var{sys.stderr};
however, it is also possible that the user has specified that
@@ -294,6 +298,16 @@
command line documentation. There is no C API for warning control.
\end{cfuncdesc}
+\begin{cfuncdesc}{int}{PyErr_Warn}{PyObject *category, char *message}
+ Issue a warning message. The \var{category} argument is a warning
+ category (see below) or \NULL; the \var{message} argument is a
+ message string. The warning will appear to be issued from the function
+ calling \cfunction{PyErr_Warn()}, equivalent to calling
+ \cfunction{PyErr_WarnEx()} with a \var{stacklevel} of 1.
+
+ Deprecated; use \cfunction{PyErr_WarnEx()} instead.
+\end{cfuncdesc}
+
\begin{cfuncdesc}{int}{PyErr_WarnExplicit}{PyObject *category,
const char *message, const char *filename, int lineno,
const char *module, PyObject *registry}
Modified: stackless/trunk/Doc/api/intro.tex
==============================================================================
--- stackless/trunk/Doc/api/intro.tex (original)
+++ stackless/trunk/Doc/api/intro.tex Mon Aug 14 12:38:35 2006
@@ -580,3 +580,59 @@
Notice that \cfunction{Py_Finalize} does \emph{not} free all memory
allocated by the Python interpreter, e.g. memory allocated by extension
modules currently cannot be released.
+
+
+\section{Debugging Builds \label{debugging}}
+
+Python can be built with several macros to enable extra checks of the
+interpreter and extension modules. These checks tend to add a large
+amount of overhead to the runtime so they are not enabled by default.
+
+A full list of the various types of debugging builds is in the file
+\file{Misc/SpecialBuilds.txt} in the Python source distribution.
+Builds are available that support tracing of reference counts,
+debugging the memory allocator, or low-level profiling of the main
+interpreter loop. Only the most frequently-used builds will be
+described in the remainder of this section.
+
+Compiling the interpreter with the \csimplemacro{Py_DEBUG} macro
+defined produces what is generally meant by "a debug build" of Python.
+\csimplemacro{Py_DEBUG} is enabled in the \UNIX{} build by adding
+\longprogramopt{with-pydebug} to the \file{configure} command. It is also
+implied by the presence of the not-Python-specific
+\csimplemacro{_DEBUG} macro. When \csimplemacro{Py_DEBUG} is enabled
+in the \UNIX{} build, compiler optimization is disabled.
+
+In addition to the reference count debugging described below, the
+following extra checks are performed:
+
+\begin{itemize}
+ \item Extra checks are added to the object allocator.
+ \item Extra checks are added to the parser and compiler.
+ \item Downcasts from wide types to narrow types are checked for
+ loss of information.
+ \item A number of assertions are added to the dictionary and set
+ implementations. In addition, the set object acquires a
+ \method{test_c_api} method.
+ \item Sanity checks of the input arguments are added to frame
+ creation.
+ \item The storage for long ints is initialized with a known
+ invalid pattern to catch reference to uninitialized
+ digits.
+ \item Low-level tracing and extra exception checking are added
+ to the runtime virtual machine.
+ \item Extra checks are added to the memory arena implementation.
+ \item Extra debugging is added to the thread module.
+\end{itemize}
+
+There may be additional checks not mentioned here.
+
+Defining \csimplemacro{Py_TRACE_REFS} enables reference tracing. When
+defined, a circular doubly linked list of active objects is maintained
+by adding two extra fields to every \ctype{PyObject}. Total
+allocations are tracked as well. Upon exit, all existing references
+are printed. (In interactive mode this happens after every statement
+run by the interpreter.) Implied by \csimplemacro{Py_DEBUG}.
+
+Please refer to \file{Misc/SpecialBuilds.txt} in the Python source
+distribution for more detailed information.
Modified: stackless/trunk/Doc/api/refcounts.dat
==============================================================================
--- stackless/trunk/Doc/api/refcounts.dat (original)
+++ stackless/trunk/Doc/api/refcounts.dat Mon Aug 14 12:38:35 2006
@@ -303,6 +303,11 @@
PyErr_Warn:PyObject*:category:0:
PyErr_Warn:char*:message::
+PyErr_WarnEx:int:::
+PyErr_WarnEx:PyObject*:category:0:
+PyErr_WarnEx:const char*:message::
+PyErr_WarnEx:Py_ssize_t:stack_level::
+
PyEval_AcquireLock:void:::
PyEval_AcquireThread:void:::
Modified: stackless/trunk/Doc/commontex/boilerplate.tex
==============================================================================
--- stackless/trunk/Doc/commontex/boilerplate.tex (original)
+++ stackless/trunk/Doc/commontex/boilerplate.tex Mon Aug 14 12:38:35 2006
@@ -5,5 +5,5 @@
Email: \email{docs at python.org}
}
-\date{11th July, 2006} % XXX update before final release!
+\date{3rd August, 2006} % XXX update before final release!
\input{patchlevel} % include Python version information
Modified: stackless/trunk/Doc/dist/dist.tex
==============================================================================
--- stackless/trunk/Doc/dist/dist.tex (original)
+++ stackless/trunk/Doc/dist/dist.tex Mon Aug 14 12:38:35 2006
@@ -530,7 +530,7 @@
you can take advantage of the fact that header files are installed in a
consistent way by the Distutils \command{install\_header} command. For
example, the Numerical Python header files are installed (on a standard
-Unix installation) to \file{/usr/local/include/python1.5/Numerical}.
+\UNIX{} installation) to \file{/usr/local/include/python1.5/Numerical}.
(The exact location will differ according to your platform and Python
installation.) Since the Python include
directory---\file{/usr/local/include/python1.5} in this case---is always
@@ -2317,7 +2317,7 @@
\lineiii{name}{the full name of the extension, including any packages
--- ie. \emph{not} a filename or pathname, but Python dotted name}{string}
\lineiii{sources}{list of source filenames, relative to the distribution
-root (where the setup script lives), in Unix form (slash-separated) for
+root (where the setup script lives), in \UNIX{} form (slash-separated) for
portability. Source files may be C, \Cpp, SWIG (.i), platform-specific
resource files, or whatever else is recognized by the \command{build_ext}
command as source for a Python extension.}{string}
@@ -3099,7 +3099,7 @@
Move file \var{src} to \var{dst}. If \var{dst} is a directory, the file will
be moved into it with the same name; otherwise, \var{src} is just renamed
to \var{dst}. Returns the new full name of the file.
-\warning{Handles cross-device moves on Unix using \function{copy_file()}.
+\warning{Handles cross-device moves on \UNIX{} using \function{copy_file()}.
What about other systems???}
\end{funcdesc}
@@ -3142,7 +3142,7 @@
Return 'pathname' as a name that will work on the native filesystem,
i.e. split it on '/' and put it back together again using the current
directory separator. Needed because filenames in the setup script are
-always supplied in Unix style, and have to be converted to the local
+always supplied in \UNIX{} style, and have to be converted to the local
convention before we can actually use them in the filesystem. Raises
\exception{ValueError} on non-\UNIX-ish systems if \var{pathname} either
starts or ends with a slash.
@@ -3191,7 +3191,7 @@
\end{funcdesc}
\begin{funcdesc}{split_quoted}{s}
-Split a string up according to Unix shell-like rules for quotes and
+Split a string up according to \UNIX{} shell-like rules for quotes and
backslashes. In short: words are delimited by spaces, as long as those
spaces are not escaped by a backslash, or inside a quoted string.
Single and double quotes are equivalent, and the quote characters can
Modified: stackless/trunk/Doc/doc/doc.tex
==============================================================================
--- stackless/trunk/Doc/doc/doc.tex (original)
+++ stackless/trunk/Doc/doc/doc.tex Mon Aug 14 12:38:35 2006
@@ -187,6 +187,20 @@
Topics which are not covered in the Apple's style guide will be
discussed in this document if necessary.
+ Footnotes are generally discouraged due to the pain of using
+ footnotes in the HTML conversion of documents. Footnotes may be
+ used when they are the best way to present specific information.
+ When a footnote reference is added at the end of the sentence, it
+ should follow the sentence-ending punctuation. The \LaTeX{} markup
+ should appear something like this:
+
+\begin{verbatim}
+This sentence has a footnote reference.%
+ \footnote{This is the footnote text.}
+\end{verbatim}
+
+ Footnotes may appear in the middle of sentences where appropriate.
+
Many special names are used in the Python documentation, including
the names of operating systems, programming languages, standards
bodies, and the like. Many of these were assigned \LaTeX{} macros
@@ -281,10 +295,10 @@
to know about \LaTeX{} syntax.
A \dfn{comment} is started by the ``percent'' character
- (\character{\%}) and continues through the end of the line and all
- leading whitespace on the following line. This is a little
- different from any programming language I know of, so an example
- is in order:
+ (\character{\%}) and continues through the end of the line
+ \emph{and all leading whitespace on the following line}. This is
+ a little different from any programming language I know of, so an
+ example is in order:
\begin{verbatim}
This is text.% comment
Modified: stackless/trunk/Doc/ext/newtypes.tex
==============================================================================
--- stackless/trunk/Doc/ext/newtypes.tex (original)
+++ stackless/trunk/Doc/ext/newtypes.tex Mon Aug 14 12:38:35 2006
@@ -16,8 +16,9 @@
The way new types are defined changed dramatically (and for the
better) in Python 2.2. This document documents how to define new
types for Python 2.2 and later. If you need to support older
-versions of Python, you will need to refer to older versions of this
-documentation.
+versions of Python, you will need to refer to
+\ulink{older versions of this documentation}
+ {http://www.python.org/doc/versions/}.
\end{notice}
\section{The Basics
@@ -479,7 +480,7 @@
1
\item when we know that deallocation of the object\footnote{This is
true when we know that the object is a basic type, like a string or
- a float} will not cause any
+ a float.} will not cause any
calls back into our type's code
\item when decrementing a reference count in a \member{tp_dealloc}
handler when garbage-collections is not supported\footnote{We relied
@@ -791,9 +792,9 @@
In the second version of the \class{Noddy} example, we allowed any
kind of object to be stored in the \member{first} or \member{last}
-attributes\footnote{Even in the third version, we aren't guaranteed to
+attributes.\footnote{Even in the third version, we aren't guaranteed to
avoid cycles. Instances of string subclasses are allowed and string
-subclasses could allow cycles even if normal strings don't.}. This
+subclasses could allow cycles even if normal strings don't.} This
means that \class{Noddy} objects can participate in cycles:
\begin{verbatim}
@@ -1563,6 +1564,85 @@
avoiding the exception can yield slightly better performance. If an
actual error occurs, it should set an exception and return \NULL.
+
+\subsection{Weak Reference Support\label{weakref-support}}
+
+One of the goals of Python's weak-reference implementation is to allow
+any type to participate in the weak reference mechanism without
+incurring the overhead on those objects which do not benefit by weak
+referencing (such as numbers).
+
+For an object to be weakly referencable, the extension must include a
+\ctype{PyObject*} field in the instance structure for the use of the
+weak reference mechanism; it must be initialized to \NULL{} by the
+object's constructor. It must also set the \member{tp_weaklistoffset}
+field of the corresponding type object to the offset of the field.
+For example, the instance type is defined with the following
+structure:
+
+\begin{verbatim}
+typedef struct {
+ PyObject_HEAD
+ PyClassObject *in_class; /* The class object */
+ PyObject *in_dict; /* A dictionary */
+ PyObject *in_weakreflist; /* List of weak references */
+} PyInstanceObject;
+\end{verbatim}
+
+The statically-declared type object for instances is defined this way:
+
+\begin{verbatim}
+PyTypeObject PyInstance_Type = {
+ PyObject_HEAD_INIT(&PyType_Type)
+ 0,
+ "module.instance",
+
+ /* Lots of stuff omitted for brevity... */
+
+ Py_TPFLAGS_DEFAULT, /* tp_flags */
+ 0, /* tp_doc */
+ 0, /* tp_traverse */
+ 0, /* tp_clear */
+ 0, /* tp_richcompare */
+ offsetof(PyInstanceObject, in_weakreflist), /* tp_weaklistoffset */
+};
+\end{verbatim}
+
+The type constructor is responsible for initializing the weak reference
+list to \NULL:
+
+\begin{verbatim}
+static PyObject *
+instance_new() {
+ /* Other initialization stuff omitted for brevity */
+
+ self->in_weakreflist = NULL;
+
+ return (PyObject *) self;
+}
+\end{verbatim}
+
+The only further addition is that the destructor needs to call the
+weak reference manager to clear any weak references. This should be
+done before any other parts of the destruction have occurred, but is
+only required if the weak reference list is non-\NULL:
+
+\begin{verbatim}
+static void
+instance_dealloc(PyInstanceObject *inst)
+{
+ /* Allocate temporaries if needed, but do not begin
+ destruction just yet.
+ */
+
+ if (inst->in_weakreflist != NULL)
+ PyObject_ClearWeakRefs((PyObject *) inst);
+
+ /* Proceed with object destruction normally. */
+}
+\end{verbatim}
+
+
\subsection{More Suggestions}
Remember that you can omit most of these functions, in which case you
Modified: stackless/trunk/Doc/ext/windows.tex
==============================================================================
--- stackless/trunk/Doc/ext/windows.tex (original)
+++ stackless/trunk/Doc/ext/windows.tex Mon Aug 14 12:38:35 2006
@@ -28,13 +28,15 @@
\section{A Cookbook Approach \label{win-cookbook}}
There are two approaches to building extension modules on Windows,
-just as there are on \UNIX: use the \refmodule{distutils} package to
+just as there are on \UNIX: use the
+\ulink{\module{distutils}}{../lib/module-distutils.html} package to
control the build process, or do things manually. The distutils
approach works well for most extensions; documentation on using
-\refmodule{distutils} to build and package extension modules is
-available in \citetitle[../dist/dist.html]{Distributing Python
-Modules}. This section describes the manual approach to building
-Python extensions written in C or \Cpp.
+\ulink{\module{distutils}}{../lib/module-distutils.html} to build and
+package extension modules is available in
+\citetitle[../dist/dist.html]{Distributing Python Modules}. This
+section describes the manual approach to building Python extensions
+written in C or \Cpp.
To build extensions using these instructions, you need to have a copy
of the Python sources of the same version as your installed Python.
Modified: stackless/trunk/Doc/howto/doanddont.tex
==============================================================================
--- stackless/trunk/Doc/howto/doanddont.tex (original)
+++ stackless/trunk/Doc/howto/doanddont.tex Mon Aug 14 12:38:35 2006
@@ -288,8 +288,9 @@
There are also many useful builtin functions people seem not to be
aware of for some reason: \function{min()} and \function{max()} can
find the minimum/maximum of any sequence with comparable semantics,
-for example, yet many people write they own max/min. Another highly
-useful function is \function{reduce()}. Classical use of \function{reduce()}
+for example, yet many people write their own
+\function{max()}/\function{min()}. Another highly useful function is
+\function{reduce()}. A classical use of \function{reduce()}
is something like
\begin{verbatim}
Modified: stackless/trunk/Doc/inst/inst.tex
==============================================================================
--- stackless/trunk/Doc/inst/inst.tex (original)
+++ stackless/trunk/Doc/inst/inst.tex Mon Aug 14 12:38:35 2006
@@ -262,7 +262,7 @@
\code{setup.py install}---then the \command{install} command installs to
the standard location for third-party Python modules. This location
varies by platform and by how you built/installed Python itself. On
-\UNIX{} (and Mac OS X, which is also Unix-based),
+\UNIX{} (and Mac OS X, which is also \UNIX-based),
it also depends on whether the module distribution
being installed is pure Python or contains extensions (``non-pure''):
\begin{tableiv}{l|l|l|c}{textrm}%
Modified: stackless/trunk/Doc/lib/email.tex
==============================================================================
--- stackless/trunk/Doc/lib/email.tex (original)
+++ stackless/trunk/Doc/lib/email.tex Mon Aug 14 12:38:35 2006
@@ -105,7 +105,7 @@
\lineiii{4.0}{Python 2.5}{Python 2.3 to 2.5}
\end{tableiii}
-Here are the major differences between \module{email} verson 4 and version 3:
+Here are the major differences between \module{email} version 4 and version 3:
\begin{itemize}
\item All modules have been renamed according to \pep{8} standards. For
@@ -126,6 +126,15 @@
\item Methods that were deprecated in version 3 have been removed. These
include \method{Generator.__call__()}, \method{Message.get_type()},
\method{Message.get_main_type()}, \method{Message.get_subtype()}.
+
+\item Fixes have been added for \rfc{2231} support which can change some of
+ the return types for \function{Message.get_param()} and friends. Under
+ some circumstances, values which used to return a 3-tuple now return
+ simple strings (specifically, if all extended parameter segments were
+ unencoded, there is no language and charset designation expected, so the
+ return type is now a simple string). Also, \%-decoding used to be done
+ for both encoded and unencoded segments; this decoding is now done only
+ for encoded segments.
\end{itemize}
Here are the major differences between \module{email} version 3 and version 2:
Modified: stackless/trunk/Doc/lib/emailgenerator.tex
==============================================================================
--- stackless/trunk/Doc/lib/emailgenerator.tex (original)
+++ stackless/trunk/Doc/lib/emailgenerator.tex Mon Aug 14 12:38:35 2006
@@ -31,11 +31,11 @@
\samp{>} character in front of any line in the body that starts exactly as
\samp{From }, i.e. \code{From} followed by a space at the beginning of the
line. This is the only guaranteed portable way to avoid having such
-lines be mistaken for a Unix mailbox format envelope header separator (see
+lines be mistaken for a \UNIX{} mailbox format envelope header separator (see
\ulink{WHY THE CONTENT-LENGTH FORMAT IS BAD}
{http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html}
for details). \var{mangle_from_} defaults to \code{True}, but you
-might want to set this to \code{False} if you are not writing Unix
+might want to set this to \code{False} if you are not writing \UNIX{}
mailbox format files.
Optional \var{maxheaderlen} specifies the longest length for a
Modified: stackless/trunk/Doc/lib/lib.tex
==============================================================================
--- stackless/trunk/Doc/lib/lib.tex (original)
+++ stackless/trunk/Doc/lib/lib.tex Mon Aug 14 12:38:35 2006
@@ -71,12 +71,12 @@
% BUILT-INs
% =============
-\input{libobjs} % Built-in Types, Exceptions and Functions
+\input{libobjs} % Built-in Exceptions and Functions
\input{libfuncs}
-\input{libstdtypes}
\input{libexcs}
\input{libconsts}
+\input{libstdtypes} % Built-in types
% =============
@@ -154,8 +154,8 @@
% encoding stuff
\input{libbase64}
-\input{libbinascii}
\input{libbinhex}
+\input{libbinascii}
\input{libquopri}
\input{libuu}
Modified: stackless/trunk/Doc/lib/libanydbm.tex
==============================================================================
--- stackless/trunk/Doc/lib/libanydbm.tex (original)
+++ stackless/trunk/Doc/lib/libanydbm.tex Mon Aug 14 12:38:35 2006
@@ -46,6 +46,32 @@
\method{keys()} methods are available. Keys and values must always be
strings.
+The following example records some hostnames and a corresponding title,
+and then prints out the contents of the database:
+
+\begin{verbatim}
+import anydbm
+
+# Open database, creating it if necessary.
+db = anydbm.open('cache', 'c')
+
+# Record some values
+db['www.python.org'] = 'Python Website'
+db['www.cnn.com'] = 'Cable News Network'
+
+# Loop through contents. Other dictionary methods
+# such as .keys(), .values() also work.
+for k, v in db.iteritems():
+ print k, '\t', v
+
+# Storing a non-string key or value will raise an exception (most
+# likely a TypeError).
+db['www.yahoo.com'] = 4
+
+# Close when done.
+db.close()
+\end{verbatim}
+
\begin{seealso}
\seemodule{dbhash}{BSD \code{db} database interface.}
Modified: stackless/trunk/Doc/lib/libbase64.tex
==============================================================================
--- stackless/trunk/Doc/lib/libbase64.tex (original)
+++ stackless/trunk/Doc/lib/libbase64.tex Mon Aug 14 12:38:35 2006
@@ -146,6 +146,18 @@
always including an extra trailing newline (\code{'\e n'}).
\end{funcdesc}
+An example usage of the module:
+
+\begin{verbatim}
+>>> import base64
+>>> encoded = base64.b64encode('data to be encoded')
+>>> encoded
+'ZGF0YSB0byBiZSBlbmNvZGVk'
+>>> data = base64.b64decode(encoded)
+>>> data
+'data to be encoded'
+\end{verbatim}
+
\begin{seealso}
\seemodule{binascii}{Support module containing \ASCII-to-binary
and binary-to-\ASCII{} conversions.}
Modified: stackless/trunk/Doc/lib/libbinascii.tex
==============================================================================
--- stackless/trunk/Doc/lib/libbinascii.tex (original)
+++ stackless/trunk/Doc/lib/libbinascii.tex Mon Aug 14 12:38:35 2006
@@ -9,10 +9,11 @@
The \module{binascii} module contains a number of methods to convert
between binary and various \ASCII-encoded binary
representations. Normally, you will not use these functions directly
-but use wrapper modules like \refmodule{uu}\refstmodindex{uu} or
-\refmodule{binhex}\refstmodindex{binhex} instead, this module solely
-exists because bit-manipulation of large amounts of data is slow in
-Python.
+but use wrapper modules like \refmodule{uu}\refstmodindex{uu},
+\refmodule{base64}\refstmodindex{base64}, or
+\refmodule{binhex}\refstmodindex{binhex} instead. The \module{binascii} module
+contains low-level functions written in C for greater speed
+that are used by the higher-level modules.
The \module{binascii} module defines the following functions:
Modified: stackless/trunk/Doc/lib/libbsddb.tex
==============================================================================
--- stackless/trunk/Doc/lib/libbsddb.tex (original)
+++ stackless/trunk/Doc/lib/libbsddb.tex Mon Aug 14 12:38:35 2006
@@ -94,7 +94,7 @@
\begin{notice}
-Beginning in 2.3 some Unix versions of Python may have a \module{bsddb185}
+Beginning in 2.3 some \UNIX{} versions of Python may have a \module{bsddb185}
module. This is present \emph{only} to allow backwards compatibility with
systems which ship with the old Berkeley DB 1.85 database library. The
\module{bsddb185} module should never be used directly in new code.
Modified: stackless/trunk/Doc/lib/libcompileall.tex
==============================================================================
--- stackless/trunk/Doc/lib/libcompileall.tex (original)
+++ stackless/trunk/Doc/lib/libcompileall.tex Mon Aug 14 12:38:35 2006
@@ -44,6 +44,19 @@
\function{compile_dir()} function.
\end{funcdesc}
+To force a recompile of all the \file{.py} files in the \file{Lib/}
+subdirectory and all its subdirectories:
+
+\begin{verbatim}
+import compileall
+
+compileall.compile_dir('Lib/', force=True)
+
+# Perform same compilation, excluding files in .svn directories.
+import re
+compileall.compile_dir('Lib/', rx=re.compile('/[.]svn'), force=True)
+\end{verbatim}
+
\begin{seealso}
\seemodule[pycompile]{py_compile}{Byte-compile a single source file.}
Modified: stackless/trunk/Doc/lib/libcsv.tex
==============================================================================
--- stackless/trunk/Doc/lib/libcsv.tex (original)
+++ stackless/trunk/Doc/lib/libcsv.tex Mon Aug 14 12:38:35 2006
@@ -55,7 +55,7 @@
Return a reader object which will iterate over lines in the given
{}\var{csvfile}. \var{csvfile} can be any object which supports the
iterator protocol and returns a string each time its \method{next}
-method is called - file objects and list objects are both suitable.
+method is called --- file objects and list objects are both suitable.
If \var{csvfile} is a file object, it must be opened with
the 'b' flag on platforms where that makes a difference. An optional
{}\var{dialect} parameter can be given
@@ -70,6 +70,18 @@
All data read are returned as strings. No automatic data type
conversion is performed.
+
+\versionchanged[
+The parser is now stricter with respect to multi-line quoted
+fields. Previously, if a line ended within a quoted field without a
+terminating newline character, a newline would be inserted into the
+returned field. This behavior caused problems when reading files
+which contained carriage return characters within fields. The
+behavior was changed to return the field without inserting newlines. As
+a consequence, if newlines embedded within fields are important, the
+input should be split into lines in a manner which preserves the newline
+characters]{2.5}
+
\end{funcdesc}
\begin{funcdesc}{writer}{csvfile\optional{,
@@ -404,7 +416,7 @@
reader = csv.reader(open("passwd", "rb"), 'unixpwd')
\end{verbatim}
-A slightly more advanced use of the reader - catching and reporting errors:
+A slightly more advanced use of the reader --- catching and reporting errors:
\begin{verbatim}
import csv, sys
Modified: stackless/trunk/Doc/lib/libctypes.tex
==============================================================================
--- stackless/trunk/Doc/lib/libctypes.tex (original)
+++ stackless/trunk/Doc/lib/libctypes.tex Mon Aug 14 12:38:35 2006
@@ -6,13 +6,13 @@
\modulesynopsis{A foreign function library for Python.}
\versionadded{2.5}
-\code{ctypes} is a foreign function library for Python.
+\code{ctypes} is a foreign function library for Python. It provides C
+compatible data types, and allows to call functions in dlls/shared
+libraries. It can be used to wrap these libraries in pure Python.
\subsection{ctypes tutorial\label{ctypes-ctypes-tutorial}}
-This tutorial describes version 0.9.9 of \code{ctypes}.
-
Note: The code samples in this tutorial uses \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
@@ -150,8 +150,10 @@
\end{verbatim}
\code{ctypes} tries to protect you from calling functions with the wrong
-number of arguments. Unfortunately this only works on Windows. It
-does this by examining the stack after the function returns:
+number of arguments or the wrong calling convention. Unfortunately
+this only works on Windows. It does this by examining the stack after
+the function returns, so although an error is raised the function
+\emph{has} been called:
\begin{verbatim}
>>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS
Traceback (most recent call last):
@@ -164,6 +166,25 @@
>>>
\end{verbatim}
+The same exception is raised when you call an \code{stdcall} function
+with the \code{cdecl} calling convention, or vice versa:
+\begin{verbatim}
+>>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ValueError: Procedure probably called with not enough arguments (4 bytes missing)
+>>>
+
+>>> windll.msvcrt.printf("spam") # doctest: +WINDOWS
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ValueError: Procedure probably called with too many arguments (4 bytes in excess)
+>>>
+\end{verbatim}
+
+To find out the correct calling convention you have to look into the C
+header file or the documentation for the function you want to call.
+
On Windows, \code{ctypes} uses win32 structured exception handling to
prevent crashes from general protection faults when functions are
called with invalid argument values:
@@ -790,10 +811,6 @@
\subsubsection{Pointers\label{ctypes-pointers}}
-XXX Rewrite this section. Normally one only uses indexing, not the .contents
-attribute!
-List some recipes with pointers. bool(ptr), POINTER(tp)(), ...?
-
Pointer instances are created by calling the \code{pointer} function on a
\code{ctypes} type:
\begin{verbatim}
@@ -826,7 +843,8 @@
attribute would cause the pointer to point to the memory location
where this is stored:
\begin{verbatim}
->>> pi.contents = c_int(99)
+>>> i = c_int(99)
+>>> pi.contents = i
>>> pi.contents
c_long(99)
>>>
@@ -855,9 +873,6 @@
pointer from a C function, and you \emph{know} that the pointer actually
points to an array instead of a single item.
-
-\subsubsection{Pointer classes/types\label{ctypes-pointer-classestypes}}
-
Behind the scenes, the \code{pointer} function does more than simply
create pointer instances, it has to create pointer \emph{types} first.
This is done with the \code{POINTER} function, which accepts any
@@ -875,6 +890,31 @@
>>>
\end{verbatim}
+Calling the pointer type without an argument creates a \code{NULL}
+pointer. \code{NULL} pointers have a \code{False} boolean value:
+\begin{verbatim}
+>>> null_ptr = POINTER(c_int)()
+>>> print bool(null_ptr)
+False
+>>>
+\end{verbatim}
+
+\code{ctypes} checks for \code{NULL} when dereferencing pointers (but
+dereferencing non-\code{NULL} pointers would crash Python):
+\begin{verbatim}
+>>> null_ptr[0]
+Traceback (most recent call last):
+ ....
+ValueError: NULL pointer access
+>>>
+
+>>> null_ptr[0] = 1234
+Traceback (most recent call last):
+ ....
+ValueError: NULL pointer access
+>>>
+\end{verbatim}
+
\subsubsection{Type conversions\label{ctypes-type-conversions}}
@@ -1357,35 +1397,6 @@
>>>
\end{verbatim}
-The solution is to use 1-element arrays; as a special case ctypes does
-no bounds checking on them:
-\begin{verbatim}
->>> short_array = (c_short * 1)()
->>> print sizeof(short_array)
-2
->>> resize(short_array, 32)
->>> sizeof(short_array)
-32
->>> sizeof(type(short_array))
-2
->>> short_array[0:8]
-[0, 0, 0, 0, 0, 0, 0, 0]
->>> short_array[7] = 42
->>> short_array[0:8]
-[0, 0, 0, 0, 0, 0, 0, 42]
->>>
-\end{verbatim}
-
-Using 1-element arrays as variable sized fields in structures works as
-well, but they should be used as the last field in the structure
-definition. This example shows a definition from the Windows header
-files:
-\begin{verbatim}
-class SP_DEVICE_INTERFACE_DETAIL_DATA(Structure):
- _fields_ = [("cbSize", c_int),
- ("DevicePath", c_char * 1)]
-\end{verbatim}
-
Another way to use variable-sized data types with \code{ctypes} is to use
the dynamic nature of Python, and (re-)define the data type after the
required size is already known, on a case by case basis.
@@ -1474,13 +1485,13 @@
There are several ways to loaded shared libraries into the Python
process. One way is to instantiate one of the following classes:
-\begin{classdesc}{CDLL}{name, mode=RTLD_LOCAL, handle=None}
+\begin{classdesc}{CDLL}{name, mode=DEFAULT_MODE, handle=None}
Instances of this class represent loaded shared libraries.
Functions in these libraries use the standard C calling
convention, and are assumed to return \code{int}.
\end{classdesc}
-\begin{classdesc}{OleDLL}{name, mode=RTLD_LOCAL, handle=None}
+\begin{classdesc}{OleDLL}{name, mode=DEFAULT_MODE, handle=None}
Windows only: Instances of this class represent loaded shared
libraries, functions in these libraries use the \code{stdcall}
calling convention, and are assumed to return the windows specific
@@ -1490,7 +1501,7 @@
failure, an \class{WindowsError} is automatically raised.
\end{classdesc}
-\begin{classdesc}{WinDLL}{name, mode=RTLD_LOCAL, handle=None}
+\begin{classdesc}{WinDLL}{name, mode=DEFAULT_MODE, handle=None}
Windows only: Instances of this class represent loaded shared
libraries, functions in these libraries use the \code{stdcall}
calling convention, and are assumed to return \code{int} by default.
@@ -1503,7 +1514,7 @@
The Python GIL is released before calling any function exported by
these libraries, and reaquired afterwards.
-\begin{classdesc}{PyDLL}{name, mode=RTLD_LOCAL, handle=None}
+\begin{classdesc}{PyDLL}{name, mode=DEFAULT_MODE, handle=None}
Instances of this class behave like \class{CDLL} instances, except
that the Python GIL is \emph{not} released during the function call,
and after the function execution the Python error flag is checked.
@@ -1533,6 +1544,12 @@
available, it is the same as \var{RTLD{\_}GLOBAL}.
\end{datadescni}
+\begin{datadescni}{DEFAULT_MODE}
+The default mode which is used to load shared libraries. On OSX
+10.3, this is \var{RTLD{\_}GLOBAL}, otherwise it is the same as
+\var{RTLD{\_}LOCAL}.
+\end{datadescni}
+
Instances of these classes have no public methods, however
\method{{\_}{\_}getattr{\_}{\_}} and \method{{\_}{\_}getitem{\_}{\_}} have special behaviour: functions
exported by the shared library can be accessed as attributes of by
@@ -1566,10 +1583,9 @@
return the same library each time.
\end{classdesc}
-\begin{methoddesc}{LoadLibrary}{name, mode=RTLD_LOCAL, handle=None}
+\begin{methoddesc}{LoadLibrary}{name}
Load a shared library into the process and return it. This method
-always creates a new instance of the library. All three
-parameters are passed to the constructor of the library object.
+always returns a new instance of the library.
\end{methoddesc}
These prefabricated library loaders are available:
@@ -1810,8 +1826,8 @@
\begin{verbatim}
WINUSERAPI BOOL WINAPI
GetWindowRect(
- HWND hWnd,
- LPRECT lpRect);
+ HWND hWnd,
+ LPRECT lpRect);
\end{verbatim}
Here is the wrapping with \code{ctypes}:
Modified: stackless/trunk/Doc/lib/libfuncs.tex
==============================================================================
--- stackless/trunk/Doc/lib/libfuncs.tex (original)
+++ stackless/trunk/Doc/lib/libfuncs.tex Mon Aug 14 12:38:35 2006
@@ -401,67 +401,17 @@
\end{funcdesc}
\begin{funcdesc}{file}{filename\optional{, mode\optional{, bufsize}}}
- Return a new file object (described in
- section~\ref{bltin-file-objects}, ``\ulink{File
- Objects}{bltin-file-objects.html}'').
- The first two arguments are the same as for \code{stdio}'s
- \cfunction{fopen()}: \var{filename} is the file name to be opened,
- \var{mode} indicates how the file is to be opened: \code{'r'} for
- reading, \code{'w'} for writing (truncating an existing file), and
- \code{'a'} opens it for appending (which on \emph{some} \UNIX{}
- systems means that \emph{all} writes append to the end of the file,
- regardless of the current seek position).
+ Constructor function for the \class{file} type, described further
+ in section~\ref{bltin-file-objects}, ``\ulink{File
+ Objects}{bltin-file-objects.html}''. The constructor's arguments
+ are the same as those of the \function{open()} built-in function
+ described below.
- Modes \code{'r+'}, \code{'w+'} and \code{'a+'} open the file for
- updating (note that \code{'w+'} truncates the file). Append
- \code{'b'} to the mode to open the file in binary mode, on systems
- that differentiate between binary and text files (else it is
- ignored). If the file cannot be opened, \exception{IOError} is
- raised.
-
- In addition to the standard \cfunction{fopen()} values \var{mode}
- may be \code{'U'} or \code{'rU'}. If Python is built with universal
- newline support (the default) the file is opened as a text file, but
- lines may be terminated by any of \code{'\e n'}, the Unix end-of-line
- convention,
- \code{'\e r'}, the Macintosh convention or \code{'\e r\e n'}, the Windows
- convention. All of these external representations are seen as
- \code{'\e n'}
- by the Python program. If Python is built without universal newline support
- \var{mode} \code{'U'} is the same as normal text mode. Note that
- file objects so opened also have an attribute called
- \member{newlines} which has a value of \code{None} (if no newlines
- have yet been seen), \code{'\e n'}, \code{'\e r'}, \code{'\e r\e n'},
- or a tuple containing all the newline types seen.
-
- Python enforces that the mode, after stripping \code{'U'}, begins with
- \code{'r'}, \code{'w'} or \code{'a'}.
-
- If \var{mode} is omitted, it defaults to \code{'r'}. When opening a
- binary file, you should append \code{'b'} to the \var{mode} value
- for improved portability. (It's useful even on systems which don't
- treat binary and text files differently, where it serves as
- documentation.)
- \index{line-buffered I/O}\index{unbuffered I/O}\index{buffer size, I/O}
- \index{I/O control!buffering}
- The optional \var{bufsize} argument specifies the
- file's desired buffer size: 0 means unbuffered, 1 means line
- buffered, any other positive value means use a buffer of
- (approximately) that size. A negative \var{bufsize} means to use
- the system default, which is usually line buffered for tty
- devices and fully buffered for other files. If omitted, the system
- default is used.\footnote{
- Specifying a buffer size currently has no effect on systems that
- don't have \cfunction{setvbuf()}. The interface to specify the
- buffer size is not done using a method that calls
- \cfunction{setvbuf()}, because that may dump core when called
- after any I/O has been performed, and there's no reliable way to
- determine whether this is the case.}
+ When opening a file, it's preferable to use \function{open()} instead of
+ invoking this constructor directly. \class{file} is more suited to
+ type testing (for example, writing \samp{isinstance(f, file)}).
\versionadded{2.2}
-
- \versionchanged[Restriction on first letter of mode string
- introduced]{2.5}
\end{funcdesc}
\begin{funcdesc}{filter}{function, list}
@@ -726,10 +676,71 @@
\end{funcdesc}
\begin{funcdesc}{open}{filename\optional{, mode\optional{, bufsize}}}
- A wrapper for the \function{file()} function above. The intent is
- for \function{open()} to be preferred for use as a factory function
- returning a new \class{file} object. \class{file} is more suited to
- type testing (for example, writing \samp{isinstance(f, file)}).
+ Open a file, returning an object of the \class{file} type described
+ in section~\ref{bltin-file-objects}, ``\ulink{File
+ Objects}{bltin-file-objects.html}''. If the file cannot be opened,
+ \exception{IOError} is raised. When opening a file, it's
+ preferable to use \function{open()} instead of invoking the
+ \class{file} constructor directly.
+
+ The first two arguments are the same as for \code{stdio}'s
+ \cfunction{fopen()}: \var{filename} is the file name to be opened,
+ and \var{mode} is a string indicating how the file is to be opened.
+
+ The most commonly-used values of \var{mode} are \code{'r'} for
+ reading, \code{'w'} for writing (truncating the file if it already
+ exists), and \code{'a'} for appending (which on \emph{some} \UNIX{}
+ systems means that \emph{all} writes append to the end of the file
+ regardless of the current seek position). If \var{mode} is omitted,
+ it defaults to \code{'r'}. When opening a binary file, you should
+ append \code{'b'} to the \var{mode} value to open the file in binary
+ mode, which will improve portability. (Appending \code{'b'} is
+ useful even on systems that don't treat binary and text files
+ differently, where it serves as documentation.) See below for more
+ possible values of \var{mode}.
+
+ \index{line-buffered I/O}\index{unbuffered I/O}\index{buffer size, I/O}
+ \index{I/O control!buffering}
+ The optional \var{bufsize} argument specifies the
+ file's desired buffer size: 0 means unbuffered, 1 means line
+ buffered, any other positive value means use a buffer of
+ (approximately) that size. A negative \var{bufsize} means to use
+ the system default, which is usually line buffered for tty
+ devices and fully buffered for other files. If omitted, the system
+ default is used.\footnote{
+ Specifying a buffer size currently has no effect on systems that
+ don't have \cfunction{setvbuf()}. The interface to specify the
+ buffer size is not done using a method that calls
+ \cfunction{setvbuf()}, because that may dump core when called
+ after any I/O has been performed, and there's no reliable way to
+ determine whether this is the case.}
+
+ Modes \code{'r+'}, \code{'w+'} and \code{'a+'} open the file for
+ updating (note that \code{'w+'} truncates the file). Append
+ \code{'b'} to the mode to open the file in binary mode, on systems
+ that differentiate between binary and text files; on systems
+ that don't have this distinction, adding the \code{'b'} has no effect.
+
+ In addition to the standard \cfunction{fopen()} values \var{mode}
+ may be \code{'U'} or \code{'rU'}. Python is usually built with universal
+ newline support; supplying \code{'U'} opens the file as a text file, but
+ lines may be terminated by any of the following: the \UNIX{} end-of-line
+ convention \code{'\e n'},
+ the Macintosh convention \code{'\e r'}, or the Windows
+ convention \code{'\e r\e n'}. All of these external representations are seen as
+ \code{'\e n'}
+ by the Python program. If Python is built without universal newline support
+ a \var{mode} with \code{'U'} is the same as normal text mode. Note that
+ file objects so opened also have an attribute called
+ \member{newlines} which has a value of \code{None} (if no newlines
+ have yet been seen), \code{'\e n'}, \code{'\e r'}, \code{'\e r\e n'},
+ or a tuple containing all the newline types seen.
+
+ Python enforces that the mode, after stripping \code{'U'}, begins with
+ \code{'r'}, \code{'w'} or \code{'a'}.
+
+ \versionchanged[Restriction on first letter of mode string
+ introduced]{2.5}
\end{funcdesc}
\begin{funcdesc}{ord}{c}
Modified: stackless/trunk/Doc/lib/libgettext.tex
==============================================================================
--- stackless/trunk/Doc/lib/libgettext.tex (original)
+++ stackless/trunk/Doc/lib/libgettext.tex Mon Aug 14 12:38:35 2006
@@ -549,7 +549,7 @@
written a program called
\program{xpot} which does a similar job. It is available as part of
his \program{po-utils} package at
-\url{http://www.iro.umontreal.ca/contrib/po-utils/HTML/}.} program
+\url{http://po-utils.progiciels-bpi.ca/}.} program
scans all your Python source code looking for the strings you
previously marked as translatable. It is similar to the GNU
\program{gettext} program except that it understands all the
@@ -585,8 +585,8 @@
translation processing during run-time.
How you use the \module{gettext} module in your code depends on
-whether you are internationalizing your entire application or a single
-module.
+whether you are internationalizing a single module or your entire application.
+The next two sections will discuss each case.
\subsubsection{Localizing your module}
Modified: stackless/trunk/Doc/lib/libimp.tex
==============================================================================
--- stackless/trunk/Doc/lib/libimp.tex (original)
+++ stackless/trunk/Doc/lib/libimp.tex Mon Aug 14 12:38:35 2006
@@ -232,6 +232,24 @@
source file.
\end{funcdesc}
+\begin{classdesc}{NullImporter}{path_string}
+The \class{NullImporter} type is a \pep{302} import hook that handles
+non-directory path strings by failing to find any modules. Calling this
+type with an existing directory or empty string raises
+\exception{ImportError}. Otherwise, a \class{NullImporter} instance is
+returned.
+
+Python adds instances of this type to \code{sys.path_importer_cache} for
+any path entries that are not directories and are not handled by any other
+path hooks on \code{sys.path_hooks}. Instances have only one method:
+
+\begin{methoddesc}{find_module}{fullname \optional{, path}}
+This method always returns \code{None}, indicating that the requested
+module could not be found.
+\end{methoddesc}
+
+\versionadded{2.5}
+\end{classdesc}
\subsection{Examples}
\label{examples-imp}
@@ -257,7 +275,7 @@
# there's a problem we can't handle -- let the caller handle it.
fp, pathname, description = imp.find_module(name)
-
+
try:
return imp.load_module(name, fp, pathname, description)
finally:
Modified: stackless/trunk/Doc/lib/libinspect.tex
==============================================================================
--- stackless/trunk/Doc/lib/libinspect.tex (original)
+++ stackless/trunk/Doc/lib/libinspect.tex Mon Aug 14 12:38:35 2006
@@ -180,13 +180,32 @@
Return true if the object is a data descriptor.
Data descriptors have both a __get__ and a __set__ attribute. Examples are
- properties (defined in Python) and getsets and members (defined in C).
- Typically, data descriptors will also have __name__ and __doc__ attributes
- (properties, getsets, and members have both of these attributes), but this
- is not guaranteed.
+ properties (defined in Python), getsets, and members. The latter two are
+ defined in C and there are more specific tests available for those types,
+ which is robust across Python implementations. Typically, data descriptors
+ will also have __name__ and __doc__ attributes (properties, getsets, and
+ members have both of these attributes), but this is not guaranteed.
\versionadded{2.3}
\end{funcdesc}
+\begin{funcdesc}{isgetsetdescriptor}{object}
+ Return true if the object is a getset descriptor.
+
+ getsets are attributes defined in extension modules via \code{PyGetSetDef}
+ structures. For Python implementations without such types, this method will
+ always return \code{False}.
+\versionadded{2.5}
+\end{funcdesc}
+
+\begin{funcdesc}{ismemberdescriptor}{object}
+ Return true if the object is a member descriptor.
+
+ Member descriptors are attributes defined in extension modules via
+ \code{PyMemberDef} structures. For Python implementations without such
+ types, this method will always return \code{False}.
+\versionadded{2.5}
+\end{funcdesc}
+
\subsection{Retrieving source code
\label{inspect-source}}
Modified: stackless/trunk/Doc/lib/liblogging.tex
==============================================================================
--- stackless/trunk/Doc/lib/liblogging.tex (original)
+++ stackless/trunk/Doc/lib/liblogging.tex Mon Aug 14 12:38:35 2006
@@ -1068,13 +1068,11 @@
\end{tableii}
If \var{backupCount} is non-zero, the system will save old log files by
-appending the extensions ".1", ".2" etc., to the filename. For example,
-with a \var{backupCount} of 5 and a base file name of \file{app.log},
-you would get \file{app.log}, \file{app.log.1}, \file{app.log.2}, up to
-\file{app.log.5}. The file being written to is always \file{app.log}.
-When this file is filled, it is closed and renamed to \file{app.log.1},
-and if files \file{app.log.1}, \file{app.log.2}, etc. exist, then they
-are renamed to \file{app.log.2}, \file{app.log.3} etc. respectively.
+appending extensions to the filename. The extensions are date-and-time
+based, using the strftime format \code{\%Y-\%m-\%d_\%H-\%M-\%S} or a leading
+portion thereof, depending on the rollover interval. At most \var{backupCount}
+files will be kept, and if more would be created when rollover occurs, the
+oldest one is deleted.
\end{classdesc}
\begin{methoddesc}{doRollover}{}
@@ -1539,7 +1537,7 @@
To stop the server, call \function{stopListening()}. To send a configuration
to the socket, read in the configuration file and send it to the socket
as a string of bytes preceded by a four-byte length packed in binary using
-struct.\code{pack(">L", n)}.
+struct.\code{pack('>L', n)}.
\end{funcdesc}
\begin{funcdesc}{stopListening}{}
Modified: stackless/trunk/Doc/lib/libmailbox.tex
==============================================================================
--- stackless/trunk/Doc/lib/libmailbox.tex (original)
+++ stackless/trunk/Doc/lib/libmailbox.tex Mon Aug 14 12:38:35 2006
@@ -1367,9 +1367,8 @@
print subject
\end{verbatim}
-A (surprisingly) simple example of copying all mail from a Babyl mailbox to an
-MH mailbox, converting all of the format-specific information that can be
-converted:
+To copy all mail from a Babyl mailbox to an MH mailbox, converting all
+of the format-specific information that can be converted:
\begin{verbatim}
import mailbox
Modified: stackless/trunk/Doc/lib/libmimetypes.tex
==============================================================================
--- stackless/trunk/Doc/lib/libmimetypes.tex (original)
+++ stackless/trunk/Doc/lib/libmimetypes.tex Mon Aug 14 12:38:35 2006
@@ -158,6 +158,20 @@
\versionadded{2.2}
\end{classdesc}
+An example usage of the module:
+
+\begin{verbatim}
+>>> import mimetypes
+>>> mimetypes.init()
+>>> mimetypes.knownfiles
+['/etc/mime.types', '/etc/httpd/mime.types', ... ]
+>>> mimetypes.suffix_map['.tgz']
+'.tar.gz'
+>>> mimetypes.encodings_map['.gz']
+'gzip'
+>>> mimetypes.types_map['.tgz']
+'application/x-tar-gz'
+\end{verbatim}
\subsection{MimeTypes Objects \label{mimetypes-objects}}
Modified: stackless/trunk/Doc/lib/libnew.tex
==============================================================================
--- stackless/trunk/Doc/lib/libnew.tex (original)
+++ stackless/trunk/Doc/lib/libnew.tex Mon Aug 14 12:38:35 2006
@@ -30,13 +30,16 @@
callable.
\end{funcdesc}
-\begin{funcdesc}{function}{code, globals\optional{, name\optional{, argdefs}}}
+\begin{funcdesc}{function}{code, globals\optional{, name\optional{,
+ argdefs\optional{, closure}}}}
Returns a (Python) function with the given code and globals. If
\var{name} is given, it must be a string or \code{None}. If it is a
string, the function will have the given name, otherwise the function
name will be taken from \code{\var{code}.co_name}. If
\var{argdefs} is given, it must be a tuple and will be used to
-determine the default values of parameters.
+determine the default values of parameters. If \var{closure} is given,
+it must be \code{None} or a tuple of cell objects containing objects
+to bind to the names in \code{\var{code}.co_freevars}.
\end{funcdesc}
\begin{funcdesc}{code}{argcount, nlocals, stacksize, flags, codestring,
Modified: stackless/trunk/Doc/lib/liboptparse.tex
==============================================================================
--- stackless/trunk/Doc/lib/liboptparse.tex (original)
+++ stackless/trunk/Doc/lib/liboptparse.tex Mon Aug 14 12:38:35 2006
@@ -1390,7 +1390,7 @@
\end{verbatim}
\end{itemize}
-% $Id: reference.txt 505 2005-07-22 01:52:40Z gward $
+% $Id: reference.txt 519 2006-06-11 14:39:11Z gward $
\subsection{Option Callbacks\label{optparse-option-callbacks}}
Modified: stackless/trunk/Doc/lib/libossaudiodev.tex
==============================================================================
--- stackless/trunk/Doc/lib/libossaudiodev.tex (original)
+++ stackless/trunk/Doc/lib/libossaudiodev.tex Mon Aug 14 12:38:35 2006
@@ -68,7 +68,7 @@
Open an audio device and return an OSS audio device object. This
object supports many file-like methods, such as \method{read()},
\method{write()}, and \method{fileno()} (although there are subtle
-differences between conventional Unix read/write semantics and those of
+differences between conventional \UNIX{} read/write semantics and those of
OSS audio devices). It also supports a number of audio-specific
methods; see below for the complete list of methods.
Modified: stackless/trunk/Doc/lib/libpickle.tex
==============================================================================
--- stackless/trunk/Doc/lib/libpickle.tex (original)
+++ stackless/trunk/Doc/lib/libpickle.tex Mon Aug 14 12:38:35 2006
@@ -725,7 +725,50 @@
\subsection{Example \label{pickle-example}}
-Here's a simple example of how to modify pickling behavior for a
+For the simplest code, use the \function{dump()} and \function{load()}
+functions. Note that a self-referencing list is pickled and restored
+correctly.
+
+\begin{verbatim}
+import pickle
+
+data1 = {'a': [1, 2.0, 3, 4+6j],
+ 'b': ('string', u'Unicode string'),
+ 'c': None}
+
+selfref_list = [1, 2, 3]
+selfref_list.append(selfref_list)
+
+output = open('data.pkl', 'wb')
+
+# Pickle dictionary using protocol 0.
+pickle.dump(data1, output)
+
+# Pickle the list using the highest protocol available.
+pickle.dump(selfref_list, output, -1)
+
+output.close()
+\end{verbatim}
+
+The following example reads the resulting pickled data. When reading
+a pickle-containing file, you should open the file in binary mode
+because you can't be sure if the ASCII or binary format was used.
+
+\begin{verbatim}
+import pprint, pickle
+
+pkl_file = open('data.pkl', 'rb')
+
+data1 = pickle.load(pkl_file)
+pprint.pprint(data1)
+
+data2 = pickle.load(pkl_file)
+pprint.pprint(data2)
+
+pkl_file.close()
+\end{verbatim}
+
+Here's a larger example that shows how to modify pickling behavior for a
class. The \class{TextReader} class opens a text file, and returns
the line number and line contents each time its \method{readline()}
method is called. If a \class{TextReader} instance is pickled, all
Modified: stackless/trunk/Doc/lib/libpkgutil.tex
==============================================================================
--- stackless/trunk/Doc/lib/libpkgutil.tex (original)
+++ stackless/trunk/Doc/lib/libpkgutil.tex Mon Aug 14 12:38:35 2006
@@ -30,7 +30,7 @@
with \code{import}. A \file{*.pkg} file is trusted at face value:
apart from checking for duplicates, all entries found in a
\file{*.pkg} file are added to the path, regardless of whether they
- exist the filesystem. (This is a feature.)
+ exist on the filesystem. (This is a feature.)
If the input path is not a list (as is the case for frozen
packages) it is returned unchanged. The input path is not
Modified: stackless/trunk/Doc/lib/libposixpath.tex
==============================================================================
--- stackless/trunk/Doc/lib/libposixpath.tex (original)
+++ stackless/trunk/Doc/lib/libposixpath.tex Mon Aug 14 12:38:35 2006
@@ -42,8 +42,11 @@
\end{funcdesc}
\begin{funcdesc}{exists}{path}
-Return \code{True} if \var{path} refers to an existing path.
-Returns \code{False} for broken symbolic links.
+Return \code{True} if \var{path} refers to an existing path. Returns
+\code{False} for broken symbolic links. On some platforms, this
+function may return \code{False} if permission is not granted to
+execute \function{os.stat()} on the requested file, even if the
+\var{path} physically exists.
\end{funcdesc}
\begin{funcdesc}{lexists}{path}
@@ -190,9 +193,8 @@
\end{funcdesc}
\begin{funcdesc}{sameopenfile}{fp1, fp2}
-Return \code{True} if the file objects \var{fp1} and \var{fp2} refer to the
-same file. The two file objects may represent different file
-descriptors.
+Return \code{True} if the file descriptors \var{fp1} and \var{fp2} refer
+to the same file.
Availability: Macintosh, \UNIX.
\end{funcdesc}
Modified: stackless/trunk/Doc/lib/librandom.tex
==============================================================================
--- stackless/trunk/Doc/lib/librandom.tex (original)
+++ stackless/trunk/Doc/lib/librandom.tex Mon Aug 14 12:38:35 2006
@@ -236,7 +236,7 @@
\var{beta} is the shape parameter.
\end{funcdesc}
-Alternative Generators
+Alternative Generators:
\begin{classdesc}{WichmannHill}{\optional{seed}}
Class that implements the Wichmann-Hill algorithm as the core generator.
@@ -267,6 +267,30 @@
\versionadded{2.4}
\end{classdesc}
+Examples of basic usage:
+
+\begin{verbatim}
+>>> random.random() # Random float x, 0.0 <= x < 1.0
+0.37444887175646646
+>>> random.uniform(1, 10) # Random float x, 1.0 <= x < 10.0
+1.1800146073117523
+>>> random.randint(1, 10) # Integer from 1 to 10, endpoints included
+7
+>>> random.randrange(0, 101, 2) # Even integer from 0 to 100
+26
+>>> random.choice('abcdefghij') # Choose a random element
+'c'
+
+>>> items = [1, 2, 3, 4, 5, 6, 7]
+>>> random.shuffle(items)
+>>> items
+[7, 3, 2, 5, 6, 4, 1]
+
+>>> random.sample([1, 2, 3, 4, 5], 3) # Choose 3 elements
+[4, 1, 5]
+
+\end{verbatim}
+
\begin{seealso}
\seetext{M. Matsumoto and T. Nishimura, ``Mersenne Twister: A
623-dimensionally equidistributed uniform pseudorandom
Modified: stackless/trunk/Doc/lib/libre.tex
==============================================================================
--- stackless/trunk/Doc/lib/libre.tex (original)
+++ stackless/trunk/Doc/lib/libre.tex Mon Aug 14 12:38:35 2006
@@ -897,7 +897,7 @@
\lineii{\code{\%d}}
{\regexp{[-+]?\e d+}}
\lineii{\code{\%e}, \code{\%E}, \code{\%f}, \code{\%g}}
- {\regexp{[-+]?(\e d+(\e.\e d*)?|\e d*\e.\e d+)([eE][-+]?\e d+)?}}
+ {\regexp{[-+]?(\e d+(\e.\e d*)?|\e.\e d+)([eE][-+]?\e d+)?}}
\lineii{\code{\%i}}
{\regexp{[-+]?(0[xX][\e dA-Fa-f]+|0[0-7]*|\e d+)}}
\lineii{\code{\%o}}
Modified: stackless/trunk/Doc/lib/libreadline.tex
==============================================================================
--- stackless/trunk/Doc/lib/libreadline.tex (original)
+++ stackless/trunk/Doc/lib/libreadline.tex Mon Aug 14 12:38:35 2006
@@ -7,10 +7,13 @@
\modulesynopsis{GNU readline support for Python.}
-The \module{readline} module defines a number of functions used either
-directly or from the \refmodule{rlcompleter} module to facilitate
-completion and history file read and write from the Python
-interpreter.
+The \module{readline} module defines a number of functions to
+facilitate completion and reading/writing of history files from the
+Python interpreter. This module can be used directly or via the
+\refmodule{rlcompleter} module. Settings made using
+this module affect the behaviour of both the interpreter's interactive prompt
+and the prompts offered by the \function{raw_input()} and \function{input()}
+built-in functions.
The \module{readline} module defines the following functions:
Modified: stackless/trunk/Doc/lib/libshelve.tex
==============================================================================
--- stackless/trunk/Doc/lib/libshelve.tex (original)
+++ stackless/trunk/Doc/lib/libshelve.tex Mon Aug 14 12:38:35 2006
@@ -143,15 +143,17 @@
del d[key] # delete data stored at key (raises KeyError
# if no such key)
flag = d.has_key(key) # true if the key exists
-list = d.keys() # a list of all existing keys (slow!)
+klist = d.keys() # a list of all existing keys (slow!)
# as d was opened WITHOUT writeback=True, beware:
d['xx'] = range(4) # this works as expected, but...
d['xx'].append(5) # *this doesn't!* -- d['xx'] is STILL range(4)!!!
+
# having opened d without writeback=True, you need to code carefully:
temp = d['xx'] # extracts the copy
temp.append(5) # mutates the copy
d['xx'] = temp # stores the copy right back, to persist it
+
# or, d=shelve.open(filename,writeback=True) would let you just code
# d['xx'].append(5) and have it work as expected, BUT it would also
# consume more memory and make the d.close() operation slower.
Modified: stackless/trunk/Doc/lib/libsocket.tex
==============================================================================
--- stackless/trunk/Doc/lib/libsocket.tex (original)
+++ stackless/trunk/Doc/lib/libsocket.tex Mon Aug 14 12:38:35 2006
@@ -711,6 +711,17 @@
read until EOF. The return value is a string of the bytes read.
\end{methoddesc}
+\begin{methoddesc}{server}{}
+Returns a string containing the ASN.1 distinguished name identifying the
+server's certificate. (See below for an example
+showing what distinguished names look like.)
+\end{methoddesc}
+
+\begin{methoddesc}{issuer}{}
+Returns a string containing the ASN.1 distinguished name identifying the
+issuer of the server's certificate.
+\end{methoddesc}
+
\subsection{Example \label{socket-example}}
Here are four minimal example programs using the TCP/IP protocol:\ a
@@ -833,3 +844,44 @@
s.close()
print 'Received', repr(data)
\end{verbatim}
+
+This example connects to an SSL server, prints the
+server and issuer's distinguished names, sends some bytes,
+and reads part of the response:
+
+\begin{verbatim}
+import socket
+
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+s.connect(('www.verisign.com', 443))
+
+ssl_sock = socket.ssl(s)
+
+print repr(ssl_sock.server())
+print repr(ssl_sock.issuer())
+
+# Set a simple HTTP request -- use httplib in actual code.
+ssl_sock.write("""GET / HTTP/1.0\r
+Host: www.verisign.com\r\n\r\n""")
+
+# Read a chunk of data. Will not necessarily
+# read all the data returned by the server.
+data = ssl_sock.read()
+
+# Note that you need to close the underlying socket, not the SSL object.
+del ssl_sock
+s.close()
+\end{verbatim}
+
+At this writing, this SSL example prints the following output (line
+breaks inserted for readability):
+
+\begin{verbatim}
+'/C=US/ST=California/L=Mountain View/
+ O=VeriSign, Inc./OU=Production Services/
+ OU=Terms of use at www.verisign.com/rpa (c)00/
+ CN=www.verisign.com'
+'/O=VeriSign Trust Network/OU=VeriSign, Inc./
+ OU=VeriSign International Server CA - Class 3/
+ OU=www.verisign.com/CPS Incorp.by Ref. LIABILITY LTD.(c)97 VeriSign'
+\end{verbatim}
Modified: stackless/trunk/Doc/lib/libsocksvr.tex
==============================================================================
--- stackless/trunk/Doc/lib/libsocksvr.tex (original)
+++ stackless/trunk/Doc/lib/libsocksvr.tex Mon Aug 14 12:38:35 2006
@@ -74,9 +74,9 @@
\end{verbatim}
Note that \class{UnixDatagramServer} derives from \class{UDPServer}, not
-from \class{UnixStreamServer} -- the only difference between an IP and a
-Unix stream server is the address family, which is simply repeated in both
-unix server classes.
+from \class{UnixStreamServer} --- the only difference between an IP and a
+\UNIX{} stream server is the address family, which is simply repeated in both
+\UNIX{} server classes.
Forking and threading versions of each type of server can be created using
the \class{ForkingMixIn} and \class{ThreadingMixIn} mix-in classes. For
Modified: stackless/trunk/Doc/lib/libsqlite3.tex
==============================================================================
--- stackless/trunk/Doc/lib/libsqlite3.tex (original)
+++ stackless/trunk/Doc/lib/libsqlite3.tex Mon Aug 14 12:38:35 2006
@@ -512,10 +512,10 @@
\class{object} as one of its bases.
\end{notice}
-The \module{sqlite3} module has two default adapters for Python's builtin
-\class{datetime.date} and \class{datetime.datetime} types. Now let's suppose we
-want to store \class{datetime.datetime} objects not in ISO representation, but
-as Unix timestamp.
+The \module{sqlite3} module has two default adapters for Python's built-in
+\class{datetime.date} and \class{datetime.datetime} types. Now let's suppose
+we want to store \class{datetime.datetime} objects not in ISO representation,
+but as a \UNIX{} timestamp.
\verbatiminput{sqlite3/adapter_datetime.py}
Modified: stackless/trunk/Doc/lib/libstdtypes.tex
==============================================================================
--- stackless/trunk/Doc/lib/libstdtypes.tex (original)
+++ stackless/trunk/Doc/lib/libstdtypes.tex Mon Aug 14 12:38:35 2006
@@ -1,4 +1,4 @@
-\section{Built-in Types \label{types}}
+\chapter{Built-in Types \label{types}}
The following sections describe the standard types that are built into
the interpreter.
@@ -7,14 +7,14 @@
the built-in types as the basis for object-oriented inheritance.
This limitation does not exist any longer.}
-The principal built-in types are numerics, sequences, mappings, files
+The principal built-in types are numerics, sequences, mappings, files,
classes, instances and exceptions.
\indexii{built-in}{types}
Some operations are supported by several object types; in particular,
practically all objects can be compared, tested for truth value,
-and converted to a string (with the \code{`\textrm{\ldots}`} notation,
-the equivalent \function{repr()} function, or the slightly different
+and converted to a string (with
+the \function{repr()} function or the slightly different
\function{str()} function). The latter
function is implicitly used when an object is written by the
\keyword{print}\stindex{print} statement.
@@ -24,7 +24,7 @@
\citetitle[../tut/tut.html]{Python Tutorial}.)
-\subsection{Truth Value Testing\label{truth}}
+\section{Truth Value Testing\label{truth}}
Any object can be tested for truth value, for use in an \keyword{if} or
\keyword{while} condition or as operand of the Boolean operations below.
@@ -71,7 +71,7 @@
\index{False}
\index{True}
-\subsection{Boolean Operations ---
+\section{Boolean Operations ---
\keyword{and}, \keyword{or}, \keyword{not}
\label{boolean}}
@@ -107,7 +107,7 @@
\end{description}
-\subsection{Comparisons \label{comparisons}}
+\section{Comparisons \label{comparisons}}
Comparison operations are supported by all objects. They all have the
same priority (which is higher than that of the Boolean operations).
@@ -174,7 +174,7 @@
only by sequence types (below).
-\subsection{Numeric Types ---
+\section{Numeric Types ---
\class{int}, \class{float}, \class{long}, \class{complex}
\label{typesnumeric}}
@@ -307,7 +307,7 @@
\end{description}
% XXXJH exceptions: overflow (when? what operations?) zerodivision
-\subsubsection{Bit-string Operations on Integer Types \label{bitstring-ops}}
+\subsection{Bit-string Operations on Integer Types \label{bitstring-ops}}
\nodename{Bit-string Operations}
Plain and long integer types support additional operations that make
@@ -350,7 +350,7 @@
\end{description}
-\subsection{Iterator Types \label{typeiter}}
+\section{Iterator Types \label{typeiter}}
\versionadded{2.2}
\index{iterator protocol}
@@ -414,7 +414,7 @@
supplying the \method{__iter__()} and \method{next()} methods.
-\subsection{Sequence Types ---
+\section{Sequence Types ---
\class{str}, \class{unicode}, \class{list},
\class{tuple}, \class{buffer}, \class{xrange}
\label{typesseq}}
@@ -566,7 +566,7 @@
\end{description}
-\subsubsection{String Methods \label{string-methods}}
+\subsection{String Methods \label{string-methods}}
\indexii{string}{methods}
These are the string methods which both 8-bit strings and Unicode
@@ -901,7 +901,7 @@
\end{methoddesc}
-\subsubsection{String Formatting Operations \label{typesseq-strings}}
+\subsection{String Formatting Operations \label{typesseq-strings}}
\index{formatting, string (\%{})}
\index{interpolation, string (\%{})}
@@ -1072,7 +1072,7 @@
\refmodule{re}.\refstmodindex{re}
-\subsubsection{XRange Type \label{typesseq-xrange}}
+\subsection{XRange Type \label{typesseq-xrange}}
The \class{xrange}\obindex{xrange} type is an immutable sequence which
is commonly used for looping. The advantage of the \class{xrange}
@@ -1084,7 +1084,7 @@
iteration, and the \function{len()} function.
-\subsubsection{Mutable Sequence Types \label{typesseq-mutable}}
+\subsection{Mutable Sequence Types \label{typesseq-mutable}}
List objects support additional operations that allow in-place
modification of the object.
@@ -1216,7 +1216,7 @@
that the list has been mutated during a sort.
\end{description}
-\subsection{Set Types ---
+\section{Set Types ---
\class{set}, \class{frozenset}
\label{types-set}}
\obindex{set}
@@ -1355,7 +1355,7 @@
\end{seealso}
-\subsection{Mapping Types --- \class{dict} \label{typesmapping}}
+\section{Mapping Types --- \class{dict} \label{typesmapping}}
\obindex{mapping}
\obindex{dictionary}
@@ -1518,7 +1518,7 @@
\end{description}
-\subsection{File Objects
+\section{File Objects
\label{bltin-file-objects}}
File objects\obindex{file} are implemented using C's \code{stdio}
@@ -1797,7 +1797,7 @@
\end{memberdesc}
-\subsection{Context Manager Types \label{typecontextmanager}}
+\section{Context Manager Types \label{typecontextmanager}}
\versionadded{2.5}
\index{context manager}
@@ -1878,13 +1878,13 @@
is negligible.
-\subsection{Other Built-in Types \label{typesother}}
+\section{Other Built-in Types \label{typesother}}
The interpreter supports several other kinds of objects.
Most of these support only one or two operations.
-\subsubsection{Modules \label{typesmodules}}
+\subsection{Modules \label{typesmodules}}
The only special operation on a module is attribute access:
\code{\var{m}.\var{name}}, where \var{m} is a module and \var{name}
@@ -1910,14 +1910,14 @@
'/usr/local/lib/python\shortversion/os.pyc'>}.
-\subsubsection{Classes and Class Instances \label{typesobjects}}
+\subsection{Classes and Class Instances \label{typesobjects}}
\nodename{Classes and Instances}
See chapters 3 and 7 of the \citetitle[../ref/ref.html]{Python
Reference Manual} for these.
-\subsubsection{Functions \label{typesfunctions}}
+\subsection{Functions \label{typesfunctions}}
Function objects are created by function definitions. The only
operation on a function object is to call it:
@@ -1931,7 +1931,7 @@
See the \citetitle[../ref/ref.html]{Python Reference Manual} for more
information.
-\subsubsection{Methods \label{typesmethods}}
+\subsection{Methods \label{typesmethods}}
\obindex{method}
Methods are functions that are called using the attribute notation.
@@ -1976,7 +1976,7 @@
information.
-\subsubsection{Code Objects \label{bltin-code-objects}}
+\subsection{Code Objects \label{bltin-code-objects}}
\obindex{code}
Code objects are used by the implementation to represent
@@ -1999,7 +1999,7 @@
information.
-\subsubsection{Type Objects \label{bltin-type-objects}}
+\subsection{Type Objects \label{bltin-type-objects}}
Type objects represent the various object types. An object's type is
accessed by the built-in function \function{type()}. There are no special
@@ -2011,7 +2011,7 @@
Types are written like this: \code{<type 'int'>}.
-\subsubsection{The Null Object \label{bltin-null-object}}
+\subsection{The Null Object \label{bltin-null-object}}
This object is returned by functions that don't explicitly return a
value. It supports no special operations. There is exactly one null
@@ -2020,7 +2020,7 @@
It is written as \code{None}.
-\subsubsection{The Ellipsis Object \label{bltin-ellipsis-object}}
+\subsection{The Ellipsis Object \label{bltin-ellipsis-object}}
This object is used by extended slice notation (see the
\citetitle[../ref/ref.html]{Python Reference Manual}). It supports no
@@ -2029,7 +2029,7 @@
It is written as \code{Ellipsis}.
-\subsubsection{Boolean Values}
+\subsection{Boolean Values}
Boolean values are the two constant objects \code{False} and
\code{True}. They are used to represent truth values (although other
@@ -2046,14 +2046,14 @@
\indexii{Boolean}{values}
-\subsubsection{Internal Objects \label{typesinternal}}
+\subsection{Internal Objects \label{typesinternal}}
See the \citetitle[../ref/ref.html]{Python Reference Manual} for this
information. It describes stack frame objects, traceback objects, and
slice objects.
-\subsection{Special Attributes \label{specialattrs}}
+\section{Special Attributes \label{specialattrs}}
The implementation adds a few special read-only attributes to several
object types, where they are relevant. Some of these are not reported
Modified: stackless/trunk/Doc/lib/libstringio.tex
==============================================================================
--- stackless/trunk/Doc/lib/libstringio.tex (original)
+++ stackless/trunk/Doc/lib/libstringio.tex Mon Aug 14 12:38:35 2006
@@ -37,6 +37,24 @@
Free the memory buffer.
\end{methoddesc}
+Example usage:
+
+\begin{verbatim}
+import StringIO
+
+output = StringIO.StringIO()
+output.write('First line.\n')
+print >>output, 'Second line.'
+
+# Retrieve file contents -- this will be
+# 'First line.\nSecond line.\n'
+contents = output.getvalue()
+
+# Close object and discard memory buffer --
+# .getvalue() will now raise an exception.
+output.close()
+\end{verbatim}
+
\section{\module{cStringIO} ---
Faster version of \module{StringIO}}
@@ -82,3 +100,22 @@
There is a C API to the module as well; refer to the module source for
more information.
+
+Example usage:
+
+\begin{verbatim}
+import cStringIO
+
+output = cStringIO.StringIO()
+output.write('First line.\n')
+print >>output, 'Second line.'
+
+# Retrieve file contents -- this will be
+# 'First line.\nSecond line.\n'
+contents = output.getvalue()
+
+# Close object and discard memory buffer --
+# .getvalue() will now raise an exception.
+output.close()
+\end{verbatim}
+
Modified: stackless/trunk/Doc/lib/libsubprocess.tex
==============================================================================
--- stackless/trunk/Doc/lib/libsubprocess.tex (original)
+++ stackless/trunk/Doc/lib/libsubprocess.tex Mon Aug 14 12:38:35 2006
@@ -107,7 +107,7 @@
If \var{universal_newlines} is \constant{True}, the file objects stdout
and stderr are opened as text files, but lines may be terminated by
-any of \code{'\e n'}, the Unix end-of-line convention, \code{'\e r'},
+any of \code{'\e n'}, the \UNIX{} end-of-line convention, \code{'\e r'},
the Macintosh convention or \code{'\e r\e n'}, the Windows convention.
All of these external representations are seen as \code{'\e n'} by the
Python program. \note{This feature is only available if Python is built
@@ -140,7 +140,7 @@
Run command with arguments. Wait for command to complete. If the exit
code was zero then return, otherwise raise \exception{CalledProcessError.}
The \exception{CalledProcessError} object will have the return code in the
-\member{errno} attribute.
+\member{returncode} attribute.
The arguments are the same as for the Popen constructor. Example:
@@ -164,9 +164,8 @@
A \exception{ValueError} will be raised if \class{Popen} is called
with invalid arguments.
-check_call() will raise \exception{CalledProcessError}, which is a
-subclass of \exception{OSError}, if the called process returns a
-non-zero return code.
+check_call() will raise \exception{CalledProcessError}, if the called
+process returns a non-zero return code.
\subsubsection{Security}
Modified: stackless/trunk/Doc/lib/libsys.tex
==============================================================================
--- stackless/trunk/Doc/lib/libsys.tex (original)
+++ stackless/trunk/Doc/lib/libsys.tex Mon Aug 14 12:38:35 2006
@@ -21,7 +21,7 @@
\begin{datadesc}{byteorder}
An indicator of the native byte order. This will have the value
- \code{'big'} on big-endian (most-signigicant byte first) platforms,
+ \code{'big'} on big-endian (most-significant byte first) platforms,
and \code{'little'} on little-endian (least-significant byte first)
platforms.
\versionadded{2.0}
@@ -258,14 +258,14 @@
\begin{itemize}
\item On Windows 9x, the encoding is ``mbcs''.
\item On Mac OS X, the encoding is ``utf-8''.
-\item On Unix, the encoding is the user's preference
- according to the result of nl_langinfo(CODESET), or None if
- the nl_langinfo(CODESET) failed.
+\item On \UNIX, the encoding is the user's preference
+ according to the result of nl_langinfo(CODESET), or \constant{None}
+ if the \code{nl_langinfo(CODESET)} failed.
\item On Windows NT+, file names are Unicode natively, so no conversion
- is performed. \code{getfilesystemencoding} still returns ``mbcs'',
- as this is the encoding that applications should use when they
- explicitly want to convert Unicode strings to byte strings that
- are equivalent when used as file names.
+ is performed. \function{getfilesystemencoding()} still returns
+ \code{'mbcs'}, as this is the encoding that applications should use
+ when they explicitly want to convert Unicode strings to byte strings
+ that are equivalent when used as file names.
\end{itemize}
\versionadded{2.3}
\end{funcdesc}
Modified: stackless/trunk/Doc/lib/libtime.tex
==============================================================================
--- stackless/trunk/Doc/lib/libtime.tex (original)
+++ stackless/trunk/Doc/lib/libtime.tex Mon Aug 14 12:38:35 2006
@@ -226,6 +226,8 @@
\versionchanged[Allowed \var{t} to be omitted]{2.1}
\versionchanged[\exception{ValueError} raised if a field in \var{t} is
out of range]{2.4}
+\versionchanged[0 is now a legal argument for any position in the time tuple;
+if it is normally illegal the value is forced to a correct one.]{2.5}
The following directives can be embedded in the \var{format} string.
@@ -425,7 +427,7 @@
'16:08:12 05/08/03 AEST'
\end{verbatim}
-On many Unix systems (including *BSD, Linux, Solaris, and Darwin), it
+On many \UNIX{} systems (including *BSD, Linux, Solaris, and Darwin), it
is more convenient to use the system's zoneinfo (\manpage{tzfile}{5})
database to specify the timezone rules. To do this, set the
\envvar{TZ} environment variable to the path of the required timezone
Modified: stackless/trunk/Doc/lib/libturtle.tex
==============================================================================
--- stackless/trunk/Doc/lib/libturtle.tex (original)
+++ stackless/trunk/Doc/lib/libturtle.tex Mon Aug 14 12:38:35 2006
@@ -27,6 +27,45 @@
Set angle measurement units to radians.
\end{funcdesc}
+\begin{funcdesc}{setup}{**kwargs}
+Sets the size and position of the main window. Keywords are:
+\begin{itemize}
+ \item \code{width}: either a size in pixels or a fraction of the screen.
+ The default is 50\% of the screen.
+ \item \code{height}: either a size in pixels or a fraction of the screen.
+ The default is 50\% of the screen.
+ \item \code{startx}: starting position in pixels from the left edge
+ of the screen. \code{None} is the default value and
+ centers the window horizontally on screen.
+ \item \code{starty}: starting position in pixels from the top edge
+ of the screen. \code{None} is the default value and
+ centers the window vertically on screen.
+\end{itemize}
+
+ Examples:
+
+\begin{verbatim}
+# Uses default geometry: 50% x 50% of screen, centered.
+setup()
+
+# Sets window to 200x200 pixels, in upper left of screen
+setup (width=200, height=200, startx=0, starty=0)
+
+# Sets window to 75% of screen by 50% of screen, and centers it.
+setup(width=.75, height=0.5, startx=None, starty=None)
+\end{verbatim}
+
+\end{funcdesc}
+
+\begin{funcdesc}{title}{title_str}
+Set the window's title to \var{title}.
+\end{funcdesc}
+
+\begin{funcdesc}{done}{}
+Enters the Tk main loop. The window will continue to
+be displayed until the user closes it or the process is killed.
+\end{funcdesc}
+
\begin{funcdesc}{reset}{}
Clear the screen, re-center the pen, and set variables to the default
values.
Modified: stackless/trunk/Doc/lib/libtypes.tex
==============================================================================
--- stackless/trunk/Doc/lib/libtypes.tex (original)
+++ stackless/trunk/Doc/lib/libtypes.tex Mon Aug 14 12:38:35 2006
@@ -180,6 +180,30 @@
\function{buffer()}\bifuncindex{buffer} function.
\end{datadesc}
+\begin{datadesc}{DictProxyType}
+The type of dict proxies, such as \code{TypeType.__dict__}.
+\end{datadesc}
+
+\begin{datadesc}{NotImplementedType}
+The type of \code{NotImplemented}
+\end{datadesc}
+
+\begin{datadesc}{GetSetDescriptorType}
+The type of objects defined in extension modules with \code{PyGetSetDef}, such
+as \code{FrameType.f_locals} or \code{array.array.typecode}. This constant is
+not defined in implementations of Python that do not have such extension
+types, so for portable code use \code{hasattr(types, 'GetSetDescriptorType')}.
+\versionadded{2.5}
+\end{datadesc}
+
+\begin{datadesc}{MemberDescriptorType}
+The type of objects defined in extension modules with \code{PyMemberDef}, such
+as \code {datetime.timedelta.days}. This constant is not defined in
+implementations of Python that do not have such extension types, so for
+portable code use \code{hasattr(types, 'MemberDescriptorType')}.
+\versionadded{2.5}
+\end{datadesc}
+
\begin{datadesc}{StringTypes}
A sequence containing \code{StringType} and \code{UnicodeType} used to
facilitate easier checking for any string object. Using this is more
Modified: stackless/trunk/Doc/lib/libundoc.tex
==============================================================================
--- stackless/trunk/Doc/lib/libundoc.tex (original)
+++ stackless/trunk/Doc/lib/libundoc.tex Mon Aug 14 12:38:35 2006
@@ -49,7 +49,7 @@
\item[\module{bsddb185}]
--- Backwards compatibility module for systems which still use the Berkeley
- DB 1.85 module. It is normally only available on certain BSD Unix-based
+ DB 1.85 module. It is normally only available on certain BSD \UNIX-based
systems. It should never be used directly.
\end{description}
Modified: stackless/trunk/Doc/lib/libunicodedata.tex
==============================================================================
--- stackless/trunk/Doc/lib/libunicodedata.tex (original)
+++ stackless/trunk/Doc/lib/libunicodedata.tex Mon Aug 14 12:38:35 2006
@@ -14,11 +14,11 @@
This module provides access to the Unicode Character Database which
defines character properties for all Unicode characters. The data in
this database is based on the \file{UnicodeData.txt} file version
-4.1.0 which is publically available from \url{ftp://ftp.unicode.org/}.
+4.1.0 which is publicly available from \url{ftp://ftp.unicode.org/}.
The module uses the same names and symbols as defined by the
UnicodeData File Format 4.1.0 (see
-\url{http://www.unicode.org/Public/4.1-Update/UnicodeData-4.1.0.html}). It
+\url{http://www.unicode.org/Public/4.1.0/ucd/UCD.html}). It
defines the following functions:
\begin{funcdesc}{lookup}{name}
@@ -108,7 +108,7 @@
Normal form C (NFC) first applies a canonical decomposition, then
composes pre-combined characters again.
-In addition to these two forms, there two additional normal forms
+In addition to these two forms, there are two additional normal forms
based on compatibility equivalence. In Unicode, certain characters are
supported which normally would be unified with other characters. For
example, U+2160 (ROMAN NUMERAL ONE) is really the same thing as U+0049
@@ -139,3 +139,22 @@
\versionadded{2.5}
\end{datadesc}
+
+Examples:
+
+\begin{verbatim}
+>>> unicodedata.lookup('LEFT CURLY BRACKET')
+u'{'
+>>> unicodedata.name(u'/')
+'SOLIDUS'
+>>> unicodedata.decimal(u'9')
+9
+>>> unicodedata.decimal(u'a')
+Traceback (most recent call last):
+ File "<stdin>", line 1, in ?
+ValueError: not a decimal
+>>> unicodedata.category(u'A') # 'L'etter, 'u'ppercase
+'Lu'
+>>> unicodedata.bidirectional(u'\u0660') # 'A'rabic, 'N'umber
+'AN'
+\end{verbatim}
Modified: stackless/trunk/Doc/lib/liburllib.tex
==============================================================================
--- stackless/trunk/Doc/lib/liburllib.tex (original)
+++ stackless/trunk/Doc/lib/liburllib.tex Mon Aug 14 12:38:35 2006
@@ -270,10 +270,10 @@
environmental proxy settings will be used if present, as discussed in
the definition of \function{urlopen()}, above.
-Additional keyword parameters, collected in \var{x509}, are used for
-authentication with the \file{https:} scheme. The keywords
-\var{key_file} and \var{cert_file} are supported; both are needed to
-actually retrieve a resource at an \file{https:} URL.
+Additional keyword parameters, collected in \var{x509}, may be used for
+authentication of the client when using the \file{https:} scheme. The keywords
+\var{key_file} and \var{cert_file} are supported to provide an
+SSL key and certificate; both are needed to support client authentication.
\class{URLopener} objects will raise an \exception{IOError} exception
if the server returns an error code.
Modified: stackless/trunk/Doc/lib/liburllib2.tex
==============================================================================
--- stackless/trunk/Doc/lib/liburllib2.tex (original)
+++ stackless/trunk/Doc/lib/liburllib2.tex Mon Aug 14 12:38:35 2006
@@ -19,7 +19,8 @@
object.
\var{data} may be a string specifying additional data to send to the
-server. Currently HTTP requests are the only ones that use \var{data};
+server, or \code{None} if no such data is needed.
+Currently HTTP requests are the only ones that use \var{data};
the HTTP request will be a POST instead of a GET when the \var{data}
parameter is provided. \var{data} should be a buffer in the standard
\mimetype{application/x-www-form-urlencoded} format. The
@@ -97,8 +98,17 @@
\optional{, origin_req_host}\optional{, unverifiable}}
This class is an abstraction of a URL request.
-\var{url} should be a string which is a valid URL. For a description
-of \var{data} see the \method{add_data()} description.
+\var{url} should be a string containing a valid URL.
+
+\var{data} may be a string specifying additional data to send to the
+server, or \code{None} if no such data is needed.
+Currently HTTP requests are the only ones that use \var{data};
+the HTTP request will be a POST instead of a GET when the \var{data}
+parameter is provided. \var{data} should be a buffer in the standard
+\mimetype{application/x-www-form-urlencoded} format. The
+\function{urllib.urlencode()} function takes a mapping or sequence of
+2-tuples and returns a string in this format.
+
\var{headers} should be a dictionary, and will be treated as if
\method{add_header()} was called with each key and value as arguments.
Modified: stackless/trunk/Doc/lib/libuuid.tex
==============================================================================
--- stackless/trunk/Doc/lib/libuuid.tex (original)
+++ stackless/trunk/Doc/lib/libuuid.tex Mon Aug 14 12:38:35 2006
@@ -32,7 +32,7 @@
Create a UUID from either a string of 32 hexadecimal digits,
a string of 16 bytes as the \var{bytes} argument, a tuple of six
-integers (32-bit \var{time_low}, 16-bit \var{time_mid},
+integers (32-bit \var{time_low}, 16-bit \var{time_mid},
16-bit \var{time_hi_version},
8-bit \var{clock_seq_hi_variant}, 8-bit \var{clock_seq_low}, 48-bit \var{node})
as the \var{fields} argument, or a single 128-bit integer as the \var{int}
@@ -109,10 +109,13 @@
The \module{uuid} module defines the following functions
\begin{funcdesc}{getnode}{}
-Get the hardware address as a 48-bit integer. The first time this runs,
-it may launch a separate program, which could be quite slow. If all
+Get the hardware address as a 48-bit positive integer. The first time this
+runs, it may launch a separate program, which could be quite slow. If all
attempts to obtain the hardware address fail, we choose a random 48-bit
-number with its eighth bit set to 1 as recommended in RFC 4122.
+number with its eighth bit set to 1 as recommended in RFC 4122. "Hardware
+address" means the MAC address of a network interface, and on a machine
+with multiple network interfaces the MAC address of any one of them may
+be returned.
\end{funcdesc}
\index{getnode}
@@ -126,10 +129,10 @@
\index{uuid1}
\begin{funcdesc}{uuid3}{namespace, name}
-Generate a UUID based upon a MD5 hash of the \var{name} string value
-drawn from a specified namespace. \var{namespace}
+Generate a UUID based upon a MD5 hash of the \var{name} string value
+drawn from a specified namespace. \var{namespace}
must be one of \constant{NAMESPACE_DNS},
-\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID},
+\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID},
or \constant{NAMESPACE_X500}.
\end{funcdesc}
\index{uuid3}
@@ -140,15 +143,15 @@
\index{uuid4}
\begin{funcdesc}{uuid5}{namespace, name}
-Generate a UUID based upon a SHA-1 hash of the \var{name} string value
-drawn from a specified namespace. \var{namespace}
+Generate a UUID based upon a SHA-1 hash of the \var{name} string value
+drawn from a specified namespace. \var{namespace}
must be one of \constant{NAMESPACE_DNS},
-\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID},
+\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID},
or \constant{NAMESPACE_X500}.
\end{funcdesc}
\index{uuid5}
-The \module{uuid} module defines the following namespace constants
+The \module{uuid} module defines the following namespace constants
for use with \function{uuid3()} or \function{uuid5()}.
\begin{datadesc}{NAMESPACE_DNS}
@@ -167,7 +170,7 @@
X.500 DN namespace UUID.
\end{datadesc}
-The \module{uuid} module defines the following constants
+The \module{uuid} module defines the following constants
for the possible values of the \member{variant} attribute:
\begin{datadesc}{RESERVED_NCS}
Modified: stackless/trunk/Doc/lib/libweakref.tex
==============================================================================
--- stackless/trunk/Doc/lib/libweakref.tex (original)
+++ stackless/trunk/Doc/lib/libweakref.tex Mon Aug 14 12:38:35 2006
@@ -65,10 +65,14 @@
obj = Dict(red=1, green=2, blue=3) # this object is weak referencable
\end{verbatim}
-Extension types can easily be made to support weak references; see section
-\ref{weakref-extension}, ``Weak References in Extension Types,'' for more
-information.
-
+Extension types can easily be made to support weak references; see
+``\ulink{Weak Reference Support}{../ext/weakref-support.html}'' in
+\citetitle[../ext/ext.html]{Extending and Embedding the Python
+Interpreter}.
+% The referenced section used to appear in this document with the
+% \label weakref-extension. It would be good to be able to generate a
+% redirect for the corresponding HTML page (weakref-extension.html)
+% for on-line versions of this document.
\begin{classdesc}{ref}{object\optional{, callback}}
Return a weak reference to \var{object}. The original object can be
@@ -330,83 +334,3 @@
def id2obj(oid):
return _id2obj_dict[oid]
\end{verbatim}
-
-
-\subsection{Weak References in Extension Types
- \label{weakref-extension}}
-
-One of the goals of the implementation is to allow any type to
-participate in the weak reference mechanism without incurring the
-overhead on those objects which do not benefit by weak referencing
-(such as numbers).
-
-For an object to be weakly referencable, the extension must include a
-\ctype{PyObject*} field in the instance structure for the use of the
-weak reference mechanism; it must be initialized to \NULL{} by the
-object's constructor. It must also set the \member{tp_weaklistoffset}
-field of the corresponding type object to the offset of the field.
-Also, it needs to add \constant{Py_TPFLAGS_HAVE_WEAKREFS} to the
-tp_flags slot. For example, the instance type is defined with the
-following structure:
-
-\begin{verbatim}
-typedef struct {
- PyObject_HEAD
- PyClassObject *in_class; /* The class object */
- PyObject *in_dict; /* A dictionary */
- PyObject *in_weakreflist; /* List of weak references */
-} PyInstanceObject;
-\end{verbatim}
-
-The statically-declared type object for instances is defined this way:
-
-\begin{verbatim}
-PyTypeObject PyInstance_Type = {
- PyObject_HEAD_INIT(&PyType_Type)
- 0,
- "module.instance",
-
- /* Lots of stuff omitted for brevity... */
-
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS /* tp_flags */
- 0, /* tp_doc */
- 0, /* tp_traverse */
- 0, /* tp_clear */
- 0, /* tp_richcompare */
- offsetof(PyInstanceObject, in_weakreflist), /* tp_weaklistoffset */
-};
-\end{verbatim}
-
-The type constructor is responsible for initializing the weak reference
-list to \NULL:
-
-\begin{verbatim}
-static PyObject *
-instance_new() {
- /* Other initialization stuff omitted for brevity */
-
- self->in_weakreflist = NULL;
-
- return (PyObject *) self;
-}
-\end{verbatim}
-
-The only further addition is that the destructor needs to call the
-weak reference manager to clear any weak references. This should be
-done before any other parts of the destruction have occurred, but is
-only required if the weak reference list is non-\NULL:
-
-\begin{verbatim}
-static void
-instance_dealloc(PyInstanceObject *inst)
-{
- /* Allocate temporaries if needed, but do not begin
- destruction just yet.
- */
-
- if (inst->in_weakreflist != NULL)
- PyObject_ClearWeakRefs((PyObject *) inst);
-
- /* Proceed with object destruction normally. */
-}
-\end{verbatim}
Modified: stackless/trunk/Doc/lib/libwebbrowser.tex
==============================================================================
--- stackless/trunk/Doc/lib/libwebbrowser.tex (original)
+++ stackless/trunk/Doc/lib/libwebbrowser.tex Mon Aug 14 12:38:35 2006
@@ -136,6 +136,18 @@
Only on MacOS X platform.
\end{description}
+Here are some simple examples:
+
+\begin{verbatim}
+url = 'http://www.python.org'
+
+# Open URL in a new tab, if a browser window is already open.
+webbrowser.open_new_tab(url + '/doc')
+
+# Open URL in new window, raising the window if possible.
+webbrowser.open_new(url)
+\end{verbatim}
+
\subsection{Browser Controller Objects \label{browser-controllers}}
Modified: stackless/trunk/Doc/lib/libzipfile.tex
==============================================================================
--- stackless/trunk/Doc/lib/libzipfile.tex (original)
+++ stackless/trunk/Doc/lib/libzipfile.tex Mon Aug 14 12:38:35 2006
@@ -106,12 +106,12 @@
is specified but the \refmodule{zlib} module is not available,
\exception{RuntimeError} is also raised. The default is
\constant{ZIP_STORED}.
- If \var{allowZip64} is \code{True} zipfile will create zipfiles that use
- the ZIP64 extensions when the zipfile is larger than 2GBytes. If it is
- false (the default) zipfile will raise an exception when the zipfile would
- require ZIP64 extensions. ZIP64 extensions are disabled by default because
- the default zip and unzip commands on Unix (the InfoZIP utilities) don't
- support these extensions.
+ If \var{allowZip64} is \code{True} zipfile will create ZIP files that use
+ the ZIP64 extensions when the zipfile is larger than 2 GB. If it is
+ false (the default) \module{zipfile} will raise an exception when the
+ ZIP file would require ZIP64 extensions. ZIP64 extensions are disabled by
+ default because the default \program{zip} and \program{unzip} commands on
+ \UNIX{} (the InfoZIP utilities) don't support these extensions.
\end{classdesc}
\begin{methoddesc}{close}{}
Modified: stackless/trunk/Doc/lib/sqlite3/complete_statement.py
==============================================================================
--- stackless/trunk/Doc/lib/sqlite3/complete_statement.py (original)
+++ stackless/trunk/Doc/lib/sqlite3/complete_statement.py Mon Aug 14 12:38:35 2006
@@ -24,7 +24,7 @@
if buffer.lstrip().upper().startswith("SELECT"):
print cur.fetchall()
except sqlite3.Error, e:
- print "An error occured:", e.args[0]
+ print "An error occurred:", e.args[0]
buffer = ""
con.close()
Modified: stackless/trunk/Doc/lib/tkinter.tex
==============================================================================
--- stackless/trunk/Doc/lib/tkinter.tex (original)
+++ stackless/trunk/Doc/lib/tkinter.tex Mon Aug 14 12:38:35 2006
@@ -18,10 +18,9 @@
module \module{\_tkinter} provides a threadsafe mechanism which allows
Python and Tcl to interact.
-Tk is not the only GUI for Python, but is however the most commonly
-used one; see section~\ref{other-gui-modules}, ``Other User Interface
-Modules and Packages,'' for more information on other GUI toolkits for
-Python.
+Tk is not the only GUI for Python; see
+section~\ref{other-gui-packages}, ``Other User Interface Modules and
+Packages,'' for more information on other GUI toolkits for Python.
% Other sections I have in mind are
% Tkinter internals
@@ -103,14 +102,14 @@
\end{classdesc}
\begin{funcdesc}{Tcl}{screenName=None, baseName=None, className='Tk', useTk=0}
-The \function{Tcl} function is a factory function which creates an object
-much like that created by the \class{Tk} class, except that it does not
-initialize the Tk subsystem. This is most often useful when driving the Tcl
-interpreter in an environment where one doesn't want to create extraneous
-toplevel windows, or where one cannot (i.e. Unix/Linux systems without an X
-server). An object created by the \function{Tcl} object can have a Toplevel
-window created (and the Tk subsystem initialized) by calling its
-\method{loadtk} method.
+The \function{Tcl} function is a factory function which creates an
+object much like that created by the \class{Tk} class, except that it
+does not initialize the Tk subsystem. This is most often useful when
+driving the Tcl interpreter in an environment where one doesn't want
+to create extraneous toplevel windows, or where one cannot (such as
+\UNIX/Linux systems without an X server). An object created by the
+\function{Tcl} object can have a Toplevel window created (and the Tk
+subsystem initialized) by calling its \method{loadtk} method.
\versionadded{2.4}
\end{funcdesc}
@@ -316,10 +315,10 @@
periods. For example, \code{.myApp.controlPanel.okButton} might be
the name of a widget.
-\item[\var{options} ]
+\item[\var{options}]
configure the widget's appearance and in some cases, its
behavior. The options come in the form of a list of flags and values.
-Flags are proceeded by a `-', like unix shell command flags, and
+Flags are proceeded by a `-', like \UNIX{} shell command flags, and
values are put in quotes if they are more than one word.
\end{description}
@@ -1806,24 +1805,29 @@
through the Tk/Tcl layer.}
\end{seealso*}
-
-Tk is not the only GUI for Python, but is however the
-most commonly used one.
+Other GUI packages are also available for Python:
\begin{seealso*}
-\seetitle[http://www.wxwindows.org]{wxWindows}{
-is a GUI toolkit that combines the most attractive attributes of Qt,
-Tk, Motif, and GTK+ in one powerful and efficient package. It is
-implemented in \Cpp. wxWindows supports two flavors of \UNIX{}
-implementation: GTK+ and Motif, and under Windows, it has a standard
-Microsoft Foundation Classes (MFC) appearance, because it uses Win32
-widgets. There is a Python class wrapper, independent of Tkinter.
-
-wxWindows is much richer in widgets than \refmodule{Tkinter}, with its
-help system, sophisticated HTML and image viewers, and other
-specialized widgets, extensive documentation, and printing capabilities.
+\seetitle[http://www.wxpython.org]{wxPython}{
+wxPython is a cross-platform GUI toolkit for Python that is built
+around the popular \ulink{wxWidgets}{http://www.wxwidgets.org/} \Cpp{}
+toolkit. It provides a native look and feel for applications on
+Windows, Mac OS X, and \UNIX{} systems by using each platform's native
+widgets where ever possible, (GTK+ on \UNIX-like systems). In
+addition to an extensive set of widgets, wxPython provides classes for
+online documentation and context sensitive help, printing, HTML
+viewing, low-level device context drawing, drag and drop, system
+clipboard access, an XML-based resource format and more, including an
+ever growing library of user-contributed modules. Both the wxWidgets
+and wxPython projects are under active development and continuous
+improvement, and have active and helpful user and developer
+communities.
+}
+\seetitle[http://www.amazon.com/exec/obidos/ASIN/1932394621]
+{wxPython in Action}{
+The wxPython book, by Noel Rappin and Robin Dunn.
}
-\seetitle[]{PyQt}{
+\seetitle{PyQt}{
PyQt is a \program{sip}-wrapped binding to the Qt toolkit. Qt is an
extensive \Cpp{} GUI toolkit that is available for \UNIX, Windows and
Mac OS X. \program{sip} is a tool for generating bindings for \Cpp{}
Modified: stackless/trunk/Doc/mac/libmacfs.tex
==============================================================================
--- stackless/trunk/Doc/mac/libmacfs.tex (original)
+++ stackless/trunk/Doc/mac/libmacfs.tex Mon Aug 14 12:38:35 2006
@@ -22,10 +22,10 @@
argument can be one of three things:\ (1) a full or partial Macintosh
pathname, (2) an \class{FSSpec} object or (3) a 3-tuple
\code{(\var{wdRefNum}, \var{parID}, \var{name})} as described in
-\citetitle{Inside Macintosh:\ Files}. An \class{FSSpec} can point to
+\citetitle{Inside Macintosh:\ Files}. An \class{FSSpec} can point to
a non-existing file, as long as the folder containing the file exists.
-Under MacPython the same is true for a pathname, but not under unix-Pyton
-because of the way pathnames and FSRefs works. See Apple's documentation
+Under MacPython the same is true for a pathname, bu