Merged revisions 59985-60000,60002,60005-60007,60009-60042 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r59987 | raymond.hettinger | 2008-01-15 21:52:42 +0100 (Tue, 15 Jan 2008) | 1 line

  Refactor if/elif chain for clarity and speed.  Remove dependency on subclasses having to implement _empty and _full.
........
  r59988 | raymond.hettinger | 2008-01-15 22:22:47 +0100 (Tue, 15 Jan 2008) | 1 line

  Fix-up half-written paragraph in the docs
........
  r59989 | amaury.forgeotdarc | 2008-01-15 22:25:11 +0100 (Tue, 15 Jan 2008) | 3 lines

  test_doctest fails since r59984.
  Not sure if these are the correct values, but save_stdout has to be set before its usage...
........
  r59992 | andrew.kuchling | 2008-01-16 01:32:03 +0100 (Wed, 16 Jan 2008) | 1 line

  Docstring typos
........
  r59993 | andrew.kuchling | 2008-01-16 04:17:25 +0100 (Wed, 16 Jan 2008) | 1 line

  Add PEP 3141 section
........
  r59998 | andrew.kuchling | 2008-01-16 14:01:51 +0100 (Wed, 16 Jan 2008) | 1 line

  Markup fix
........
  r59999 | georg.brandl | 2008-01-16 17:56:29 +0100 (Wed, 16 Jan 2008) | 2 lines

  Fix MSDN library URL. (#1854)
........
  r60006 | georg.brandl | 2008-01-16 21:27:56 +0100 (Wed, 16 Jan 2008) | 3 lines

  Add Python-specific content to Doc dir. Update configuration file
  to work with the newest Sphinx.
........
  r60007 | georg.brandl | 2008-01-16 21:29:00 +0100 (Wed, 16 Jan 2008) | 2 lines

  Doc build should work with 2.4 now.
........
  r60009 | raymond.hettinger | 2008-01-17 00:38:16 +0100 (Thu, 17 Jan 2008) | 1 line

  Minor wordsmithing.
........
  r60010 | raymond.hettinger | 2008-01-17 00:40:45 +0100 (Thu, 17 Jan 2008) | 1 line

  Add queues will alternative fetch orders (priority based and stack based).
........
  r60011 | raymond.hettinger | 2008-01-17 00:49:35 +0100 (Thu, 17 Jan 2008) | 1 line

  Add news entry.
........
  r60013 | raymond.hettinger | 2008-01-17 04:02:14 +0100 (Thu, 17 Jan 2008) | 1 line

  Make starmap() match its pure python definition and accept any itertable input (not just tuples).
........
  r60015 | gregory.p.smith | 2008-01-17 08:43:20 +0100 (Thu, 17 Jan 2008) | 3 lines

  Comply with RFC 3207.
  Fixes issue 829951 - http://bugs.python.org/issue829951
........
  r60018 | gregory.p.smith | 2008-01-17 09:03:17 +0100 (Thu, 17 Jan 2008) | 2 lines

  entry for r60015
........
  r60019 | raymond.hettinger | 2008-01-17 09:07:05 +0100 (Thu, 17 Jan 2008) | 1 line

  Note versionadded.
........
  r60020 | gregory.p.smith | 2008-01-17 09:35:49 +0100 (Thu, 17 Jan 2008) | 8 lines

  Fixes (accepts patch) issue1339 - http://bugs.python.org/issue1339
  - Factor out the duplication of EHLO/HELO in login() and sendmail() to
    a new function, ehlo_or_helo_if_needed().
  - Use ehlo_or_helo_if_needed() in starttls()
  - Check for the starttls exception in starttls() in the same way as
    login() checks for the auth extension.
  Contributed by Bill Fenner.
........
  r60021 | andrew.kuchling | 2008-01-17 13:00:15 +0100 (Thu, 17 Jan 2008) | 1 line

  Revise 3141 section a bit; add some Windows items
........
  r60022 | brett.cannon | 2008-01-17 19:45:10 +0100 (Thu, 17 Jan 2008) | 2 lines

  Fix a function pointer declaration to silence the compiler.
........
  r60024 | raymond.hettinger | 2008-01-17 20:31:38 +0100 (Thu, 17 Jan 2008) | 1 line

  Issue #1861:  Add read-only attribute listing upcoming events in the order they will be run.
........
  r60025 | andrew.kuchling | 2008-01-17 20:49:24 +0100 (Thu, 17 Jan 2008) | 1 line

  Correction from Jordan Lewis: halfdelay() uses tenths of a second, not milliseconds
........
  r60026 | raymond.hettinger | 2008-01-17 23:27:49 +0100 (Thu, 17 Jan 2008) | 1 line

  Add advice on choosing between scheduler and threading.Timer().
........
  r60028 | christian.heimes | 2008-01-18 00:01:44 +0100 (Fri, 18 Jan 2008) | 2 lines

  Updated new property syntax. An elaborate example for subclassing and the getter was missing.
  Added comment about VS 2008 and PGO builds.
........
  r60029 | raymond.hettinger | 2008-01-18 00:32:01 +0100 (Fri, 18 Jan 2008) | 1 line

  Fix-up Timer() example.
........
  r60030 | raymond.hettinger | 2008-01-18 00:56:56 +0100 (Fri, 18 Jan 2008) | 1 line

  Fix markup
........
  r60031 | raymond.hettinger | 2008-01-18 01:10:42 +0100 (Fri, 18 Jan 2008) | 1 line

  clearcache() needs to remove the dict as well as clear it.
........
  r60033 | andrew.kuchling | 2008-01-18 03:26:16 +0100 (Fri, 18 Jan 2008) | 1 line

  Bump verson
........
  r60034 | andrew.kuchling | 2008-01-18 03:42:52 +0100 (Fri, 18 Jan 2008) | 1 line

  Typo fix
........
  r60035 | christian.heimes | 2008-01-18 08:30:20 +0100 (Fri, 18 Jan 2008) | 3 lines

  Coverity issue CID #197
  var_decl: Declared variable "stm" without initializer
  ninit_use_in_call: Using uninitialized value "stm" (field "stm".tm_zone uninitialized) in call to function "mktime"
........
  r60036 | christian.heimes | 2008-01-18 08:45:30 +0100 (Fri, 18 Jan 2008) | 11 lines

  Coverity issue CID #167
  Event alloc_fn: Called allocation function "metacompile" [model]
  Event var_assign: Assigned variable "gr" to storage returned from "metacompile"
  		gr = metacompile(n);
  Event pass_arg: Variable "gr" not freed or pointed-to in function "maketables" [model]
  		g = maketables(gr);
    		translatelabels(g);
    		addfirstsets(g);
  Event leaked_storage: Returned without freeing storage "gr"
  		return g;
........
  r60038 | christian.heimes | 2008-01-18 09:04:57 +0100 (Fri, 18 Jan 2008) | 3 lines

  Coverity issue CID #182
  size_error: Allocating 1 bytes to pointer "children", which needs at least 4 bytes
........
  r60041 | christian.heimes | 2008-01-18 09:47:59 +0100 (Fri, 18 Jan 2008) | 4 lines

  Coverity issue CID #169
  local_ptr_assign_local: Assigning address of stack variable "namebuf" to pointer "filename"
  out_of_scope: Variable "namebuf" goes out of scope
  use_invalid: Used "filename" pointing to out-of-scope variable "namebuf"
........
  r60042 | christian.heimes | 2008-01-18 09:53:45 +0100 (Fri, 18 Jan 2008) | 2 lines

  Coverity CID #168
  leaked_storage: Returned without freeing storage "fp"
........
This commit is contained in:
Christian Heimes 2008-01-18 09:56:22 +00:00
parent ff72122184
commit 679db4aa99
29 changed files with 538 additions and 79 deletions

View File

@ -2,22 +2,28 @@
#
# Python documentation build configuration file
#
# This file is execfile()d with the current directory set to its containing dir.
#
# The contents of this file are pickled, so don't put values in the namespace
# that aren't pickleable (module imports are okay, they're removed automatically).
# General configuration
# ---------------------
# General substitutions.
project = 'Python'
copyright = '1990-2007, Python Software Foundation'
# The default replacements for |version| and |release|.
# If 'auto', Sphinx looks for the Include/patchlevel.h file in the current Python
# If '<auto>', Sphinx looks for the Include/patchlevel.h file in the current Python
# source tree and replaces the values accordingly.
#
# The short X.Y version.
# version = '2.6'
version = 'auto'
version = '<auto>'
# The full version, including alpha/beta/rc tags.
# release = '2.6a0'
release = 'auto'
release = '<auto>'
# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
@ -39,6 +45,9 @@ unused_files = [
'library/xml.etree.rst',
]
# Relative filename of the reference count data file.
refcount_file = 'data/refcounts.dat'
# If true, '()' will be appended to :func: etc. cross-reference text.
add_function_parentheses = True
@ -50,9 +59,6 @@ add_module_names = True
# Options for HTML output
# -----------------------
# The base URL for download links.
html_download_base_url = 'http://docs.python.org/ftp/python/doc/'
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
# using the given strftime format.
html_last_updated_fmt = '%b %d, %Y'
@ -61,12 +67,71 @@ html_last_updated_fmt = '%b %d, %Y'
# typographically correct entities.
html_use_smartypants = True
# Content template for the index page, filename relative to this file.
html_index = 'tools/sphinxext/indexcontent.html'
# Custom sidebar templates, filenames relative to this file.
html_sidebars = {
'index': 'tools/sphinxext/indexsidebar.html',
}
# Additional templates that should be rendered to pages.
html_additional_pages = {
'download': 'tools/sphinxext/download.html',
}
# Output file base name for HTML help builder.
htmlhelp_basename = 'pydoc'
# Options for LaTeX output
# ------------------------
# The paper size ("letter" or "a4").
latex_paper_size = "a4"
# The paper size ('letter' or 'a4').
latex_paper_size = 'a4'
# The font size ("10pt", "11pt" or "12pt").
latex_font_size = "10pt"
# The font size ('10pt', '11pt' or '12pt').
latex_font_size = '10pt'
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, document class [howto/manual]).
_stdauthor = r'Guido van Rossum\\Fred L. Drake, Jr., editor'
latex_documents = [
('c-api/index.rst', 'c-api.tex',
'The Python/C API', _stdauthor, 'manual'),
('distutils/index.rst', 'distutils.tex',
'Distributing Python Modules', _stdauthor, 'manual'),
('documenting/index.rst', 'documenting.tex',
'Documenting Python', 'Georg Brandl', 'manual'),
('extending/index.rst', 'extending.tex',
'Extending and Embedding Python', _stdauthor, 'manual'),
('install/index.rst', 'install.tex',
'Installing Python Modules', _stdauthor, 'manual'),
('library/index.rst', 'library.tex',
'The Python Library Reference', _stdauthor, 'manual'),
('reference/index.rst', 'reference.tex',
'The Python Language Reference', _stdauthor, 'manual'),
('tutorial/index.rst', 'tutorial.tex',
'Python Tutorial', _stdauthor, 'manual'),
('using/index.rst', 'using.tex',
'Using Python', _stdauthor, 'manual'),
('whatsnew/' + version + '.rst', 'whatsnew.tex',
'What\'s New in Python', 'A. M. Kuchling', 'howto'),
]
# Collect all HOWTOs individually
import os
latex_documents.extend(('howto/' + fn, 'howto-' + fn[:-4] + '.tex',
'HOWTO', _stdauthor, 'howto')
for fn in os.listdir('howto')
if fn.endswith('.rst') and fn != 'index.rst')
# Additional stuff for the LaTeX preamble.
latex_preamble = r'''
\authoraddress{
\strong{Python Software Foundation}\\
Email: \email{docs@python.org}
}
'''
# Documents to append as an appendix to all manuals.
latex_appendices = ['glossary.rst', 'about.rst', 'license.rst', 'copyright.rst']

View File

@ -3,7 +3,7 @@
**********************************
:Author: A.M. Kuchling, Eric S. Raymond
:Release: 2.02
:Release: 2.03
.. topic:: Abstract
@ -367,8 +367,8 @@ It's possible to change this behavior with the method :meth:`nodelay`. After
``nodelay(1)``, :meth:`getch` for the window becomes non-blocking and returns
``curses.ERR`` (a value of -1) when no input is ready. There's also a
:func:`halfdelay` function, which can be used to (in effect) set a timer on each
:meth:`getch`; if no input becomes available within the number of milliseconds
specified as the argument to :func:`halfdelay`, curses raises an exception.
:meth:`getch`; if no input becomes available within a specified
delay (measured in tenths of a second), curses raises an exception.
The :meth:`getch` method returns an integer; if it's between 0 and 255, it
represents the ASCII code of the key pressed. Values greater than 255 are

View File

@ -566,6 +566,9 @@ faster versions that bypass error-checking::
def _replace(self, _map=map, **kwds):
return self._make(_map(kwds.get, ('x', 'y'), self))
The subclasses shown above set ``__slots__`` to an empty tuple. This keeps
keep memory requirements low by preventing the creation of instance dictionaries.
Subclassing is not useful for adding new, stored fields. Instead, simply
create a new named tuple type from the :attr:`_fields` attribute::

View File

@ -319,16 +319,19 @@ loops that truncate the stream.
.. function:: starmap(function, iterable)
Make an iterator that computes the function using arguments tuples obtained from
Make an iterator that computes the function using arguments obtained from
the iterable. Used instead of :func:`imap` when argument parameters are already
grouped in tuples from a single iterable (the data has been "pre-zipped"). The
difference between :func:`imap` and :func:`starmap` parallels the distinction
between ``function(a,b)`` and ``function(*c)``. Equivalent to::
def starmap(function, iterable):
iterable = iter(iterable)
while True:
yield function(*next(iterable))
for args in iterable:
yield function(*args)
.. versionchanged:: 2.6
Previously, :func:`starmap` required the function arguments to be tuples.
Now, any iterable is allowed.
.. function:: takewhile(predicate, iterable)

View File

@ -146,7 +146,7 @@ Database Objects
.. seealso::
`MSIOpenView <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msiopenview.asp>`_
`MSIDatabaseOpenView <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msidatabaseopenview.asp>`_
`MSIDatabaseCommit <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msidatabasecommit.asp>`_
`MSIGetSummaryInformation <http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/msigetsummaryinformation.asp>`_

View File

@ -29,6 +29,7 @@ The :mod:`Queue` module defines the following classes and exceptions:
block once this size has been reached, until queue items are consumed. If
*maxsize* is less than or equal to zero, the queue size is infinite.
.. class:: LifoQueue(maxsize)
Constructor for a LIFO queue. *maxsize* is an integer that sets the upperbound
@ -36,6 +37,9 @@ The :mod:`Queue` module defines the following classes and exceptions:
block once this size has been reached, until queue items are consumed. If
*maxsize* is less than or equal to zero, the queue size is infinite.
.. versionadded:: 2.6
.. class:: PriorityQueue(maxsize)
Constructor for a priority queue. *maxsize* is an integer that sets the upperbound
@ -47,6 +51,9 @@ The :mod:`Queue` module defines the following classes and exceptions:
one returned by ``sorted(list(entries))[0]``). A typical pattern for entries
is a tuple in the form: ``(priority_number, data)``.
.. versionadded:: 2.6
.. exception:: Empty
Exception raised when non-blocking :meth:`get` (or :meth:`get_nowait`) is called

View File

@ -41,13 +41,39 @@ Example::
From print_time 930343700.273
930343700.276
In multi-threaded environments, the :class:`scheduler` class has limitations
with respect to thread-safety, inability to insert a new task before
the one currently pending in a running scheduler, and holding up the main
thread until the event queue is empty. Instead, the preferred approach
is to use the :class:`threading.Timer` class instead.
Example::
>>> import time
>>> from threading import Timer
>>> def print_time():
... print "From print_time", time.time()
...
>>> def print_some_times():
... print time.time()
... Timer(5, print_time, ()).start()
... Timer(10, print_time, ()).start()
... time.sleep(11) # sleep while time-delay events execute
... print time.time()
...
>>> print_some_times()
930343690.257
From print_time 930343695.274
From print_time 930343700.273
930343701.301
.. _scheduler-objects:
Scheduler Objects
-----------------
:class:`scheduler` instances have the following methods:
:class:`scheduler` instances have the following methods and attributes:
.. method:: scheduler.enterabs(time, priority, action, argument)
@ -98,3 +124,10 @@ Scheduler Objects
the calling code is responsible for canceling events which are no longer
pertinent.
.. attribute:: scheduler.queue
Read-only attribute returning a list of upcoming events in the order they
will be run. Each event is shown as a :term:`named tuple` with the
following fields: time, priority, action, argument.
.. versionadded:: 2.6

View File

@ -184,6 +184,16 @@ An :class:`SMTP` instance has the following methods:
necessary to call this method explicitly. It will be implicitly called by
:meth:`sendmail` when necessary.
.. method:: SMTP.ehlo_or_helo_if_needed()
This method call :meth:`ehlo` and or :meth:`helo` if there has been no
previous ``EHLO`` or ``HELO`` command this session. It tries ESMTP ``EHLO``
first.
:exc:SMTPHeloError
The server didn't reply properly to the ``HELO`` greeting.
.. versionadded:: 2.6
.. method:: SMTP.has_extn(name)
@ -230,6 +240,22 @@ An :class:`SMTP` instance has the following methods:
If *keyfile* and *certfile* are provided, these are passed to the :mod:`socket`
module's :func:`ssl` function.
If there has been no previous ``EHLO`` or ``HELO`` command this session,
this method tries ESMTP ``EHLO`` first.
.. versionchanged:: 2.6
:exc:`SMTPHeloError`
The server didn't reply properly to the ``HELO`` greeting.
:exc:`SMTPException`
The server does not support the STARTTLS extension.
.. versionchanged:: 2.6
:exc:`RuntimeError`
SSL/TLS support is not available to your python interpreter.
.. method:: SMTP.sendmail(from_addr, to_addrs, msg[, mail_options, rcpt_options])

View File

@ -562,7 +562,7 @@ correspond to Unix system calls applicable to sockets.
:platform: Windows
The `meth:ioctl` method is a limited interface to the WSAIoctl system
The :meth:`ioctl` method is a limited interface to the WSAIoctl system
interface. Please refer to the MSDN documentation for more information.

View File

@ -11,12 +11,13 @@ import sys
if __name__ == '__main__':
if not (2, 5, 1) <= sys.version_info[:3] < (3, 0, 0):
sys.stderr.write("""\
Error: Sphinx needs to be executed with Python 2.5.1 or newer (not 3.0 though).
If you run this from the Makefile, you can set the PYTHON variable to the path
of an alternative interpreter executable, e.g., ``make html PYTHON=python2.5``.)
""")
if sys.version_info[:3] < (2, 4, 0):
print("""\
Error: Sphinx needs to be executed with Python 2.4 or newer (not 3.0 though).
(If you run this from the Makefile, you can set the PYTHON variable
to the path of an alternative interpreter executable, e.g.,
``make html PYTHON=python2.5``).
""", file=sys.stderr)
sys.exit(1)
from sphinx import main

View File

@ -0,0 +1,53 @@
{% extends "layout.html" %}
{% set title = 'Download' %}
{% block body %}
<h1>Download Python {{ release }} Documentation
{%- if last_updated %} (last updated on {{ last_updated }}){% endif %}</h1>
<p>To download an archive containing all the documents for this version of
Python in one of various formats, follow one of links in this table. The numbers
in the table are the size of the download files in Kilobytes.</p>
{# XXX download links #}
<p>These archives contain all the content in the documentation section.</p>
<h2>Unpacking</h2>
<p>Unix users should download the .tar.bz2 archives; these are bzipped tar
archives and can be handled in the usual way using tar and the bzip2
program. The <a href="http://www.info-zip.org">InfoZIP</a> unzip program can be
used to handle the ZIP archives if desired. The .tar.bz2 archives provide the
best compression and fastest download times.</p>
<p>Windows users can use the ZIP archives since those are customary on that
platform. These are created on Unix using the InfoZIP zip program. They may be
unpacked using the free WiZ tool (from the InfoZIP developers) or any other
tool for handling ZIP archives; any of them should work.</p>
<p>Note that the .tar.bz2 files are smaller than the other archives; Windows
users may want to install the bzip2 tools on their systems as well. Windows
binaries for a command-line tool are available at <a
href="http://www.bzip.org">The bzip2 and libbzip2 official home page</a>, but
most other archiving utilities support the tar and bzip2 formats as well.</p>
<h2>Problems</h2>
<p><strong>Printing PDFs using Adobe Acrobat Reader 5.0:</strong> Adobe has
reportedly admitted that there is a bug in Acrobat Reader 5.0 which causes it
not to print at least some PDF files generated by pdfTeX. This software is used
to produce the PDF version of the Python documentation, and our documents
definately trigger this bug in Acrobat Reader. To print the PDF files, use
Acrobat Reader 4.x, ghostscript, or xpdf.</p>
<p>Reportedly, Acrobat Reader 6.0 can print these documents without this
problem, but we've not yet had an opportunity to confirm the report. Sadly,
version 6.0 is not yet available on Unix platforms.</p>
<p>If you have comments or suggestions for the Python documentation, please send
email to <a href="docs@python.org">docs@python.org</a>.</p>
{% endblock %}

View File

@ -0,0 +1,56 @@
<p><strong>Parts of the documentation:</strong></p>
<table class="contentstable" align="center"><tr>
<td width="50%">
<p class="biglink"><a class="biglink" href="{{ pathto("whatsnew/" + version) }}">What's new in Python {{ version }}?</a><br>
<span class="linkdescr">changes since previous major release</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("tutorial/index") }}">Tutorial</a><br>
<span class="linkdescr">start here</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("using/index") }}">Using Python</a><br>
<span class="linkdescr">how to use Python on different platforms</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("reference/index") }}">Language Reference</a><br>
<span class="linkdescr">describes syntax and language elements</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("library/index") }}">Library Reference</a><br>
<span class="linkdescr">keep this under your pillow</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("howto/index") }}">Python HOWTOs</a><br>
<span class="linkdescr">in-depth documents on specific topics</span></p>
</td><td width="50%">
<p class="biglink"><a class="biglink" href="{{ pathto("extending/index") }}">Extending and Embedding</a><br>
<span class="linkdescr">tutorial for C/C++ programmers</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("c-api/index") }}">Python/C API</a><br>
<span class="linkdescr">reference for C/C++ programmers</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("install/index") }}">Installing Python Modules</a><br>
<span class="linkdescr">information for installers &amp; sys-admins</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("distutils/index") }}">Distributing Python Modules</a><br>
<span class="linkdescr">sharing modules with others</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("documenting/index") }}">Documenting Python</a><br>
<span class="linkdescr">guide for documentation authors</span></p>
</td></tr>
</table>
<p><strong>Indices and tables:</strong></p>
<table class="contentstable" align="center"><tr>
<td width="50%">
<p class="biglink"><a class="biglink" href="{{ pathto("modindex") }}">Global Module Index</a><br>
<span class="linkdescr">quick access to all modules</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("genindex") }}">General Index</a><br>
<span class="linkdescr">all functions, classes, terms</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("glossary") }}">Glossary</a><br>
<span class="linkdescr">the most important terms explained</span></p>
</td><td width="50%">
<p class="biglink"><a class="biglink" href="{{ pathto("search") }}">Search page</a><br>
<span class="linkdescr">search this documentation</span></p>
<p class="biglink"><a class="biglink" href="{{ pathto("contents") }}">Complete Table of Contents</a><br>
<span class="linkdescr">lists all sections and subsections</span></p>
</td></tr>
</table>
<p><strong>Meta information:</strong></p>
<table class="contentstable" align="center"><tr>
<td width="50%">
<p class="biglink"><a class="biglink" href="{{ pathto("bugs") }}">Reporting bugs</a></p>
<p class="biglink"><a class="biglink" href="{{ pathto("about") }}">About the documentation</a></p>
</td><td width="50%">
<p class="biglink"><a class="biglink" href="{{ pathto("license") }}">History and License of Python</a></p>
<p class="biglink"><a class="biglink" href="{{ pathto("copyright") }}">Copyright</a></p>
</td></tr>
</table>

View File

@ -0,0 +1,19 @@
<h3>Download</h3>
<p><a href="{{ pathto('download') }}">Download these documents</a></p>
<h3>Other resources</h3>
<ul>
{# XXX: many of these should probably be merged in the main docs #}
<li><a href="http://www.python.org/doc/faq/">FAQs</a></li>
<li><a href="http://www.python.org/doc/intros/">Introductions</a></li>
<li><a href="http://www.python.org/doc/essays/">Guido's Essays</a></li>
<li><a href="http://www.python.org/doc/newstyle/">New-style Classes</a></li>
<li><a href="http://www.python.org/dev/peps/">PEP Index</a></li>
<li><a href="http://wiki.python.org/moin/BeginnersGuide">Beginner's Guide</a></li>
<li><a href="http://www.python.org/topics/">Topic Guides</a></li>
<li><a href="http://wiki.python.org/moin/PythonBooks">Book List</a></li>
<li><a href="http://www.python.org/doc/av/">Audio/Visual Talks</a></li>
<li><a href="http://www.python.org/doc/other/">Other Doc Collections</a></li>
<li>&nbsp;</li>
<li><a href="http://www.python.org/doc/versions/">Previous versions</a></li>
<li>&nbsp;</li>
</ul>

View File

@ -541,6 +541,90 @@ an abstract method.
Implemented by XXX.
Backported to 2.6 by Benjamin Aranguren, with Alex Martelli.
.. ======================================================================
.. _pep-3141:
PEP 3141: A Type Hierarchy for Numbers
=====================================================
In Python 3.0, several abstract base classes for numeric types,
inspired by Scheme's numeric tower, are being added.
This change was backported to 2.6 as the :mod:`numbers` module.
The most general ABC is :class:`Number`. It defines no operations at
all, and only exists to allow checking if an object is a number by
doing ``isinstance(obj, Number)``.
Numbers are further divided into :class:`Exact` and :class:`Inexact`.
Exact numbers can represent values precisely and operations never
round off the results or introduce tiny errors that may break the
communtativity and associativity properties; inexact numbers may
perform such rounding or introduce small errors. Integers, long
integers, and rational numbers are exact, while floating-point
and complex numbers are inexact.
:class:`Complex` is a subclass of :class:`Number`. Complex numbers
can undergo the basic operations of addition, subtraction,
multiplication, division, and exponentiation, and you can retrieve the
real and imaginary parts and obtain a number's conjugate. Python's built-in
complex type is an implementation of :class:`Complex`.
:class:`Real` further derives from :class:`Complex`, and adds
operations that only work on real numbers: :func:`floor`, :func:`trunc`,
rounding, taking the remainder mod N, floor division,
and comparisons.
:class:`Rational` numbers derive from :class:`Real`, have
:attr:`numerator` and :attr:`denominator` properties, and can be
converted to floats. Python 2.6 adds a simple rational-number class
in the :mod:`rational` module.
:class:`Integral` numbers derive from :class:`Rational`, and
can be shifted left and right with ``<<`` and ``>>``,
combined using bitwise operations such as ``&`` and ``|``,
and can be used as array indexes and slice boundaries.
In Python 3.0, the PEP slightly redefines the existing built-ins
:func:`math.floor`, :func:`math.ceil`, :func:`round`, and adds a new
one, :func:`trunc`, that's been backported to Python 2.6.
:func:`trunc` rounds toward zero, returning the closest
:class:`Integral` that's between the function's argument and zero.
.. seealso::
XXX link: Discusses Scheme's numeric tower.
The Rational Module
--------------------------------------------------
To fill out the hierarchy of numeric types, a rational-number class
has been added as the :mod:`rational` module. Rational numbers are
represented as a fraction; rational numbers can exactly represent
numbers such as two-thirds that floating-point numbers can only
approximate.
The :class:`Rational` constructor takes two :class:`Integral` values
that will be the numerator and denominator of the resulting fraction. ::
>>> from rational import Rational
>>> a = Rational(2, 3)
>>> b = Rational(2, 5)
>>> float(a), float(b)
(0.66666666666666663, 0.40000000000000002)
>>> a+b
rational.Rational(16,15)
>>> a/b
rational.Rational(5,3)
The :mod:`rational` module is based upon an implementation by Sjoerd
Mullender that was in Python's :file:`Demo/classes/` directory for a
long time. This implementation was significantly updated by Jeffrey
Yaskin.
Other Language Changes
======================
@ -568,10 +652,10 @@ Here are all of the changes that Python 2.6 makes to the core Python language.
.. Revision 57619
* Properties now have two attributes,
* Properties now have three attributes, :attr:`getter`,
:attr:`setter` and :attr:`deleter`, that are useful shortcuts for
adding a setter or deleter function to an existing property.
You would use them like this::
adding or modifying a getter, setter or deleter function to an
existing property. You would use them like this::
class C(object):
@property
@ -586,6 +670,15 @@ Here are all of the changes that Python 2.6 makes to the core Python language.
def x(self):
del self._x
class D(C):
@C.x.getter
def x(self):
return self._x * 2
@x.setter
def x(self, value):
self._x = value / 2
* C functions and methods that use
:cfunc:`PyComplex_AsCComplex` will now accept arguments that
@ -997,6 +1090,12 @@ complete list of changes, or look through the CVS logs for all the details.
.. Patch #957003
* In the :mod:`smtplib` module, SMTP.starttls() now complies with :rfc:`3207`
and forgets any knowledge obtained from the server not obtained from
the TLS negotiation itself. Patch contributed by Bill Fenner.
.. Issue 829951
* The :mod:`socket` module now supports TIPC (http://tipc.sf.net),
a high-performance non-IP-based protocol designed for use in clustered
environments. TIPC addresses are 4- or 5-tuples.
@ -1246,13 +1345,30 @@ Port-Specific Changes: Windows
API. The :func:`getwch` function reads a keypress and returns a Unicode
value, as does the :func:`getwche` function. The :func:`putwch` function
takes a Unicode character and writes it to the console.
(Contributed by Christian Heimes.)
* :func:`os.path.expandvars` will now expand environment variables
in the form "%var%", and "~user" will be expanded into the
user's home directory path. (Contributed by Josiah Carlson.)
* The :mod:`socket` module's socket objects now have an
:meth:`ioctl` method that provides a limited interface to the
:cfunc:`WSAIoctl` system interface.
* The :mod:`_winreg` module now has a function,
:func:`ExpandEnvironmentStrings`,
that expands environment variable references such as ``%NAME%``
in an input string. The handle objects provided by this
module now support the context protocol, so they can be used
in :keyword:`with` statements.
in :keyword:`with` statements. (Contributed by Christian Heimes.)
* The new default compiler on Windows is Visual Studio 2008 (VS 9.0). The
build directories for Visual Studio 2003 (VS7.1) and 2005 (VS8.0)
were moved into the PC/ directory. The new PCbuild directory supports
cross compilation for X64, debug builds and Profile Guided Optimization
(PGO). PGO builds are roughly 10% faster than normal builds.
(Contributed by Christian Heimes with help from Amaury Forgeot d'Arc and
Martin von Loewis.)
.. ======================================================================

View File

@ -2982,7 +2982,7 @@ class Decimal(_numbers.Real, _numbers.Inexact):
def _islogical(self):
"""Return True if self is a logical operand.
For being logical, it must be a finite numbers with a sign of 0,
For being logical, it must be a finite number with a sign of 0,
an exponent of 0, and a coefficient whose digits must all be
either 0 or 1.
"""
@ -4098,7 +4098,7 @@ class Context(object):
"""max compares two values numerically and returns the maximum.
If either operand is a NaN then the general rules apply.
Otherwise, the operands are compared as as though by the compare
Otherwise, the operands are compared as though by the compare
operation. If they are numerically equal then the left-hand operand
is chosen as the result. Otherwise the maximum (closer to positive
infinity) of the two operands is chosen as the result.
@ -4122,7 +4122,7 @@ class Context(object):
"""min compares two values numerically and returns the minimum.
If either operand is a NaN then the general rules apply.
Otherwise, the operands are compared as as though by the compare
Otherwise, the operands are compared as though by the compare
operation. If they are numerically equal then the left-hand operand
is chosen as the result. Otherwise the minimum (closer to negative
infinity) of the two operands is chosen as the result.

View File

@ -198,6 +198,8 @@ class Pdb(bdb.Bdb, cmd.Cmd):
globals = self.curframe.f_globals
try:
code = compile(line + '\n', '<stdin>', 'single')
save_stdout = sys.stdout
save_stdin = sys.stdin
try:
sys.stdin = self.stdin
sys.stdout = self.stdout

View File

@ -29,14 +29,17 @@ has another way to reference private data (besides global variables).
# XXX the global state of your particular time and delay functions.
import heapq
from collections import namedtuple
__all__ = ["scheduler"]
Event = namedtuple('Event', 'time, priority, action, argument')
class scheduler:
def __init__(self, timefunc, delayfunc):
"""Initialize a new instance, passing the time and delay
functions"""
self.queue = []
self._queue = []
self.timefunc = timefunc
self.delayfunc = delayfunc
@ -47,8 +50,8 @@ class scheduler:
if necessary.
"""
event = time, priority, action, argument
heapq.heappush(self.queue, event)
event = Event(time, priority, action, argument)
heapq.heappush(self._queue, event)
return event # The ID
def enter(self, delay, priority, action, argument):
@ -67,12 +70,12 @@ class scheduler:
If the event is not in the queue, this raises RuntimeError.
"""
self.queue.remove(event)
heapq.heapify(self.queue)
self._queue.remove(event)
heapq.heapify(self._queue)
def empty(self):
"""Check whether the queue is empty."""
return not self.queue
return not self._queue
def run(self):
"""Execute events until the queue is empty.
@ -97,7 +100,7 @@ class scheduler:
"""
# localize variable access to minimize overhead
# and to improve thread safety
q = self.queue
q = self._queue
delayfunc = self.delayfunc
timefunc = self.timefunc
pop = heapq.heappop
@ -115,3 +118,17 @@ class scheduler:
delayfunc(0) # Let other threads run
else:
heapq.heappush(event)
@property
def queue(self):
"""An ordered list of upcoming events.
Events are named tuples with fields for:
time, priority, action, arguments
"""
# Use heapq to sort the queue rather than using 'sorted(self._queue)'.
# With heapq, two events scheduled at the same time will show in
# the actual order they would be retrieved.
events = self._queue[:]
return map(heapq.heappop, [events]*len(events))

View File

@ -495,6 +495,23 @@ class SMTP:
# some useful methods
def ehlo_or_helo_if_needed(self):
"""Call self.ehlo() and/or self.helo() if needed.
If there has been no previous EHLO or HELO command this session, this
method tries ESMTP EHLO first.
This method may raise the following exceptions:
SMTPHeloError The server didn't reply properly to
the helo greeting.
"""
if self.helo_resp is None and self.ehlo_resp is None:
if not (200 <= self.ehlo()[0] <= 299):
(code, resp) = self.helo()
if not (200 <= code <= 299):
raise SMTPHeloError(code, resp)
def login(self, user, password):
"""Log in on an SMTP server that requires authentication.
@ -530,11 +547,7 @@ class SMTP:
AUTH_CRAM_MD5 = "CRAM-MD5"
AUTH_LOGIN = "LOGIN"
if self.helo_resp is None and self.ehlo_resp is None:
if not (200 <= self.ehlo()[0] <= 299):
(code, resp) = self.helo()
if not (200 <= code <= 299):
raise SMTPHeloError(code, resp)
self.ehlo_or_helo_if_needed()
if not self.has_extn("auth"):
raise SMTPException("SMTP AUTH extension not supported by server.")
@ -580,18 +593,37 @@ class SMTP:
def starttls(self, keyfile = None, certfile = None):
"""Puts the connection to the SMTP server into TLS mode.
If there has been no previous EHLO or HELO command this session, this
method tries ESMTP EHLO first.
If the server supports TLS, this will encrypt the rest of the SMTP
session. If you provide the keyfile and certfile parameters,
the identity of the SMTP server and client can be checked. This,
however, depends on whether the socket module really checks the
certificates.
This method may raise the following exceptions:
SMTPHeloError The server didn't reply properly to
the helo greeting.
"""
self.ehlo_or_helo_if_needed()
if not self.has_extn("starttls"):
raise SMTPException("STARTTLS extension not supported by server.")
(resp, reply) = self.docmd("STARTTLS")
if resp == 220:
if not _have_ssl:
raise RuntimeError("No SSL support included in this Python")
self.sock = ssl.wrap_socket(self.sock, keyfile, certfile)
self.file = SSLFakeFile(self.sock)
# RFC 3207:
# The client MUST discard any knowledge obtained from
# the server, such as the list of SMTP service extensions,
# which was not obtained from the TLS negotiation itself.
self.helo_resp = None
self.ehlo_resp = None
self.esmtp_features = {}
self.does_esmtp = 0
return (resp, reply)
def sendmail(self, from_addr, to_addrs, msg, mail_options=[],
@ -651,11 +683,7 @@ class SMTP:
empty dictionary.
"""
if self.helo_resp is None and self.ehlo_resp is None:
if not (200 <= self.ehlo()[0] <= 299):
(code,resp) = self.helo()
if not (200 <= code <= 299):
raise SMTPHeloError(code, resp)
self.ehlo_or_helo_if_needed()
esmtp_opts = []
if self.does_esmtp:
# Hmmm? what's this? -ddm

View File

@ -300,7 +300,8 @@ class TestBasicOps(unittest.TestCase):
self.assertEqual(take(3, starmap(operator.pow, izip(count(), count(1)))),
[0**1, 1**2, 2**3])
self.assertEqual(list(starmap(operator.pow, [])), [])
self.assertRaises(TypeError, list, starmap(operator.pow, [[4,5]]))
self.assertEqual(list(starmap(operator.pow, [iter([4,5])])), [4**5])
self.assertRaises(TypeError, list, starmap(operator.pow, [None]))
self.assertRaises(TypeError, starmap)
self.assertRaises(TypeError, starmap, operator.pow, [(4,5)], 'extra')
self.assertRaises(TypeError, next, starmap(10, [(4,5)]))

View File

@ -184,28 +184,35 @@ def SimpleQueueTest(q):
raise RuntimeError("Call this function with an empty queue")
# I guess we better check things actually queue correctly a little :)
q.put(111)
q.put(333)
q.put(222)
verify(q.get() == 111 and q.get() == 222,
target_order = dict(Queue = [111, 333, 222],
LifoQueue = [222, 333, 111],
PriorityQueue = [111, 222, 333])
actual_order = [q.get(), q.get(), q.get()]
verify(actual_order == target_order[q.__class__.__name__],
"Didn't seem to queue the correct data!")
for i in range(QUEUE_SIZE-1):
q.put(i)
verify(q.qsize(), "Queue should not be empty")
verify(not qfull(q), "Queue should not be full")
q.put("last")
last = 2*QUEUE_SIZE
full = 3*2*QUEUE_SIZE
q.put(last)
verify(qfull(q), "Queue should be full")
try:
q.put("full", block=0)
q.put(full, block=0)
raise TestFailed("Didn't appear to block with a full queue")
except Queue.Full:
pass
try:
q.put("full", timeout=0.01)
q.put(full, timeout=0.01)
raise TestFailed("Didn't appear to time-out with a full queue")
except Queue.Full:
pass
# Test a blocking put
_doBlockingTest(q.put, ("full",), q.get, ())
_doBlockingTest(q.put, ("full", True, 10), q.get, ())
_doBlockingTest(q.put, (full,), q.get, ())
_doBlockingTest(q.put, (full, True, 10), q.get, ())
# Empty it
for i in range(QUEUE_SIZE):
q.get()
@ -250,8 +257,7 @@ def QueueJoinTest(q):
q.put(i)
q.join()
verify(cum==sum(range(100)), "q.join() did not block until all tasks were done")
for i in (0,1):
q.put(None) # instruct the threads to close
q.put(None) # instruct the threads to close
q.join() # verify that you can join twice
def QueueTaskDoneTest(q):
@ -263,18 +269,20 @@ def QueueTaskDoneTest(q):
raise TestFailed("Did not detect task count going negative")
def test():
q = Queue.Queue()
QueueTaskDoneTest(q)
QueueJoinTest(q)
QueueJoinTest(q)
QueueTaskDoneTest(q)
for Q in Queue.Queue, Queue.LifoQueue, Queue.PriorityQueue:
q = Q()
QueueTaskDoneTest(q)
QueueJoinTest(q)
QueueJoinTest(q)
QueueTaskDoneTest(q)
q = Q(QUEUE_SIZE)
# Do it a couple of times on the same queue
SimpleQueueTest(q)
SimpleQueueTest(q)
if verbose:
print("Simple Queue tests seemed to work for", Q.__name__)
q = Queue.Queue(QUEUE_SIZE)
# Do it a couple of times on the same queue
SimpleQueueTest(q)
SimpleQueueTest(q)
if verbose:
print("Simple Queue tests seemed to work")
q = FailingQueue(QUEUE_SIZE)
FailingQueueTest(q)
FailingQueueTest(q)

View File

@ -217,7 +217,7 @@ extern void ffi_call_STDCALL(void (*)(char *, extended_cif *),
#endif /* X86_WIN32 */
void ffi_call(/*@dependent@*/ ffi_cif *cif,
void (*fn)(),
void (*fn)(void),
/*@out@*/ void *rvalue,
/*@dependent@*/ void **avalue)
{

View File

@ -348,7 +348,17 @@ element_resize(ElementObject* self, int extra)
if (size > self->extra->allocated) {
/* use Python 2.4's list growth strategy */
size = (size >> 3) + (size < 9 ? 3 : 6) + size;
/* Coverity CID #182 size_error: Allocating 1 bytes to pointer "children"
* which needs at least 4 bytes.
* Although it's a false alarm always assume at least one child to
* be safe.
*/
size = size ? size : 1;
if (self->extra->children != self->extra->_children) {
/* Coverity CID #182 size_error: Allocating 1 bytes to pointer
* "children", which needs at least 4 bytes. Although it's a
* false alarm always assume at least one child to be safe.
*/
children = PyObject_Realloc(self->extra->children,
size * sizeof(PyObject*));
if (!children)

View File

@ -1918,8 +1918,7 @@ PyDoc_STRVAR(clearcache_doc,
static PyObject *
clearcache(PyObject *self)
{
if (cache != NULL)
PyDict_Clear(cache);
Py_CLEAR(cache);
Py_RETURN_NONE;
}

View File

@ -1356,10 +1356,11 @@ starmap_next(starmapobject *lz)
if (args == NULL)
return NULL;
if (!PyTuple_CheckExact(args)) {
PyObject *newargs = PySequence_Tuple(args);
Py_DECREF(args);
PyErr_SetString(PyExc_TypeError,
"iterator must return a tuple");
return NULL;
if (newargs == NULL)
return NULL;
args = newargs;
}
result = PyObject_Call(lz->func, args, NULL);
Py_DECREF(args);

View File

@ -533,6 +533,7 @@ Py_Main(int argc, char **argv)
if (fstat(fileno(fp), &sb) == 0 &&
S_ISDIR(sb.st_mode)) {
fprintf(stderr, "%s: '%s' is a directory, cannot continue\n", argv[0], filename);
fclose(fp);
return 1;
}
}

View File

@ -1000,6 +1000,8 @@ parse_dostime(int dostime, int dosdate)
{
struct tm stm;
memset((void *) &stm, '\0', sizeof(stm));
stm.tm_sec = (dostime & 0x1f) * 2;
stm.tm_min = (dostime >> 5) & 0x3f;
stm.tm_hour = (dostime >> 11) & 0x1f;

View File

@ -667,6 +667,7 @@ pgen(node *n)
g = maketables(gr);
translatelabels(g);
addfirstsets(g);
PyObject_FREE(gr);
return g;
}

View File

@ -135,6 +135,8 @@ tb_displayline(PyObject *f, char *filename, int lineno, char *name)
FILE *xfp;
char linebuf[2000];
int i;
char namebuf[MAXPATHLEN+1];
if (filename == NULL || name == NULL)
return -1;
/* This is needed by Emacs' compile command */
@ -153,7 +155,6 @@ tb_displayline(PyObject *f, char *filename, int lineno, char *name)
Py_ssize_t _npath = PyList_Size(path);
int npath = Py_SAFE_DOWNCAST(_npath, Py_ssize_t, int);
size_t taillen = strlen(tail);
char namebuf[MAXPATHLEN+1];
for (i = 0; i < npath; i++) {
PyObject *v = PyList_GetItem(path, i);
if (v == NULL) {

View File

@ -101,8 +101,14 @@ class PyBuildExt(build_ext):
missing = self.detect_modules()
# Remove modules that are present on the disabled list
self.extensions = [ext for ext in self.extensions
if ext.name not in disabled_module_list]
extensions = [ext for ext in self.extensions
if ext.name not in disabled_module_list]
# move ctypes to the end, it depends on other modules
ext_map = dict((ext.name, i) for i, ext in enumerate(extensions))
if "_ctypes" in ext_map:
ctypes = extensions.pop(ext_map["_ctypes"])
extensions.append(ctypes)
self.extensions = extensions
# Fix up the autodetected modules, prefixing all the source files
# with Modules/ and adding Python's include directory to the path.