Merged revisions 46753-51188 via svnmerge from

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

........
  r46755 | brett.cannon | 2006-06-08 18:23:04 +0200 (Thu, 08 Jun 2006) | 4 lines

  Make binascii.hexlify() use s# for its arguments instead of t# to actually
  match its documentation stating it accepts any read-only buffer.
........
  r46757 | brett.cannon | 2006-06-08 19:00:45 +0200 (Thu, 08 Jun 2006) | 8 lines

  Buffer objects would return the read or write buffer for a wrapped object when
  the char buffer was requested.  Now it actually returns the char buffer if
  available or raises a TypeError if it isn't (as is raised for the other buffer
  types if they are not present but requested).

  Not a backport candidate since it does change semantics of the buffer object
  (although it could be argued this is enough of a bug to bother backporting).
........
  r46760 | andrew.kuchling | 2006-06-09 03:10:17 +0200 (Fri, 09 Jun 2006) | 1 line

  Update functools section
........
  r46762 | tim.peters | 2006-06-09 04:11:02 +0200 (Fri, 09 Jun 2006) | 6 lines

  Whitespace normalization.

  Since test_file is implicated in mysterious test failures
  when followed by test_optparse, if I had any brains I'd
  look at the checkin that last changed test_file ;-)
........
  r46763 | tim.peters | 2006-06-09 05:09:42 +0200 (Fri, 09 Jun 2006) | 5 lines

  To boost morale :-), force test_optparse to run immediately
  after test_file until we can figure out how to fix it.
  (See python-dev; at the moment we don't even know which checkin
  caused the problem.)
........
  r46764 | tim.peters | 2006-06-09 05:51:41 +0200 (Fri, 09 Jun 2006) | 6 lines

  AutoFileTests.tearDown():  Removed mysterious undocumented
  try/except.  Remove TESTFN.

  Throughout:  used open() instead of file(), and wrapped
  long lines.
........
  r46765 | tim.peters | 2006-06-09 06:02:06 +0200 (Fri, 09 Jun 2006) | 8 lines

  testUnicodeOpen():  I have no idea why, but making this
  test clean up after itself appears to fix the test failures
  when test_optparse follows test_file.

  test_main():  Get rid of TESTFN no matter what.  That's
  also enough to fix the mystery failures.  Doesn't hurt
  to fix them twice :-)
........
  r46766 | tim.peters | 2006-06-09 07:12:40 +0200 (Fri, 09 Jun 2006) | 6 lines

  Remove the temporary hack to force test_optparse to
  run immediately after test_file.  At least 8 buildbot
  boxes passed since the underlying problem got fixed,
  and they all failed before the fix, so there's no point
  to this anymore.
........
  r46767 | neal.norwitz | 2006-06-09 07:54:18 +0200 (Fri, 09 Jun 2006) | 1 line

  Fix grammar and reflow
........
  r46769 | andrew.kuchling | 2006-06-09 12:22:35 +0200 (Fri, 09 Jun 2006) | 1 line

  Markup fix
........
  r46773 | andrew.kuchling | 2006-06-09 15:15:57 +0200 (Fri, 09 Jun 2006) | 1 line

  [Bug #1472827] Make saxutils.XMLGenerator handle \r\n\t in attribute values by escaping them properly.   2.4 bugfix candidate.
........
  r46778 | kristjan.jonsson | 2006-06-09 18:28:01 +0200 (Fri, 09 Jun 2006) | 2 lines

  Turn off warning about deprecated CRT functions on for VisualStudio .NET 2005.
  Make the definition #ARRAYSIZE conditional.  VisualStudio .NET 2005 already has it defined using a better gimmick.
........
  r46779 | phillip.eby | 2006-06-09 18:40:18 +0200 (Fri, 09 Jun 2006) | 2 lines

  Import wsgiref into the stdlib, as of the external version 0.1-r2181.
........
  r46783 | andrew.kuchling | 2006-06-09 18:44:40 +0200 (Fri, 09 Jun 2006) | 1 line

  Add note about XMLGenerator bugfix
........
  r46784 | andrew.kuchling | 2006-06-09 18:46:51 +0200 (Fri, 09 Jun 2006) | 1 line

  Add note about wsgiref
........
  r46785 | brett.cannon | 2006-06-09 19:05:48 +0200 (Fri, 09 Jun 2006) | 2 lines

  Fix inconsistency in naming within an enum.
........
  r46787 | tim.peters | 2006-06-09 19:47:00 +0200 (Fri, 09 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46792 | georg.brandl | 2006-06-09 20:29:52 +0200 (Fri, 09 Jun 2006) | 3 lines

  Test file.__exit__.
........
  r46794 | brett.cannon | 2006-06-09 20:40:46 +0200 (Fri, 09 Jun 2006) | 2 lines

  svn:ignore .pyc and .pyo files.
........
  r46795 | georg.brandl | 2006-06-09 20:45:48 +0200 (Fri, 09 Jun 2006) | 3 lines

  RFE #1491485: str/unicode.endswith()/startswith() now accept a tuple as first argument.
........
  r46798 | andrew.kuchling | 2006-06-09 21:03:16 +0200 (Fri, 09 Jun 2006) | 1 line

  Describe startswith()/endswiith() change; add reminder about wsgiref
........
  r46799 | tim.peters | 2006-06-09 21:24:44 +0200 (Fri, 09 Jun 2006) | 11 lines

  Implementing a happy idea from Georg Brandl:  make runtest() try to
  clean up files and directories the tests often leave behind by
  mistake.  This is the first time in history I don't have a bogus
  "db_home" directory after running the tests ;-)

  Also worked on runtest's docstring, to say something about all the
  arguments, and to document the non-obvious return values.

  New functions runtest_inner() and cleanup_test_droppings() in
  support of the above.
........
  r46800 | andrew.kuchling | 2006-06-09 21:43:25 +0200 (Fri, 09 Jun 2006) | 1 line

  Remove unused variable
........
  r46801 | andrew.kuchling | 2006-06-09 21:56:05 +0200 (Fri, 09 Jun 2006) | 1 line

  Add some wsgiref text
........
  r46803 | thomas.heller | 2006-06-09 21:59:11 +0200 (Fri, 09 Jun 2006) | 1 line

  set eol-style svn property
........
  r46804 | thomas.heller | 2006-06-09 22:01:01 +0200 (Fri, 09 Jun 2006) | 1 line

  set eol-style svn property
........
  r46805 | georg.brandl | 2006-06-09 22:43:48 +0200 (Fri, 09 Jun 2006) | 3 lines

  Make use of new str.startswith/endswith semantics.
  Occurences in email and compiler were ignored due to backwards compat requirements.
........
  r46806 | brett.cannon | 2006-06-10 00:31:23 +0200 (Sat, 10 Jun 2006) | 4 lines

  An object with __call__ as an attribute, when called, will have that attribute checked for __call__ itself, and will continue to look until it finds an object without the attribute.  This can lead to an infinite recursion.

  Closes bug #532646, again.  Will be backported.
........
  r46808 | brett.cannon | 2006-06-10 00:45:54 +0200 (Sat, 10 Jun 2006) | 2 lines

  Fix bug introduced in rev. 46806 by not having variable declaration at the top of a block.
........
  r46812 | georg.brandl | 2006-06-10 08:40:50 +0200 (Sat, 10 Jun 2006) | 4 lines

  Apply perky's fix for #1503157: "/".join([u"", u""]) raising OverflowError.
  Also improve error message on overflow.
........
  r46817 | martin.v.loewis | 2006-06-10 10:14:03 +0200 (Sat, 10 Jun 2006) | 2 lines

  Port cygwin kill_python changes from 2.4 branch.
........
  r46818 | armin.rigo | 2006-06-10 12:57:40 +0200 (Sat, 10 Jun 2006) | 4 lines

  SF bug #1503294.

  PyThreadState_GET() complains if the tstate is NULL, but only in debug mode.
........
  r46819 | martin.v.loewis | 2006-06-10 14:23:46 +0200 (Sat, 10 Jun 2006) | 4 lines

  Patch #1495999: Part two of Windows CE changes.
  - update header checks, using autoconf
  - provide dummies for getenv, environ, and GetVersion
  - adjust MSC_VER check in socketmodule.c
........
  r46820 | skip.montanaro | 2006-06-10 16:09:11 +0200 (Sat, 10 Jun 2006) | 1 line

  document the class, not its initializer
........
  r46821 | greg.ward | 2006-06-10 18:40:01 +0200 (Sat, 10 Jun 2006) | 4 lines

  Sync with Optik docs (rev 518):
    * restore "Extending optparse" section
    * document ALWAYS_TYPED_ACTIONS (SF #1449311)
........
  r46824 | thomas.heller | 2006-06-10 21:51:46 +0200 (Sat, 10 Jun 2006) | 8 lines

  Upgrade to ctypes version 0.9.9.7.

  Summary of changes:

  - support for 'variable sized' data
  - support for anonymous structure/union fields
  - fix severe bug with certain arrays or structures containing more than 256 fields
........
  r46825 | thomas.heller | 2006-06-10 21:55:36 +0200 (Sat, 10 Jun 2006) | 8 lines

  Upgrade to ctypes version 0.9.9.7.

  Summary of changes:

  - support for 'variable sized' data
  - support for anonymous structure/union fields
  - fix severe bug with certain arrays or structures containing more than 256 fields
........
  r46826 | fred.drake | 2006-06-10 22:01:34 +0200 (Sat, 10 Jun 2006) | 4 lines

  SF patch #1303595: improve description of __builtins__, explaining how it
  varies between __main__ and other modules, and strongly suggest not touching
  it but using __builtin__ if absolutely necessary
........
  r46827 | fred.drake | 2006-06-10 22:02:58 +0200 (Sat, 10 Jun 2006) | 1 line

  credit for SF patch #1303595
........
  r46831 | thomas.heller | 2006-06-10 22:29:34 +0200 (Sat, 10 Jun 2006) | 2 lines

  New docs for ctypes.
........
  r46834 | thomas.heller | 2006-06-10 23:07:19 +0200 (Sat, 10 Jun 2006) | 1 line

  Fix a wrong printf format.
........
  r46835 | thomas.heller | 2006-06-10 23:17:58 +0200 (Sat, 10 Jun 2006) | 1 line

  Fix the second occurrence of the problematic printf format.
........
  r46837 | thomas.heller | 2006-06-10 23:56:03 +0200 (Sat, 10 Jun 2006) | 1 line

  Don't use C++ comment.
........
  r46838 | thomas.heller | 2006-06-11 00:01:50 +0200 (Sun, 11 Jun 2006) | 1 line

  Handle failure of PyMem_Realloc.
........
  r46839 | skip.montanaro | 2006-06-11 00:38:13 +0200 (Sun, 11 Jun 2006) | 2 lines

  Suppress warning on MacOSX about possible use before set of proc.
........
  r46840 | tim.peters | 2006-06-11 00:51:45 +0200 (Sun, 11 Jun 2006) | 8 lines

  shuffle() doscstring:  Removed warning about sequence length
  versus generator period.  While this was a real weakness of the
  older WH generator for lists with just a few dozen elements,
  and so could potentially bite the naive ;-), the Twister should
  show excellent behavior up to at least 600 elements.

  Module docstring:  reflowed some jarringly short lines.
........
  r46844 | greg.ward | 2006-06-11 02:40:49 +0200 (Sun, 11 Jun 2006) | 4 lines

  Bug #1361643: fix textwrap.dedent() so it handles tabs appropriately,
  i.e. do *not* expand tabs, but treat them as whitespace that is not
  equivalent to spaces.  Add a couple of test cases.  Clarify docs.
........
  r46850 | neal.norwitz | 2006-06-11 07:44:18 +0200 (Sun, 11 Jun 2006) | 5 lines

  Fix Coverity # 146.  newDBSequenceObject would deref dbobj, so it can't be NULL.

  We know it's not NULL from the ParseTuple and DbObject_Check will verify
  it's not NULL.
........
  r46851 | neal.norwitz | 2006-06-11 07:45:25 +0200 (Sun, 11 Jun 2006) | 4 lines

  Wrap some long lines
  Top/Bottom factor out some common expressions
  Add a XXX comment about widing offset.
........
  r46852 | neal.norwitz | 2006-06-11 07:45:47 +0200 (Sun, 11 Jun 2006) | 1 line

  Add versionadded to doc
........
  r46853 | neal.norwitz | 2006-06-11 07:47:14 +0200 (Sun, 11 Jun 2006) | 3 lines

  Update doc to make it agree with code.
  Bottom factor out some common code.
........
  r46854 | neal.norwitz | 2006-06-11 07:48:14 +0200 (Sun, 11 Jun 2006) | 3 lines

  f_code can't be NULL based on Frame_New and other code that derefs it.
  So there doesn't seem to be much point to checking here.
........
  r46855 | neal.norwitz | 2006-06-11 09:26:27 +0200 (Sun, 11 Jun 2006) | 1 line

  Fix errors found by pychecker
........
  r46856 | neal.norwitz | 2006-06-11 09:26:50 +0200 (Sun, 11 Jun 2006) | 1 line

  warnings was imported at module scope, no need to import again
........
  r46857 | neal.norwitz | 2006-06-11 09:27:56 +0200 (Sun, 11 Jun 2006) | 5 lines

  Fix errors found by pychecker.
  I think these changes are correct, but I'm not sure.  Could someone
  who knows how this module works test it?  It can at least start on
  the cmd line.
........
  r46858 | neal.norwitz | 2006-06-11 10:35:14 +0200 (Sun, 11 Jun 2006) | 1 line

  Fix errors found by pychecker
........
  r46859 | ronald.oussoren | 2006-06-11 16:33:36 +0200 (Sun, 11 Jun 2006) | 4 lines

  This patch improves the L&F of IDLE on OSX. The changes are conditionalized on
  being in an IDLE.app bundle on darwin. This does a slight reorganisation of the
  menus and adds support for file-open events.
........
  r46860 | greg.ward | 2006-06-11 16:42:41 +0200 (Sun, 11 Jun 2006) | 1 line

  SF #1366250: optparse docs: fix inconsistency in variable name; minor tweaks.
........
  r46861 | greg.ward | 2006-06-11 18:24:11 +0200 (Sun, 11 Jun 2006) | 3 lines

  Bug #1498146: fix optparse to handle Unicode strings in option help,
  description, and epilog.
........
  r46862 | thomas.heller | 2006-06-11 19:04:22 +0200 (Sun, 11 Jun 2006) | 2 lines

  Release the GIL during COM method calls, to avoid deadlocks in
  Python coded COM objects.
........
  r46863 | tim.peters | 2006-06-11 21:42:51 +0200 (Sun, 11 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46864 | tim.peters | 2006-06-11 21:43:49 +0200 (Sun, 11 Jun 2006) | 2 lines

  Add missing svn:eol-style property to text files.
........
  r46865 | ronald.oussoren | 2006-06-11 21:45:57 +0200 (Sun, 11 Jun 2006) | 2 lines

  Remove message about using make frameworkinstall, that's no longer necesssary
........
  r46866 | ronald.oussoren | 2006-06-11 22:23:29 +0200 (Sun, 11 Jun 2006) | 2 lines

  Use configure to substitute the correct prefix instead of hardcoding
........
  r46867 | ronald.oussoren | 2006-06-11 22:24:45 +0200 (Sun, 11 Jun 2006) | 4 lines

  - Change fixapplepython23.py to ensure that it will run with /usr/bin/python
    on intel macs.
  - Fix some minor problems in the installer for OSX
........
  r46868 | neal.norwitz | 2006-06-11 22:25:56 +0200 (Sun, 11 Jun 2006) | 5 lines

  Try to fix several networking tests.  The problem is that if hosts have
  a search path setup, some of these hosts resolve to the wrong address.
  By appending a period to the hostname, the hostname should only resolve
  to what we want it to resolve to.  Hopefully this doesn't break different bots.
........
  r46869 | neal.norwitz | 2006-06-11 22:42:02 +0200 (Sun, 11 Jun 2006) | 7 lines

  Try to fix another networking test.  The problem is that if hosts have
  a search path setup, some of these hosts resolve to the wrong address.
  By appending a period to the hostname, the hostname should only resolve
  to what we want it to resolve to.  Hopefully this doesn't break different bots.

  Also add more info to failure message to aid debugging test failure.
........
  r46870 | neal.norwitz | 2006-06-11 22:46:46 +0200 (Sun, 11 Jun 2006) | 4 lines

  Fix test on PPC64 buildbot.  It raised an IOError (really an URLError which
  derives from an IOError).  That seems valid.  Env Error includes both OSError
  and IOError, so this seems like a reasonable fix.
........
  r46871 | tim.peters | 2006-06-11 22:52:59 +0200 (Sun, 11 Jun 2006) | 10 lines

  compare_generic_iter():  Fixed the failure of test_wsgiref's testFileWrapper
  when running with -O.

  test_simple_validation_error still fails under -O.  That appears to be because
  wsgiref's validate.py uses `assert` statements all over the place to check
  arguments for sanity.  That should all be changed (it's not a logical error
  in the software if a user passes bogus arguments, so this isn't a reasonable
  use for `assert` -- checking external preconditions should generally raise
  ValueError or TypeError instead, as appropriate).
........
  r46872 | neal.norwitz | 2006-06-11 23:38:38 +0200 (Sun, 11 Jun 2006) | 1 line

  Get test to pass on S/390.  Shout if you think this change is incorrect.
........
  r46873 | neal.norwitz | 2006-06-12 04:05:55 +0200 (Mon, 12 Jun 2006) | 1 line

  Cleanup Py_ssize_t a little (get rid of second #ifdef)
........
  r46874 | neal.norwitz | 2006-06-12 04:06:17 +0200 (Mon, 12 Jun 2006) | 1 line

  Fix some Py_ssize_t issues
........
  r46875 | neal.norwitz | 2006-06-12 04:06:42 +0200 (Mon, 12 Jun 2006) | 1 line

  Fix some Py_ssize_t issues
........
  r46876 | neal.norwitz | 2006-06-12 04:07:24 +0200 (Mon, 12 Jun 2006) | 2 lines

  Cleanup: Remove import of types to get StringTypes, we can just use basestring.
........
  r46877 | neal.norwitz | 2006-06-12 04:07:57 +0200 (Mon, 12 Jun 2006) | 1 line

  Don't truncate if size_t is bigger than uint
........
  r46878 | neal.norwitz | 2006-06-12 04:08:41 +0200 (Mon, 12 Jun 2006) | 1 line

  Don't leak the list object if there's an error allocating the item storage.  Backport candidate
........
  r46879 | neal.norwitz | 2006-06-12 04:09:03 +0200 (Mon, 12 Jun 2006) | 1 line

  Fix typo.  Backport if anyone cares. :-)
........
  r46880 | neal.norwitz | 2006-06-12 04:09:34 +0200 (Mon, 12 Jun 2006) | 1 line

  Fix indentation of case and a Py_ssize_t issue.
........
  r46881 | neal.norwitz | 2006-06-12 04:11:18 +0200 (Mon, 12 Jun 2006) | 3 lines

  Get rid of f_restricted too.  Doc the other 4 ints that were already removed
  at the NeedForSpeed sprint.
........
  r46882 | neal.norwitz | 2006-06-12 04:13:21 +0200 (Mon, 12 Jun 2006) | 1 line

  Fix the socket tests so they can be run concurrently.  Backport candidate
........
  r46883 | neal.norwitz | 2006-06-12 04:16:10 +0200 (Mon, 12 Jun 2006) | 1 line

  i and j are initialized below when used.  No need to do it twice
........
  r46884 | neal.norwitz | 2006-06-12 05:05:03 +0200 (Mon, 12 Jun 2006) | 1 line

  Remove unused import
........
  r46885 | neal.norwitz | 2006-06-12 05:05:40 +0200 (Mon, 12 Jun 2006) | 1 line

  Impl ssize_t
........
  r46886 | neal.norwitz | 2006-06-12 05:33:09 +0200 (Mon, 12 Jun 2006) | 6 lines

  Patch #1503046, Conditional compilation of zlib.(de)compressobj.copy

  copy is only in newer versions of zlib.  This should allow zlibmodule
  to work with older versions like the Tru64 buildbot.
........
  r46887 | phillip.eby | 2006-06-12 06:04:32 +0200 (Mon, 12 Jun 2006) | 2 lines

  Sync w/external release 0.1.2.  Please see PEP 360 before making changes to external packages.
........
  r46888 | martin.v.loewis | 2006-06-12 06:26:31 +0200 (Mon, 12 Jun 2006) | 2 lines

  Get rid of function pointer cast.
........
  r46889 | thomas.heller | 2006-06-12 08:05:57 +0200 (Mon, 12 Jun 2006) | 3 lines

  I don't know how that happend, but the entire file contents was
  duplicated.  Thanks to Simon Percivall for the heads up.
........
  r46890 | nick.coghlan | 2006-06-12 10:19:37 +0200 (Mon, 12 Jun 2006) | 1 line

  Fix site module docstring to match the code
........
  r46891 | nick.coghlan | 2006-06-12 10:23:02 +0200 (Mon, 12 Jun 2006) | 1 line

  Fix site module docstring to match the code for Mac OSX, too
........
  r46892 | nick.coghlan | 2006-06-12 10:27:13 +0200 (Mon, 12 Jun 2006) | 1 line

  The site module documentation also described the Windows behaviour incorrectly.
........
  r46893 | nick.coghlan | 2006-06-12 12:17:11 +0200 (Mon, 12 Jun 2006) | 1 line

  Make the -m switch conform to the documentation of sys.path by behaving like the -c switch
........
  r46894 | kristjan.jonsson | 2006-06-12 17:45:12 +0200 (Mon, 12 Jun 2006) | 2 lines

  Fix the CRT argument error handling for VisualStudio .NET 2005.  Install a CRT error handler and disable the assertion for debug builds.  This causes CRT to set errno to EINVAL.
  This update fixes crash cases in the test suite where the default CRT error handler would cause process exit.
........
  r46899 | thomas.heller | 2006-06-12 22:56:48 +0200 (Mon, 12 Jun 2006) | 1 line

  Add pep-291 compatibility markers.
........
  r46901 | ka-ping.yee | 2006-06-13 01:47:52 +0200 (Tue, 13 Jun 2006) | 5 lines

  Add the uuid module.

  This module has been tested so far on Windows XP (Python 2.4 and 2.5a2),
  Mac OS X (Python 2.3, 2.4, and 2.5a2), and Linux (Python 2.4 and 2.5a2).
........
  r46902 | tim.peters | 2006-06-13 02:30:01 +0200 (Tue, 13 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46903 | tim.peters | 2006-06-13 02:30:50 +0200 (Tue, 13 Jun 2006) | 2 lines

  Added missing svn:eol-style property to text files.
........
  r46905 | tim.peters | 2006-06-13 05:30:07 +0200 (Tue, 13 Jun 2006) | 5 lines

  get_matching_blocks():  rewrote code & comments so they match; added
  more comments about why it's this way at all; and removed what looked
  like needless expense (sorting (i, j, k) triples directly should give
  exactly the same order as sorting (i, (i, j, k)) pairs).
........
  r46906 | neal.norwitz | 2006-06-13 06:08:53 +0200 (Tue, 13 Jun 2006) | 1 line

  Don't fail if another process is listening on our port.
........
  r46908 | neal.norwitz | 2006-06-13 10:28:19 +0200 (Tue, 13 Jun 2006) | 2 lines

  Initialize the type object so pychecker can't crash the interpreter.
........
  r46909 | neal.norwitz | 2006-06-13 10:41:06 +0200 (Tue, 13 Jun 2006) | 1 line

  Verify the crash due to EncodingMap not initialized does not return
........
  r46910 | thomas.heller | 2006-06-13 10:56:14 +0200 (Tue, 13 Jun 2006) | 3 lines

  Add some windows datatypes that were missing from this file, and add
  the aliases defined in windows header files for the structures.
........
  r46911 | thomas.heller | 2006-06-13 11:40:14 +0200 (Tue, 13 Jun 2006) | 3 lines

  Add back WCHAR, UINT, DOUBLE, _LARGE_INTEGER, _ULARGE_INTEGER.
  VARIANT_BOOL is a special _ctypes data type, not c_short.
........
  r46912 | ronald.oussoren | 2006-06-13 13:19:56 +0200 (Tue, 13 Jun 2006) | 4 lines

  Linecache contains support for PEP302 loaders, but fails to deal with loaders
  that return None to indicate that the module is valid but no source is
  available. This patch fixes that.
........
  r46913 | andrew.kuchling | 2006-06-13 13:57:04 +0200 (Tue, 13 Jun 2006) | 1 line

  Mention uuid module
........
  r46915 | walter.doerwald | 2006-06-13 14:02:12 +0200 (Tue, 13 Jun 2006) | 2 lines

  Fix passing errors to the encoder and decoder functions.
........
  r46917 | walter.doerwald | 2006-06-13 14:04:43 +0200 (Tue, 13 Jun 2006) | 3 lines

  errors is an attribute in the incremental decoder
  not an argument.
........
  r46919 | andrew.macintyre | 2006-06-13 17:04:24 +0200 (Tue, 13 Jun 2006) | 11 lines

  Patch #1454481:  Make thread stack size runtime tunable.

  Heavily revised, comprising revisions:
  46640 - original trunk revision (backed out in r46655)
  46647 - markup fix (backed out in r46655)
  46692:46918 merged from branch aimacintyre-sf1454481

  branch tested on buildbots (Windows buildbots had problems
  not related to these changes).
........
  r46920 | brett.cannon | 2006-06-13 18:06:55 +0200 (Tue, 13 Jun 2006) | 2 lines

  Remove unused variable.
........
  r46921 | andrew.kuchling | 2006-06-13 18:41:41 +0200 (Tue, 13 Jun 2006) | 1 line

  Add ability to set stack size
........
  r46923 | marc-andre.lemburg | 2006-06-13 19:04:26 +0200 (Tue, 13 Jun 2006) | 2 lines

  Update pybench to version 2.0.
........
  r46924 | marc-andre.lemburg | 2006-06-13 19:07:14 +0200 (Tue, 13 Jun 2006) | 2 lines

  Revert wrong svn copy.
........
  r46925 | andrew.macintyre | 2006-06-13 19:14:36 +0200 (Tue, 13 Jun 2006) | 2 lines

  fix exception usage
........
  r46927 | tim.peters | 2006-06-13 20:37:07 +0200 (Tue, 13 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46928 | marc-andre.lemburg | 2006-06-13 20:56:56 +0200 (Tue, 13 Jun 2006) | 9 lines

  Updated to pybench 2.0.

  See svn.python.org/external/pybench-2.0 for the original import of that
  version.

  Note that platform.py was not copied over from pybench-2.0 since
  it is already part of Python 2.5.
........
  r46929 | andrew.macintyre | 2006-06-13 21:02:35 +0200 (Tue, 13 Jun 2006) | 5 lines

  Increase the small thread stack size to get the test
  to pass reliably on the one buildbot that insists on
  more than 32kB of thread stack.
........
  r46930 | marc-andre.lemburg | 2006-06-13 21:20:07 +0200 (Tue, 13 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46931 | thomas.heller | 2006-06-13 22:18:43 +0200 (Tue, 13 Jun 2006) | 2 lines

  More docs for ctypes.
........
  r46932 | brett.cannon | 2006-06-13 23:34:24 +0200 (Tue, 13 Jun 2006) | 2 lines

  Ignore .pyc and .pyo files in Pybench.
........
  r46933 | brett.cannon | 2006-06-13 23:46:41 +0200 (Tue, 13 Jun 2006) | 7 lines

  If a classic class defined a __coerce__() method that just returned its two
  arguments in reverse, the interpreter would infinitely recourse trying to get a
  coercion that worked.  So put in a recursion check after a coercion is made and
  the next call to attempt to use the coerced values.

  Fixes bug #992017 and closes crashers/coerce.py .
........
  r46936 | gerhard.haering | 2006-06-14 00:24:47 +0200 (Wed, 14 Jun 2006) | 3 lines

  Merged changes from external pysqlite 2.3.0 release. Documentation updates will
  follow in a few hours at the latest. Then we should be ready for beta1.
........
  r46937 | brett.cannon | 2006-06-14 00:26:13 +0200 (Wed, 14 Jun 2006) | 2 lines

  Missed test for rev. 46933; infinite recursion from __coerce__() returning its arguments reversed.
........
  r46938 | gerhard.haering | 2006-06-14 00:53:48 +0200 (Wed, 14 Jun 2006) | 2 lines

  Updated documentation for pysqlite 2.3.0 API.
........
  r46939 | tim.peters | 2006-06-14 06:09:25 +0200 (Wed, 14 Jun 2006) | 10 lines

  SequenceMatcher.get_matching_blocks():  This now guarantees that
  adjacent triples in the result list describe non-adjacent matching
  blocks.  That's _nice_ to have, and Guido said he wanted it.

  Not a bugfix candidate:  Guido or not ;-), this changes visible
  endcase semantics (note that some tests had to change), and
  nothing about this was documented before.  Since it was working
  as designed, and behavior was consistent with the docs, it wasn't
  "a bug".
........
  r46940 | tim.peters | 2006-06-14 06:13:00 +0200 (Wed, 14 Jun 2006) | 2 lines

  Repaired typo in new comment.
........
  r46941 | tim.peters | 2006-06-14 06:15:27 +0200 (Wed, 14 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46942 | fred.drake | 2006-06-14 06:25:02 +0200 (Wed, 14 Jun 2006) | 3 lines

  - make some disabled tests run what they intend when enabled
  - remove some over-zealous triple-quoting
........
  r46943 | fred.drake | 2006-06-14 07:04:47 +0200 (Wed, 14 Jun 2006) | 3 lines

  add tests for two cases that are handled correctly in the current code,
  but that SF patch 1504676 as written mis-handles
........
  r46944 | fred.drake | 2006-06-14 07:15:51 +0200 (Wed, 14 Jun 2006) | 1 line

  explain an XXX in more detail
........
  r46945 | martin.v.loewis | 2006-06-14 07:21:04 +0200 (Wed, 14 Jun 2006) | 1 line

  Patch #1455898: Incremental mode for "mbcs" codec.
........
  r46946 | georg.brandl | 2006-06-14 08:08:31 +0200 (Wed, 14 Jun 2006) | 3 lines

  Bug #1339007: Shelf objects now don't raise an exception in their
  __del__ method when initialization failed.
........
  r46948 | thomas.heller | 2006-06-14 08:18:15 +0200 (Wed, 14 Jun 2006) | 1 line

  Fix docstring.
........
  r46949 | georg.brandl | 2006-06-14 08:29:07 +0200 (Wed, 14 Jun 2006) | 2 lines

  Bug #1501122: mention __gt__ &co in description of comparison order.
........
  r46951 | thomas.heller | 2006-06-14 09:08:38 +0200 (Wed, 14 Jun 2006) | 1 line

  Write more docs.
........
  r46952 | georg.brandl | 2006-06-14 10:31:39 +0200 (Wed, 14 Jun 2006) | 3 lines

  Bug #1153163: describe __add__ vs __radd__ behavior when adding
  objects of same type/of subclasses of the other.
........
  r46954 | georg.brandl | 2006-06-14 10:42:11 +0200 (Wed, 14 Jun 2006) | 3 lines

  Bug #1202018: add some common mime.types locations.
........
  r46955 | georg.brandl | 2006-06-14 10:50:03 +0200 (Wed, 14 Jun 2006) | 3 lines

  Bug #1117556: SimpleHTTPServer now tries to find and use the system's
  mime.types file for determining MIME types.
........
  r46957 | thomas.heller | 2006-06-14 11:09:08 +0200 (Wed, 14 Jun 2006) | 1 line

  Document paramflags.
........
  r46958 | thomas.heller | 2006-06-14 11:20:11 +0200 (Wed, 14 Jun 2006) | 1 line

  Add an __all__ list, since this module does 'from ctypes import *'.
........
  r46959 | andrew.kuchling | 2006-06-14 15:59:15 +0200 (Wed, 14 Jun 2006) | 1 line

  Add item
........
  r46961 | georg.brandl | 2006-06-14 18:46:43 +0200 (Wed, 14 Jun 2006) | 3 lines

  Bug #805015: doc error in PyUnicode_FromEncodedObject.
........
  r46962 | gerhard.haering | 2006-06-15 00:28:37 +0200 (Thu, 15 Jun 2006) | 10 lines

  - Added version checks in C code to make sure we don't trigger bugs in older
    SQLite versions.
  - Added version checks in test suite so that we don't execute tests that we
    know will fail with older (buggy) SQLite versions.

  Now, all tests should run against all SQLite versions from 3.0.8 until 3.3.6
  (latest one now). The sqlite3 module can be built against all these SQLite
  versions and the sqlite3 module does its best to not trigger bugs in SQLite,
  but using SQLite 3.3.3 or later is recommended.
........
  r46963 | tim.peters | 2006-06-15 00:38:13 +0200 (Thu, 15 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46964 | neal.norwitz | 2006-06-15 06:54:29 +0200 (Thu, 15 Jun 2006) | 9 lines

  Speculative checkin (requires approval of Gerhard Haering)

  This backs out the test changes in 46962 which prevented crashes
  by not running the tests via a version check.  All the version checks
  added in that rev were removed from the tests.

  Code was added to the error handler in connection.c that seems
  to work with older versions of sqlite including 3.1.3.
........
  r46965 | neal.norwitz | 2006-06-15 07:55:49 +0200 (Thu, 15 Jun 2006) | 1 line

  Try to narrow window of failure on slow/busy boxes (ppc64 buildbot)
........
  r46966 | martin.v.loewis | 2006-06-15 08:45:05 +0200 (Thu, 15 Jun 2006) | 2 lines

  Make import/lookup of mbcs fail on non-Windows systems.
........
  r46967 | ronald.oussoren | 2006-06-15 10:14:18 +0200 (Thu, 15 Jun 2006) | 2 lines

  Patch #1446489	(zipfile: support for ZIP64)
........
  r46968 | neal.norwitz | 2006-06-15 10:16:44 +0200 (Thu, 15 Jun 2006) | 6 lines

  Re-revert this change.  Install the version check and don't run the test
  until Gerhard has time to fully debug the issue.  This affects versions
  before 3.2.1 (possibly only versions earlier than 3.1.3).

  Based on discussion on python-checkins.
........
  r46969 | gregory.p.smith | 2006-06-15 10:52:32 +0200 (Thu, 15 Jun 2006) | 6 lines

  - bsddb: multithreaded DB access using the simple bsddb module interface
    now works reliably.  It has been updated to use automatic BerkeleyDB
    deadlock detection and the bsddb.dbutils.DeadlockWrap wrapper to retry
    database calls that would previously deadlock. [SF python bug #775414]
........
  r46970 | gregory.p.smith | 2006-06-15 11:23:52 +0200 (Thu, 15 Jun 2006) | 2 lines

  minor documentation cleanup.  mention the bsddb.db interface explicitly by name.
........
  r46971 | neal.norwitz | 2006-06-15 11:57:03 +0200 (Thu, 15 Jun 2006) | 5 lines

  Steal the trick from test_compiler to print out a slow msg.
  This will hopefully get the buildbots to pass.  Not sure this
  test will be feasible or even work.  But everything is red now,
  so it can't get much worse.
........
  r46972 | neal.norwitz | 2006-06-15 12:24:49 +0200 (Thu, 15 Jun 2006) | 1 line

  Print some more info to get an idea of how much longer the test will last
........
  r46981 | tim.peters | 2006-06-15 20:04:40 +0200 (Thu, 15 Jun 2006) | 6 lines

  Try to reduce the extreme peak memory and disk-space use
  of this test.  It probably still requires more disk space
  than most buildbots have, and in any case is still so
  intrusive that if we don't find another way to test this I'm
  taking my buildbot offline permanently ;-)
........
  r46982 | tim.peters | 2006-06-15 20:06:29 +0200 (Thu, 15 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r46983 | tim.peters | 2006-06-15 20:07:28 +0200 (Thu, 15 Jun 2006) | 2 lines

  Add missing svn:eol-style property to text files.
........
  r46984 | tim.peters | 2006-06-15 20:38:19 +0200 (Thu, 15 Jun 2006) | 2 lines

  Oops -- I introduced an off-by-6436159488 error.
........
  r46990 | neal.norwitz | 2006-06-16 06:30:34 +0200 (Fri, 16 Jun 2006) | 1 line

  Disable this test until we can determine what to do about it
........
  r46991 | neal.norwitz | 2006-06-16 06:31:06 +0200 (Fri, 16 Jun 2006) | 1 line

  Param name is dir, not directory.  Update docstring.  Backport candidate
........
  r46992 | neal.norwitz | 2006-06-16 06:31:28 +0200 (Fri, 16 Jun 2006) | 1 line

  Add missing period in comment.
........
  r46993 | neal.norwitz | 2006-06-16 06:32:43 +0200 (Fri, 16 Jun 2006) | 1 line

  Fix whitespace, there are memory leaks in this module.
........
  r46995 | fred.drake | 2006-06-17 01:45:06 +0200 (Sat, 17 Jun 2006) | 3 lines

  SF patch 1504676: Make sgmllib char and entity references pluggable
  (implementation/tests contributed by Sam Ruby)
........
  r46996 | fred.drake | 2006-06-17 03:07:54 +0200 (Sat, 17 Jun 2006) | 1 line

  fix change that broke the htmllib tests
........
  r46998 | martin.v.loewis | 2006-06-17 11:15:14 +0200 (Sat, 17 Jun 2006) | 3 lines

  Patch #763580:  Add name and value arguments to
  Tkinter variable classes.
........
  r46999 | martin.v.loewis | 2006-06-17 11:20:41 +0200 (Sat, 17 Jun 2006) | 2 lines

  Patch #1096231: Add default argument to wm_iconbitmap.
........
  r47000 | martin.v.loewis | 2006-06-17 11:25:15 +0200 (Sat, 17 Jun 2006) | 2 lines

  Patch #1494750: Destroy master after deleting children.
........
  r47003 | george.yoshida | 2006-06-17 18:31:52 +0200 (Sat, 17 Jun 2006) | 2 lines

  markup fix
........
  r47005 | george.yoshida | 2006-06-17 18:39:13 +0200 (Sat, 17 Jun 2006) | 4 lines

  Update url.

  Old url returned status code:301 Moved permanently.
........
  r47007 | martin.v.loewis | 2006-06-17 20:44:27 +0200 (Sat, 17 Jun 2006) | 2 lines

  Patch #812986: Update the canvas even if not tracing.
........
  r47008 | martin.v.loewis | 2006-06-17 21:03:26 +0200 (Sat, 17 Jun 2006) | 2 lines

  Patch #815924: Restore ability to pass type= and icon=
........
  r47009 | neal.norwitz | 2006-06-18 00:37:45 +0200 (Sun, 18 Jun 2006) | 1 line

  Fix typo in docstring
........
  r47010 | neal.norwitz | 2006-06-18 00:38:15 +0200 (Sun, 18 Jun 2006) | 1 line

  Fix memory leak reported by valgrind while running test_subprocess
........
  r47011 | fred.drake | 2006-06-18 04:57:35 +0200 (Sun, 18 Jun 2006) | 1 line

  remove unnecessary markup
........
  r47013 | neal.norwitz | 2006-06-18 21:35:01 +0200 (Sun, 18 Jun 2006) | 7 lines

  Prevent spurious leaks when running regrtest.py -R.  There may be more
  issues that crop up from time to time, but this change seems to have been
  pretty stable (no spurious warnings) for about a week.

  Other modules which use threads may require similar use of
  threading_setup/threading_cleanup from test_support.
........
  r47014 | neal.norwitz | 2006-06-18 21:37:40 +0200 (Sun, 18 Jun 2006) | 9 lines

  The hppa ubuntu box sometimes hangs forever in these tests.  My guess
  is that the wait is failing for some reason.  Use WNOHANG, so we won't
  wait until the buildbot kills the test suite.

  I haven't been able to reproduce the failure, so I'm not sure if
  this will help or not.  Hopefully, this change will cause the test
  to fail, rather than hang.  That will be better since we will get
  the rest of the test results.  It may also help us debug the real problem.
........
  r47015 | neal.norwitz | 2006-06-18 22:10:24 +0200 (Sun, 18 Jun 2006) | 1 line

  Revert 47014 until it is more robust
........
  r47016 | thomas.heller | 2006-06-18 23:27:04 +0200 (Sun, 18 Jun 2006) | 6 lines

  Fix typos.
  Fix doctest example.
  Mention in the tutorial that 'errcheck' is explained in the ref manual.
  Use better wording in some places.
  Remoce code examples that shouldn't be in the tutorial.
  Remove some XXX notices.
........
  r47017 | georg.brandl | 2006-06-19 00:17:29 +0200 (Mon, 19 Jun 2006) | 3 lines

  Patch #1507676: improve exception messages in abstract.c, object.c and typeobject.c.
........
  r47018 | neal.norwitz | 2006-06-19 07:40:44 +0200 (Mon, 19 Jun 2006) | 1 line

  Use Py_ssize_t
........
  r47019 | georg.brandl | 2006-06-19 08:35:54 +0200 (Mon, 19 Jun 2006) | 3 lines

  Add news entry about error msg improvement.
........
  r47020 | thomas.heller | 2006-06-19 09:07:49 +0200 (Mon, 19 Jun 2006) | 2 lines

  Try to repair the failing test on the OpenBSD buildbot.  Trial and error...
........
  r47021 | tim.peters | 2006-06-19 09:45:16 +0200 (Mon, 19 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r47022 | walter.doerwald | 2006-06-19 10:07:50 +0200 (Mon, 19 Jun 2006) | 4 lines

  Patch #1506645: add Python wrappers for the curses functions
  is_term_resized, resize_term and resizeterm. This uses three
  separate configure checks (one for each function).
........
  r47023 | walter.doerwald | 2006-06-19 10:14:09 +0200 (Mon, 19 Jun 2006) | 2 lines

  Make check order match in configure and configure.in.
........
  r47024 | tim.peters | 2006-06-19 10:14:28 +0200 (Mon, 19 Jun 2006) | 3 lines

  Repair KeyError when running test_threaded_import under -R,
  as reported by Neal on python-dev.
........
  r47025 | thomas.heller | 2006-06-19 10:32:46 +0200 (Mon, 19 Jun 2006) | 3 lines

  Next try to fix the OpenBSD buildbot tests:
  Use ctypes.util.find_library to locate the C runtime library
  on platforms where is returns useful results.
........
  r47026 | tim.peters | 2006-06-19 11:09:44 +0200 (Mon, 19 Jun 2006) | 13 lines

  TestHelp.make_parser():  This was making a permanent change to
  os.environ (setting envar COLUMNS), which at least caused
  test_float_default() to fail if the tests were run more than once.

  This repairs the test_optparse -R failures Neal reported on
  python-dev.  It also explains some seemingly bizarre test_optparse
  failures we saw a couple weeks ago on the buildbots, when
  test_optparse failed due to test_file failing to clean up after
  itself, and then test_optparse failed in an entirely different
  way when regrtest's -w option ran test_optparse a second time.
  It's now obvious that make_parser() permanently changing os.environ
  was responsible for the second half of that.
........
  r47027 | anthony.baxter | 2006-06-19 14:04:15 +0200 (Mon, 19 Jun 2006) | 2 lines

  Preparing for 2.5b1.
........
  r47029 | fred.drake | 2006-06-19 19:31:16 +0200 (Mon, 19 Jun 2006) | 1 line

  remove non-working document formats from edist
........
  r47030 | gerhard.haering | 2006-06-19 23:17:35 +0200 (Mon, 19 Jun 2006) | 5 lines

  Fixed a memory leak that was introduced with incorrect usage of the Python weak
  reference API in pysqlite 2.2.1.

  Bumbed pysqlite version number to upcoming pysqlite 2.3.1 release.
........
  r47032 | ka-ping.yee | 2006-06-20 00:49:36 +0200 (Tue, 20 Jun 2006) | 2 lines

  Remove Python 2.3 compatibility comment.
........
  r47033 | trent.mick | 2006-06-20 01:21:25 +0200 (Tue, 20 Jun 2006) | 2 lines

  Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
........
  r47034 | trent.mick | 2006-06-20 01:57:41 +0200 (Tue, 20 Jun 2006) | 3 lines

  [ 1295808 ] expat symbols should be namespaced in pyexpat
  (http://python.org/sf/1295808)
........
  r47039 | andrew.kuchling | 2006-06-20 13:52:16 +0200 (Tue, 20 Jun 2006) | 1 line

  Uncomment wsgiref section
........
  r47040 | andrew.kuchling | 2006-06-20 14:15:09 +0200 (Tue, 20 Jun 2006) | 1 line

  Add four library items
........
  r47041 | andrew.kuchling | 2006-06-20 14:19:54 +0200 (Tue, 20 Jun 2006) | 1 line

  Terminology and typography fixes
........
  r47042 | andrew.kuchling | 2006-06-20 15:05:12 +0200 (Tue, 20 Jun 2006) | 1 line

  Add introductory paragraphs summarizing the release; minor edits
........
  r47043 | andrew.kuchling | 2006-06-20 15:11:29 +0200 (Tue, 20 Jun 2006) | 1 line

  Minor edits and rearrangements; markup fix
........
  r47044 | andrew.kuchling | 2006-06-20 15:20:30 +0200 (Tue, 20 Jun 2006) | 1 line

  [Bug #1504456] Mention xml -> xmlcore change
........
  r47047 | brett.cannon | 2006-06-20 19:30:26 +0200 (Tue, 20 Jun 2006) | 2 lines

  Raise TestSkipped when the test socket connection is refused.
........
  r47049 | brett.cannon | 2006-06-20 21:20:17 +0200 (Tue, 20 Jun 2006) | 2 lines

  Fix typo of exception name.
........
  r47053 | brett.cannon | 2006-06-21 18:57:57 +0200 (Wed, 21 Jun 2006) | 5 lines

  At the C level, tuple arguments are passed in directly to the exception
  constructor, meaning it is treated as *args, not as a single argument.  This
  means using the 'message' attribute won't work (until Py3K comes around),
  and so one must grab from 'arg' to get the error number.
........
  r47054 | andrew.kuchling | 2006-06-21 19:10:18 +0200 (Wed, 21 Jun 2006) | 1 line

  Link to LibRef module documentation
........
  r47055 | andrew.kuchling | 2006-06-21 19:17:10 +0200 (Wed, 21 Jun 2006) | 1 line

  Note some of Barry's work
........
  r47056 | andrew.kuchling | 2006-06-21 19:17:28 +0200 (Wed, 21 Jun 2006) | 1 line

  Bump version
........
  r47057 | georg.brandl | 2006-06-21 19:45:17 +0200 (Wed, 21 Jun 2006) | 3 lines

  fix [ 1509132 ] compiler module builds incorrect AST for TryExceptFinally
........
  r47058 | georg.brandl | 2006-06-21 19:52:36 +0200 (Wed, 21 Jun 2006) | 3 lines

  Make test_fcntl aware of netbsd3.
........
  r47059 | georg.brandl | 2006-06-21 19:53:17 +0200 (Wed, 21 Jun 2006) | 3 lines

  Patch #1509001: expected skips for netbsd3.
........
  r47060 | gerhard.haering | 2006-06-21 22:55:04 +0200 (Wed, 21 Jun 2006) | 2 lines

  Removed call to enable_callback_tracebacks that slipped in by accident.
........
  r47061 | armin.rigo | 2006-06-21 23:58:50 +0200 (Wed, 21 Jun 2006) | 13 lines

  Fix for an obscure bug introduced by revs 46806 and 46808, with a test.
  The problem of checking too eagerly for recursive calls is the
  following: if a RuntimeError is caused by recursion, and if code needs
  to normalize it immediately (as in the 2nd test), then
  PyErr_NormalizeException() needs a call to the RuntimeError class to
  instantiate it, and this hits the recursion limit again...  causing
  PyErr_NormalizeException() to never finish.

  Moved this particular recursion check to slot_tp_call(), which is not
  involved in instantiating built-in exceptions.

  Backport candidate.
........
  r47064 | neal.norwitz | 2006-06-22 08:30:50 +0200 (Thu, 22 Jun 2006) | 3 lines

  Copy the wsgiref package during make install.
........
  r47065 | neal.norwitz | 2006-06-22 08:35:30 +0200 (Thu, 22 Jun 2006) | 1 line

  Reset the doc date to today for the automatic doc builds
........
  r47067 | andrew.kuchling | 2006-06-22 15:10:23 +0200 (Thu, 22 Jun 2006) | 1 line

  Mention how to suppress warnings
........
  r47069 | georg.brandl | 2006-06-22 16:46:17 +0200 (Thu, 22 Jun 2006) | 3 lines

  Set lineno correctly on list, tuple and dict literals.
........
  r47070 | georg.brandl | 2006-06-22 16:46:46 +0200 (Thu, 22 Jun 2006) | 4 lines

  Test for correct compilation of try-except-finally stmt.
  Test for correct lineno on list, tuple, dict literals.
........
  r47071 | fred.drake | 2006-06-22 17:50:08 +0200 (Thu, 22 Jun 2006) | 1 line

  fix markup nit
........
  r47072 | brett.cannon | 2006-06-22 18:49:14 +0200 (Thu, 22 Jun 2006) | 6 lines

  'warning's was improperly requiring that a command-line Warning category be
  both a subclass of Warning and a subclass of types.ClassType.  The latter is no
  longer true thanks to new-style exceptions.

  Closes bug #1510580.  Thanks to AMK for the test.
........
  r47073 | ronald.oussoren | 2006-06-22 20:33:54 +0200 (Thu, 22 Jun 2006) | 3 lines

  MacOSX: Add a message to the first screen of the installer that tells
  users how to avoid updates to their shell profile.
........
  r47074 | georg.brandl | 2006-06-22 21:02:18 +0200 (Thu, 22 Jun 2006) | 3 lines

  Fix my name ;)
........
  r47075 | thomas.heller | 2006-06-22 21:07:36 +0200 (Thu, 22 Jun 2006) | 2 lines

  Small fixes, mostly in the markup.
........
  r47076 | peter.astrand | 2006-06-22 22:06:46 +0200 (Thu, 22 Jun 2006) | 1 line

  Make it possible to run test_subprocess.py on Python 2.2, which lacks test_support.is_resource_enabled.
........
  r47077 | peter.astrand | 2006-06-22 22:21:26 +0200 (Thu, 22 Jun 2006) | 1 line

  Applied patch #1506758: Prevent MemoryErrors with large MAXFD.
........
  r47079 | neal.norwitz | 2006-06-23 05:32:44 +0200 (Fri, 23 Jun 2006) | 1 line

  Fix refleak
........
  r47080 | fred.drake | 2006-06-23 08:03:45 +0200 (Fri, 23 Jun 2006) | 9 lines

  - SF bug #853506: IP6 address parsing in sgmllib
    ('[' and ']' were not accepted in unquoted attribute values)

  - cleaned up tests of character and entity reference decoding so the
    tests cover the documented relationships among handle_charref,
    handle_entityref, convert_charref, convert_codepoint, and
    convert_entityref, without bringing up Unicode issues that sgmllib
    cannot be involved in
........
  r47085 | andrew.kuchling | 2006-06-23 21:23:40 +0200 (Fri, 23 Jun 2006) | 11 lines

  Fit Makefile for the Python doc environment better; this is a step toward
  including the howtos in the build process.

  	* Put LaTeX output in ../paper-<whatever>/.
  	* Put HTML output in ../html/
  	* Explain some of the Makefile variables
  	* Remove some cruft dating to my environment (e.g. the 'web' target)

  This makefile isn't currently invoked by the documentation build process,
  so these changes won't destabilize anything.
........
  r47086 | hyeshik.chang | 2006-06-23 23:16:18 +0200 (Fri, 23 Jun 2006) | 5 lines

  Bug #1511381: codec_getstreamcodec() in codec.c is corrected to
  omit a default "error" argument for NULL pointer.  This allows
  the parser to take a codec from cjkcodecs again.
  (Reported by Taewook Kang and reviewed by Walter Doerwald)
........
  r47091 | ronald.oussoren | 2006-06-25 22:44:16 +0200 (Sun, 25 Jun 2006) | 6 lines

  Workaround for bug #1512124

  Without this patch IDLE will get unresponsive when you open the debugger
  window on OSX. This is both using the system Tcl/Tk on Tiger as the latest
  universal download from tk-components.sf.net.
........
  r47092 | ronald.oussoren | 2006-06-25 23:14:19 +0200 (Sun, 25 Jun 2006) | 3 lines

  Drop the calldll demo's for macos, calldll isn't present anymore, no need
  to keep the demo's around.
........
  r47093 | ronald.oussoren | 2006-06-25 23:15:58 +0200 (Sun, 25 Jun 2006) | 3 lines

  Use a path without a double slash to compile the .py files after installation
  (macosx, binary installer). This fixes bug #1508369 for python 2.5.
........
  r47094 | ronald.oussoren | 2006-06-25 23:19:06 +0200 (Sun, 25 Jun 2006) | 3 lines

  Also install the .egg-info files in Lib. This will cause wsgiref.egg-info to
  be installed.
........
  r47097 | andrew.kuchling | 2006-06-26 14:40:02 +0200 (Mon, 26 Jun 2006) | 1 line

  [Bug #1511998] Various comments from Nick Coghlan; thanks!
........
  r47098 | andrew.kuchling | 2006-06-26 14:43:43 +0200 (Mon, 26 Jun 2006) | 1 line

  Describe workaround for PyRange_New()'s removal
........
  r47099 | andrew.kuchling | 2006-06-26 15:08:24 +0200 (Mon, 26 Jun 2006) | 5 lines

  [Bug #1512163] Fix typo.

  This change will probably break tests on FreeBSD buildbots, but I'll check in
  a fix for that next.
........
  r47100 | andrew.kuchling | 2006-06-26 15:12:16 +0200 (Mon, 26 Jun 2006) | 9 lines

  [Bug #1512163] Use one set of locking methods, lockf();
  remove the flock() calls.

  On FreeBSD, the two methods lockf() and flock() end up using the same
  mechanism and the second one fails.  A Linux man page claims that the
  two methods are orthogonal (so locks acquired one way don't interact
  with locks acquired the other way) but that clearly must be false.
........
  r47101 | andrew.kuchling | 2006-06-26 15:23:10 +0200 (Mon, 26 Jun 2006) | 5 lines

  Add a test for a conflicting lock.

  On slow machines, maybe the time intervals (2 sec, 0.5 sec) will be too tight.
  I'll see how the buildbots like it.
........
  r47103 | andrew.kuchling | 2006-06-26 16:33:24 +0200 (Mon, 26 Jun 2006) | 1 line

  Windows doesn't have os.fork().  I'll just disable this test for now
........
  r47106 | andrew.kuchling | 2006-06-26 19:00:35 +0200 (Mon, 26 Jun 2006) | 9 lines

  Attempt to fix build failure on OS X and Debian alpha; the symptom is
  consistent with os.wait() returning immediately because some other
  subprocess had previously exited; the test suite then immediately
  tries to lock the mailbox and gets an error saying it's already
  locked.

  To fix this, do a waitpid() so the test suite only continues once
  the intended child process has exited.
........
  r47113 | neal.norwitz | 2006-06-27 06:06:46 +0200 (Tue, 27 Jun 2006) | 1 line

  Ignore some more warnings in the dynamic linker on an older gentoo
........
  r47114 | neal.norwitz | 2006-06-27 06:09:13 +0200 (Tue, 27 Jun 2006) | 6 lines

  Instead of doing a make test, run the regression tests out of the installed
  copy.  This will hopefully catch problems where directories are added
  under Lib/ but not to Makefile.pre.in.  This breaks out the 2 runs
  of the test suite with and without -O which is also nicer.
........
  r47115 | neal.norwitz | 2006-06-27 06:12:58 +0200 (Tue, 27 Jun 2006) | 5 lines

  Fix SF bug #1513032, 'make install' failure on FreeBSD 5.3.

  No need to install lib-old, it's empty in 2.5.
........
  r47116 | neal.norwitz | 2006-06-27 06:23:06 +0200 (Tue, 27 Jun 2006) | 1 line

  Test unimportant change to verify buildbot does not try to build
........
  r47117 | neal.norwitz | 2006-06-27 06:26:30 +0200 (Tue, 27 Jun 2006) | 1 line

  Try again: test unimportant change to verify buildbot does not try to build
........
  r47118 | neal.norwitz | 2006-06-27 06:28:56 +0200 (Tue, 27 Jun 2006) | 1 line

  Verify buildbot picks up these changes (really needs testing after last change to Makefile.pre.in)
........
  r47121 | vinay.sajip | 2006-06-27 09:34:37 +0200 (Tue, 27 Jun 2006) | 1 line

  Removed buggy exception handling in doRollover of rotating file handlers. Exceptions now propagate to caller.
........
  r47123 | ronald.oussoren | 2006-06-27 12:08:25 +0200 (Tue, 27 Jun 2006) | 3 lines

  MacOSX: fix rather dumb buglet that made it impossible to create extensions on
  OSX 10.3 when using a binary distribution build on 10.4.
........
  r47125 | tim.peters | 2006-06-27 13:52:49 +0200 (Tue, 27 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r47128 | ronald.oussoren | 2006-06-27 14:53:52 +0200 (Tue, 27 Jun 2006) | 8 lines

  Use staticly build copies of zlib and bzip2 to build the OSX installer, that
  way the resulting binaries have a better change of running on 10.3.

  This patch also updates the search logic for sleepycat db3/4, without this
  patch you cannot use a sleepycat build with a non-standard prefix; with this
  you can (at least on OSX) if you add the prefix to CPPFLAGS/LDFLAGS at
  configure-time. This change is needed to build the binary installer for OSX.
........
  r47131 | ronald.oussoren | 2006-06-27 17:45:32 +0200 (Tue, 27 Jun 2006) | 5 lines

  macosx: Install a libpython2.5.a inside the framework as a symlink to the actual
  dylib at the root of the framework, that way tools that expect a unix-like
  install (python-config, but more importantly external products like
  mod_python) work correctly.
........
  r47137 | neal.norwitz | 2006-06-28 07:03:22 +0200 (Wed, 28 Jun 2006) | 4 lines

  According to the man pages on Gentoo Linux and Tru64, EACCES or EAGAIN
  can be returned if fcntl (lockf) fails.  This fixes the test failure
  on Tru64 by checking for either error rather than just EAGAIN.
........
  r47139 | neal.norwitz | 2006-06-28 08:28:31 +0200 (Wed, 28 Jun 2006) | 5 lines

  Fix bug #1512695: cPickle.loads could crash if it was interrupted with
  a KeyboardInterrupt since PyTuple_Pack was passed a NULL.

  Will backport.
........
  r47142 | nick.coghlan | 2006-06-28 12:41:47 +0200 (Wed, 28 Jun 2006) | 1 line

  Make full module name available as __module_name__ even when __name__ is set to something else (like '__main__')
........
  r47143 | armin.rigo | 2006-06-28 12:49:51 +0200 (Wed, 28 Jun 2006) | 2 lines

  A couple of crashers of the "won't fix" kind.
........
  r47147 | andrew.kuchling | 2006-06-28 16:25:20 +0200 (Wed, 28 Jun 2006) | 1 line

  [Bug #1508766] Add docs for uuid module; docs written by George Yoshida, with minor rearrangements by me.
........
  r47148 | andrew.kuchling | 2006-06-28 16:27:21 +0200 (Wed, 28 Jun 2006) | 1 line

  [Bug #1508766] Add docs for uuid module; this puts the module in the 'Internet Protocols' section.  Arguably this module could also have gone in the chapters on strings or encodings, maybe even the crypto chapter.  Fred, please move if you see fit.
........
  r47151 | georg.brandl | 2006-06-28 22:23:25 +0200 (Wed, 28 Jun 2006) | 3 lines

  Fix end_fill().
........
  r47153 | trent.mick | 2006-06-28 22:30:41 +0200 (Wed, 28 Jun 2006) | 2 lines

  Mention the expat upgrade and pyexpat fix I put in 2.5b1.
........
  r47154 | fred.drake | 2006-06-29 02:51:53 +0200 (Thu, 29 Jun 2006) | 6 lines

  SF bug #1504333: sgmlib should allow angle brackets in quoted values
  (modified patch by Sam Ruby; changed to use separate REs for start and end
   tags to reduce matching cost for end tags; extended tests; updated to avoid
   breaking previous changes to support IPv6 addresses in unquoted attribute
   values)
........
  r47156 | fred.drake | 2006-06-29 04:57:48 +0200 (Thu, 29 Jun 2006) | 1 line

  document recent bugfixes in sgmllib
........
  r47158 | neal.norwitz | 2006-06-29 06:10:08 +0200 (Thu, 29 Jun 2006) | 10 lines

  Add new utility function, reap_children(), to test_support.  This should
  be called at the end of each test that spawns children (perhaps it
  should be called from regrtest instead?).  This will hopefully prevent
  some of the unexplained failures in the buildbots (hppa and alpha)
  during tests that spawn children.  The problems were not reproducible.
  There were many zombies that remained at the end of several tests.
  In the worst case, this shouldn't cause any more problems,
  though it may not help either.  Time will tell.
........
  r47159 | neal.norwitz | 2006-06-29 07:48:14 +0200 (Thu, 29 Jun 2006) | 5 lines

  This should fix the buildbot failure on s/390 which can't connect to gmail.org.
  It makes the error message consistent and always sends to stderr.

  It would be much better for all the networking tests to hit only python.org.
........
  r47161 | thomas.heller | 2006-06-29 20:34:15 +0200 (Thu, 29 Jun 2006) | 3 lines

  Protect the thread api calls in the _ctypes extension module within
  #ifdef WITH_THREADS/#endif blocks.  Found by Sam Rushing.
........
  r47162 | martin.v.loewis | 2006-06-29 20:58:44 +0200 (Thu, 29 Jun 2006) | 2 lines

  Patch #1509163: MS Toolkit Compiler no longer available
........
  r47163 | skip.montanaro | 2006-06-29 21:20:09 +0200 (Thu, 29 Jun 2006) | 1 line

  add string methods to index
........
  r47164 | vinay.sajip | 2006-06-30 02:13:08 +0200 (Fri, 30 Jun 2006) | 1 line

  Fixed bug in fileConfig() which failed to clear logging._handlerList
........
  r47166 | tim.peters | 2006-06-30 08:18:39 +0200 (Fri, 30 Jun 2006) | 2 lines

  Whitespace normalization.
........
  r47170 | neal.norwitz | 2006-06-30 09:32:16 +0200 (Fri, 30 Jun 2006) | 1 line

  Silence compiler warning
........
  r47171 | neal.norwitz | 2006-06-30 09:32:46 +0200 (Fri, 30 Jun 2006) | 1 line

  Another problem reported by Coverity.  Backport candidate.
........
  r47175 | thomas.heller | 2006-06-30 19:44:54 +0200 (Fri, 30 Jun 2006) | 2 lines

  Revert the use of PY_FORMAT_SIZE_T in PyErr_Format.
........
  r47176 | tim.peters | 2006-06-30 20:34:51 +0200 (Fri, 30 Jun 2006) | 2 lines

  Remove now-unused fidding with PY_FORMAT_SIZE_T.
........
  r47177 | georg.brandl | 2006-06-30 20:47:56 +0200 (Fri, 30 Jun 2006) | 3 lines

  Document decorator usage of property.
........
  r47181 | fred.drake | 2006-06-30 21:29:25 +0200 (Fri, 30 Jun 2006) | 4 lines

  - consistency nit: always include "()" in \function and \method
    (*should* be done by the presentation, but that requires changes all over)
  - avoid spreading the __name meme
........
  r47188 | vinay.sajip | 2006-07-01 12:45:20 +0200 (Sat, 01 Jul 2006) | 1 line

  Added entry for fileConfig() bugfix.
........
  r47189 | vinay.sajip | 2006-07-01 12:47:20 +0200 (Sat, 01 Jul 2006) | 1 line

  Added duplicate call to fileConfig() to ensure that it cleans up after itself correctly.
........
  r47190 | martin.v.loewis | 2006-07-01 17:33:37 +0200 (Sat, 01 Jul 2006) | 2 lines

  Release all forwarded functions in .close. Fixes #1513223.
........
  r47191 | fred.drake | 2006-07-01 18:28:20 +0200 (Sat, 01 Jul 2006) | 7 lines

  SF bug #1296433 (Expat bug #1515266): Unchecked calls to character data
  handler would cause a segfault.  This merges in Expat's lib/xmlparse.c
  revisions 1.154 and 1.155, which fix this and a closely related problem
  (the later does not affect Python).

  Moved the crasher test to the tests for xml.parsers.expat.
........
  r47197 | gerhard.haering | 2006-07-02 19:48:30 +0200 (Sun, 02 Jul 2006) | 4 lines

  The sqlite3 module did cut off data from the SQLite database at the first null
  character before sending it to a custom converter. This has been fixed now.
........
  r47198 | martin.v.loewis | 2006-07-02 20:44:00 +0200 (Sun, 02 Jul 2006) | 1 line

  Correct arithmetic in access on Win32. Fixes #1513646.
........
  r47203 | thomas.heller | 2006-07-03 09:58:09 +0200 (Mon, 03 Jul 2006) | 1 line

  Cleanup: Remove commented out code.
........
  r47204 | thomas.heller | 2006-07-03 09:59:50 +0200 (Mon, 03 Jul 2006) | 1 line

  Don't run the doctests with Python 2.3 because it doesn't have the ELLIPSIS flag.
........
  r47205 | thomas.heller | 2006-07-03 10:04:05 +0200 (Mon, 03 Jul 2006) | 7 lines

  Fixes so that _ctypes can be compiled with the MingW compiler.

  It seems that the definition of '__attribute__(x)' was responsible for
  the compiler ignoring the '__fastcall' attribute on the
  ffi_closure_SYSV function in libffi_msvc/ffi.c, took me quite some
  time to figure this out.
........
  r47206 | thomas.heller | 2006-07-03 10:08:14 +0200 (Mon, 03 Jul 2006) | 11 lines

  Add a new function uses_seh() to the _ctypes extension module.  This
  will return True if Windows Structured Exception handling (SEH) is
  used when calling functions, False otherwise.

  Currently, only MSVC supports SEH.

  Fix the test so that it doesn't crash when run with MingW compiled
  _ctypes.  Note that two tests are still failing when mingw is used, I
  suspect structure layout differences and function calling conventions
  between MSVC and MingW.
........
  r47207 | tim.peters | 2006-07-03 10:23:19 +0200 (Mon, 03 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r47208 | martin.v.loewis | 2006-07-03 11:44:00 +0200 (Mon, 03 Jul 2006) | 3 lines

  Only setup canvas when it is first created.
  Fixes #1514703
........
  r47209 | martin.v.loewis | 2006-07-03 12:05:30 +0200 (Mon, 03 Jul 2006) | 3 lines

  Reimplement turtle.circle using a polyline, to allow correct
  filling of arcs. Also fixes #1514693.
........
  r47210 | martin.v.loewis | 2006-07-03 12:19:49 +0200 (Mon, 03 Jul 2006) | 3 lines

  Bug #1514693: Update turtle's heading when switching between
  degrees and radians.
........
  r47211 | martin.v.loewis | 2006-07-03 13:12:06 +0200 (Mon, 03 Jul 2006) | 2 lines

  Document functions added in 2.3 and 2.5.
........
  r47212 | martin.v.loewis | 2006-07-03 14:19:50 +0200 (Mon, 03 Jul 2006) | 3 lines

  Bug #1417699: Reject locale-specific decimal point in float()
  and atof().
........
  r47213 | martin.v.loewis | 2006-07-03 14:28:58 +0200 (Mon, 03 Jul 2006) | 3 lines

  Bug #1267547: Put proper recursive setup.py call into the
  spec file generated by bdist_rpm.
........
  r47215 | martin.v.loewis | 2006-07-03 15:01:35 +0200 (Mon, 03 Jul 2006) | 3 lines

  Patch #825417: Fix timeout processing in expect,
  read_until. Will backport to 2.4.
........
  r47218 | martin.v.loewis | 2006-07-03 15:47:40 +0200 (Mon, 03 Jul 2006) | 2 lines

  Put method-wrappers into trashcan. Fixes #927248.
........
  r47219 | andrew.kuchling | 2006-07-03 16:07:30 +0200 (Mon, 03 Jul 2006) | 1 line

  [Bug #1515932] Clarify description of slice assignment
........
  r47220 | andrew.kuchling | 2006-07-03 16:16:09 +0200 (Mon, 03 Jul 2006) | 4 lines

  [Bug #1511911] Clarify description of optional arguments to sorted()
     by improving the xref to the section on lists, and by
     copying the explanations of the arguments (with a slight modification).
........
  r47223 | kristjan.jonsson | 2006-07-03 16:59:05 +0200 (Mon, 03 Jul 2006) | 1 line

  Fix build problems with the platform SDK on windows.  It is not sufficient to test for the C compiler version when determining if we have the secure CRT from microsoft.  Must test with an undocumented macro, __STDC_SECURE_LIB__ too.
........
  r47224 | ronald.oussoren | 2006-07-04 14:30:22 +0200 (Tue, 04 Jul 2006) | 7 lines

  Sync the darwin/x86 port libffi with the copy in PyObjC. This fixes a number
  of bugs in that port. The most annoying ones were due to some subtle differences
  between the document ABI and the actual implementation :-(

  (there are no python unittests that fail without this patch, but without it
   some of libffi's unittests fail).
........
  r47234 | georg.brandl | 2006-07-05 10:21:00 +0200 (Wed, 05 Jul 2006) | 3 lines

  Remove remaining references to OverflowWarning.
........
  r47236 | thomas.heller | 2006-07-05 11:13:56 +0200 (Wed, 05 Jul 2006) | 3 lines

  Fix the bitfield test when _ctypes is compiled with MingW.  Structures
  containing bitfields may have different layout on MSVC and MingW .
........
  r47237 | thomas.wouters | 2006-07-05 13:03:49 +0200 (Wed, 05 Jul 2006) | 15 lines


  Fix bug in passing tuples to string.Template. All other values (with working
  str() or repr()) would work, just not multi-value tuples. Probably not a
  backport candidate, since it changes the behaviour of passing a
  single-element tuple:

  >>> string.Template("$foo").substitute(dict(foo=(1,)))

  '(1,)'

  versus

  '1'
........
  r47241 | georg.brandl | 2006-07-05 16:18:45 +0200 (Wed, 05 Jul 2006) | 2 lines

  Patch #1517490: fix glitches in filter() docs.
........
  r47244 | georg.brandl | 2006-07-05 17:50:05 +0200 (Wed, 05 Jul 2006) | 2 lines

  no need to elaborate "string".
........
  r47251 | neal.norwitz | 2006-07-06 06:28:59 +0200 (Thu, 06 Jul 2006) | 3 lines

  Fix refleaks reported by Shane Hathaway in SF patch #1515361.  This change
  contains only the changes related to leaking the copy variable.
........
  r47253 | fred.drake | 2006-07-06 07:13:22 +0200 (Thu, 06 Jul 2006) | 4 lines

  - back out Expat change; the final fix to Expat will be different
  - change the pyexpat wrapper to not be so sensitive to this detail of the
    Expat implementation (the ex-crasher test still passes)
........
  r47257 | neal.norwitz | 2006-07-06 08:45:08 +0200 (Thu, 06 Jul 2006) | 1 line

  Add a NEWS entry for a recent pyexpat fix
........
  r47258 | martin.v.loewis | 2006-07-06 08:55:58 +0200 (Thu, 06 Jul 2006) | 2 lines

  Add sqlite3.dll to the DLLs component, not to the TkDLLs component.
  Fixes #1517388.
........
  r47259 | martin.v.loewis | 2006-07-06 09:05:21 +0200 (Thu, 06 Jul 2006) | 1 line

  Properly quote compileall and Lib paths in case TARGETDIR has a space.
........
  r47260 | thomas.heller | 2006-07-06 09:50:18 +0200 (Thu, 06 Jul 2006) | 5 lines

  Revert the change done in svn revision 47206:

  Add a new function uses_seh() to the _ctypes extension module.  This
  will return True if Windows Structured Exception handling (SEH) is
  used when calling functions, False otherwise.
........
  r47261 | armin.rigo | 2006-07-06 09:58:18 +0200 (Thu, 06 Jul 2006) | 3 lines

  A couple of examples about how to attack the fact that _PyType_Lookup()
  returns a borrowed ref.  Many of the calls are open to attack.
........
  r47262 | thomas.heller | 2006-07-06 10:28:14 +0200 (Thu, 06 Jul 2006) | 2 lines

  The test that calls a function with invalid arguments and catches the
  resulting Windows access violation will not be run by default.
........
  r47263 | thomas.heller | 2006-07-06 10:48:35 +0200 (Thu, 06 Jul 2006) | 5 lines

  Patch #1517790: It is now possible to use custom objects in the ctypes
  foreign function argtypes sequence as long as they provide a
  from_param method, no longer is it required that the object is a
  ctypes type.
........
  r47264 | thomas.heller | 2006-07-06 10:58:40 +0200 (Thu, 06 Jul 2006) | 2 lines

  Document the Struture and Union constructors.
........
  r47265 | thomas.heller | 2006-07-06 11:11:22 +0200 (Thu, 06 Jul 2006) | 2 lines

  Document the changes in svn revision 47263, from patch #1517790.
........
  r47267 | ronald.oussoren | 2006-07-06 12:13:35 +0200 (Thu, 06 Jul 2006) | 7 lines

  This patch solves the problem Skip was seeing with zlib, this patch ensures that
  configure uses similar compiler flags as setup.py when doing the zlib test.

  Without this patch configure would use the first shared library on the linker
  path, with this patch it uses the first shared or static library on that path
  just like setup.py.
........
  r47268 | thomas.wouters | 2006-07-06 12:48:28 +0200 (Thu, 06 Jul 2006) | 4 lines


  NEWS entry for r47267: fixing configure's zlib probing.
........
  r47269 | fredrik.lundh | 2006-07-06 14:29:24 +0200 (Thu, 06 Jul 2006) | 3 lines

  added XMLParser alias for cElementTree compatibility
........
  r47271 | nick.coghlan | 2006-07-06 14:53:04 +0200 (Thu, 06 Jul 2006) | 1 line

  Revert the __module_name__ changes made in rev 47142. We'll revisit this in Python 2.6
........
  r47272 | nick.coghlan | 2006-07-06 15:04:56 +0200 (Thu, 06 Jul 2006) | 1 line

  Update the tutorial section on relative imports
........
  r47273 | nick.coghlan | 2006-07-06 15:35:27 +0200 (Thu, 06 Jul 2006) | 1 line

  Ignore ImportWarning by default
........
  r47274 | nick.coghlan | 2006-07-06 15:41:34 +0200 (Thu, 06 Jul 2006) | 1 line

  Cover ImportWarning, PendingDeprecationWarning and simplefilter() in the warnings module docs
........
  r47275 | nick.coghlan | 2006-07-06 15:47:18 +0200 (Thu, 06 Jul 2006) | 1 line

  Add NEWS entries for the ImportWarning change and documentation update
........
  r47276 | andrew.kuchling | 2006-07-06 15:57:28 +0200 (Thu, 06 Jul 2006) | 1 line

  ImportWarning is now silent by default
........
  r47277 | thomas.heller | 2006-07-06 17:06:05 +0200 (Thu, 06 Jul 2006) | 2 lines

  Document the correct return type of PyLong_AsUnsignedLongLongMask.
........
  r47278 | hyeshik.chang | 2006-07-06 17:21:52 +0200 (Thu, 06 Jul 2006) | 2 lines

  Add a testcase for r47086 which fixed a bug in codec_getstreamcodec().
........
  r47279 | hyeshik.chang | 2006-07-06 17:39:24 +0200 (Thu, 06 Jul 2006) | 3 lines

  Test using all CJK encodings for the testcases which don't require
  specific encodings.
........
  r47280 | martin.v.loewis | 2006-07-06 21:28:03 +0200 (Thu, 06 Jul 2006) | 2 lines

  Properly generate logical file ids. Fixes #1515998.
  Also correct typo in Control.mapping.
........
  r47287 | neal.norwitz | 2006-07-07 08:03:15 +0200 (Fri, 07 Jul 2006) | 17 lines

  Restore rev 47014:

  The hppa ubuntu box sometimes hangs forever in these tests.  My guess
  is that the wait is failing for some reason.  Use WNOHANG, so we won't
  wait until the buildbot kills the test suite.

  I haven't been able to reproduce the failure, so I'm not sure if
  this will help or not.  Hopefully, this change will cause the test
  to fail, rather than hang.  That will be better since we will get
  the rest of the test results.  It may also help us debug the real problem.

  *** The reason this originally failed was because there were many
  zombie children outstanding before rev 47158 cleaned them up.
  There are still hangs in test_subprocess that need to be addressed,
  but that will take more work.  This should close some holes.
........
  r47289 | georg.brandl | 2006-07-07 10:15:12 +0200 (Fri, 07 Jul 2006) | 3 lines

  Fix RFC number.
........
  r50489 | neal.norwitz | 2006-07-08 07:31:37 +0200 (Sat, 08 Jul 2006) | 1 line

  Fix SF bug #1519018: 'as' is now validated properly in import statements
........
  r50490 | georg.brandl | 2006-07-08 14:15:27 +0200 (Sat, 08 Jul 2006) | 3 lines

  Add an additional test for bug #1519018.
........
  r50491 | tim.peters | 2006-07-08 21:55:05 +0200 (Sat, 08 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50493 | neil.schemenauer | 2006-07-09 18:16:34 +0200 (Sun, 09 Jul 2006) | 2 lines

  Fix AST compiler bug #1501934: incorrect LOAD/STORE_GLOBAL generation.
........
  r50495 | neil.schemenauer | 2006-07-09 23:19:29 +0200 (Sun, 09 Jul 2006) | 2 lines

  Fix SF bug 1441486: bad unary minus folding in compiler.
........
  r50497 | neal.norwitz | 2006-07-10 00:14:42 +0200 (Mon, 10 Jul 2006) | 4 lines

  On 64 bit systems, int literals that use less than 64 bits are now ints
  rather than longs.  This also fixes the test for eval(-sys.maxint - 1).
........
  r50500 | neal.norwitz | 2006-07-10 02:04:44 +0200 (Mon, 10 Jul 2006) | 4 lines

  Bug #1512814, Fix incorrect lineno's when code at module scope
  started after line 256.
........
  r50501 | neal.norwitz | 2006-07-10 02:05:34 +0200 (Mon, 10 Jul 2006) | 1 line

  Fix doco.  Backport candidate.
........
  r50503 | neal.norwitz | 2006-07-10 02:23:17 +0200 (Mon, 10 Jul 2006) | 5 lines

  Part of SF patch #1484695.  This removes dead code.  The chksum was
  already verified in .frombuf() on the lines above.  If there was
  a problem an exception is raised, so there was no way this condition
  could have been true.
........
  r50504 | neal.norwitz | 2006-07-10 03:18:57 +0200 (Mon, 10 Jul 2006) | 3 lines

  Patch #1516912: improve Modules support for OpenVMS.
........
  r50506 | neal.norwitz | 2006-07-10 04:36:41 +0200 (Mon, 10 Jul 2006) | 7 lines

  Patch #1504046: Add documentation for xml.etree.

  /F wrote the text docs, Englebert Gruber massaged it to latex and I
  did some more massaging to try and improve the consistency and
  fix some name mismatches between the declaration and text.
........
  r50509 | martin.v.loewis | 2006-07-10 09:23:48 +0200 (Mon, 10 Jul 2006) | 2 lines

  Introduce DISTUTILS_USE_SDK as a flag to determine whether the
  SDK environment should be used. Fixes #1508010.
........
  r50510 | martin.v.loewis | 2006-07-10 09:26:41 +0200 (Mon, 10 Jul 2006) | 1 line

  Change error message to indicate that VS2003 is necessary to build extension modules, not the .NET SDK.
........
  r50511 | martin.v.loewis | 2006-07-10 09:29:41 +0200 (Mon, 10 Jul 2006) | 1 line

  Add svn:ignore.
........
  r50512 | anthony.baxter | 2006-07-10 09:41:04 +0200 (Mon, 10 Jul 2006) | 1 line

  preparing for 2.5b2
........
  r50513 | thomas.heller | 2006-07-10 11:10:28 +0200 (Mon, 10 Jul 2006) | 2 lines

  Fix bug #1518190: accept any integer or long value in the
  ctypes.c_void_p constructor.
........
  r50514 | thomas.heller | 2006-07-10 11:31:06 +0200 (Mon, 10 Jul 2006) | 3 lines

  Fixed a segfault when ctypes.wintypes were imported on
  non-Windows machines.
........
  r50516 | thomas.heller | 2006-07-10 13:11:10 +0200 (Mon, 10 Jul 2006) | 3 lines

  Assigning None to pointer type structure fields possible overwrote
  wrong fields.
........
  r50517 | thomas.heller | 2006-07-10 13:17:37 +0200 (Mon, 10 Jul 2006) | 5 lines

  Moved the ctypes news entries from the 'Library' section into the
  'Extension Modules' section where they belong, probably.

  This destroyes the original order of the news entries, don't know
  if that is important or not.
........
  r50526 | phillip.eby | 2006-07-10 21:03:29 +0200 (Mon, 10 Jul 2006) | 2 lines

  Fix SF#1516184 and add a test to prevent regression.
........
  r50528 | phillip.eby | 2006-07-10 21:18:35 +0200 (Mon, 10 Jul 2006) | 2 lines

  Fix SF#1457312: bad socket error handling in distutils "upload" command.
........
  r50537 | peter.astrand | 2006-07-10 22:39:49 +0200 (Mon, 10 Jul 2006) | 1 line

  Make it possible to run test_subprocess.py with Python 2.2, which lacks test_support.reap_children().
........
  r50541 | tim.peters | 2006-07-10 23:08:24 +0200 (Mon, 10 Jul 2006) | 5 lines

  After approval from Anthony, merge the tim-current_frames
  branch into the trunk.  This adds a new sys._current_frames()
  function, which returns a dict mapping thread id to topmost
  thread stack frame.
........
  r50542 | tim.peters | 2006-07-10 23:11:49 +0200 (Mon, 10 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50553 | martin.v.loewis | 2006-07-11 00:11:28 +0200 (Tue, 11 Jul 2006) | 4 lines

  Patch #1519566: Remove unused _tofill member.
  Make begin_fill idempotent.
  Update demo2 to demonstrate filling of concave shapes.
........
  r50567 | anthony.baxter | 2006-07-11 04:04:09 +0200 (Tue, 11 Jul 2006) | 4 lines

  #1494314: Fix a regression with high-numbered sockets in 2.4.3. This
  means that select() on sockets > FD_SETSIZE (typically 1024) work again.
  The patch makes sockets use poll() internally where available.
........
  r50568 | tim.peters | 2006-07-11 04:17:48 +0200 (Tue, 11 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50575 | thomas.heller | 2006-07-11 18:42:05 +0200 (Tue, 11 Jul 2006) | 1 line

  Add missing Py_DECREF.
........
  r50576 | thomas.heller | 2006-07-11 18:44:25 +0200 (Tue, 11 Jul 2006) | 1 line

  Add missing Py_DECREFs.
........
  r50579 | andrew.kuchling | 2006-07-11 19:20:16 +0200 (Tue, 11 Jul 2006) | 1 line

  Bump version number;  add sys._current_frames
........
  r50582 | thomas.heller | 2006-07-11 20:28:35 +0200 (Tue, 11 Jul 2006) | 3 lines

  When a foreign function is retrived by calling __getitem__ on a ctypes
  library instance, do not set it as attribute.
........
  r50583 | thomas.heller | 2006-07-11 20:40:50 +0200 (Tue, 11 Jul 2006) | 2 lines

  Change the ctypes version number to 1.0.0.
........
  r50597 | neal.norwitz | 2006-07-12 07:26:17 +0200 (Wed, 12 Jul 2006) | 3 lines

  Bug #1520864: unpacking singleton tuples in for loop (for x, in) work again.
........
  r50598 | neal.norwitz | 2006-07-12 07:26:35 +0200 (Wed, 12 Jul 2006) | 1 line

  Fix function name in error msg
........
  r50599 | neal.norwitz | 2006-07-12 07:27:46 +0200 (Wed, 12 Jul 2006) | 4 lines

  Fix uninitialized memory read reported by Valgrind when running doctest.
  This could happen if size == 0.
........
  r50600 | neal.norwitz | 2006-07-12 09:28:29 +0200 (Wed, 12 Jul 2006) | 1 line

  Actually change the MAGIC #.  Create a new section for 2.5c1 and mention the impact of changing the MAGIC #.
........
  r50601 | thomas.heller | 2006-07-12 10:43:47 +0200 (Wed, 12 Jul 2006) | 3 lines

  Fix #1467450: ctypes now uses RTLD_GLOBAL by default on OSX 10.3 to
  load shared libraries.
........
  r50604 | thomas.heller | 2006-07-12 16:25:18 +0200 (Wed, 12 Jul 2006) | 3 lines

  Fix the wrong description of LibraryLoader.LoadLibrary, and document
  the DEFAULT_MODE constant.
........
  r50607 | georg.brandl | 2006-07-12 17:31:17 +0200 (Wed, 12 Jul 2006) | 3 lines

  Accept long options "--help" and "--version".
........
  r50617 | thomas.heller | 2006-07-13 11:53:47 +0200 (Thu, 13 Jul 2006) | 3 lines

  A misspelled preprocessor symbol caused ctypes to be always compiled
  without thread support.  Replaced WITH_THREADS with WITH_THREAD.
........
  r50619 | thomas.heller | 2006-07-13 19:01:14 +0200 (Thu, 13 Jul 2006) | 3 lines

  Fix #1521375.  When running with root priviledges, 'gcc -o /dev/null'
  did overwrite /dev/null.  Use a temporary file instead of /dev/null.
........
  r50620 | thomas.heller | 2006-07-13 19:05:13 +0200 (Thu, 13 Jul 2006) | 2 lines

  Fix misleading words.
........
  r50622 | andrew.kuchling | 2006-07-13 19:37:26 +0200 (Thu, 13 Jul 2006) | 1 line

  Typo fix
........
  r50629 | georg.brandl | 2006-07-14 09:12:54 +0200 (Fri, 14 Jul 2006) | 3 lines

  Patch #1521874: grammar errors in doanddont.tex.
........
  r50630 | neal.norwitz | 2006-07-14 09:20:04 +0200 (Fri, 14 Jul 2006) | 1 line

  Try to improve grammar further.
........
  r50631 | martin.v.loewis | 2006-07-14 11:58:55 +0200 (Fri, 14 Jul 2006) | 1 line

  Extend build_ssl to Win64, using VSExtComp.
........
  r50632 | martin.v.loewis | 2006-07-14 14:10:09 +0200 (Fri, 14 Jul 2006) | 1 line

  Add debug output to analyse buildbot failure.
........
  r50633 | martin.v.loewis | 2006-07-14 14:31:05 +0200 (Fri, 14 Jul 2006) | 1 line

  Fix Debug build of _ssl.
........
  r50636 | andrew.kuchling | 2006-07-14 15:32:38 +0200 (Fri, 14 Jul 2006) | 1 line

  Mention new options
........
  r50638 | peter.astrand | 2006-07-14 16:04:45 +0200 (Fri, 14 Jul 2006) | 1 line

  Bug #1223937: CalledProcessError.errno -> CalledProcessError.returncode.
........
  r50640 | thomas.heller | 2006-07-14 17:01:05 +0200 (Fri, 14 Jul 2006) | 4 lines

  Make the prototypes of our private PyUnicode_FromWideChar and
  PyUnicode_AsWideChar replacement functions compatible to the official
  functions by using Py_ssize_t instead of int.
........
  r50643 | thomas.heller | 2006-07-14 19:51:14 +0200 (Fri, 14 Jul 2006) | 3 lines

  Patch #1521817: The index range checking on ctypes arrays containing
  exactly one element is enabled again.
........
  r50647 | thomas.heller | 2006-07-14 20:22:50 +0200 (Fri, 14 Jul 2006) | 2 lines

  Updates for the ctypes documentation.
........
  r50655 | fredrik.lundh | 2006-07-14 23:45:48 +0200 (Fri, 14 Jul 2006) | 3 lines

  typo
........
  r50664 | george.yoshida | 2006-07-15 18:03:49 +0200 (Sat, 15 Jul 2006) | 2 lines

  Bug #15187702 : ext/win-cookbook.html has a broken link to distutils
........
  r50667 | bob.ippolito | 2006-07-15 18:53:15 +0200 (Sat, 15 Jul 2006) | 1 line

  Patch #1220874: Update the binhex module for Mach-O.
........
  r50671 | fred.drake | 2006-07-16 03:21:20 +0200 (Sun, 16 Jul 2006) | 1 line

  clean up some link markup
........
  r50673 | neal.norwitz | 2006-07-16 03:50:38 +0200 (Sun, 16 Jul 2006) | 4 lines

  Bug #1512814, Fix incorrect lineno's when code within a function
  had more than 255 blank lines.  Byte codes need to go first, line #s second.
........
  r50674 | neal.norwitz | 2006-07-16 04:00:32 +0200 (Sun, 16 Jul 2006) | 5 lines

  a & b were dereffed above, so they are known to be valid pointers.
  z is known to be NULL, nothing to DECREF.

  Reported by Klockwork, #107.
........
  r50675 | neal.norwitz | 2006-07-16 04:02:57 +0200 (Sun, 16 Jul 2006) | 5 lines

  self is dereffed (and passed as first arg), so it's known to be good.
  func is returned from PyArg_ParseTuple and also dereffed.

  Reported by Klocwork, #30 (self one at least).
........
  r50676 | neal.norwitz | 2006-07-16 04:05:35 +0200 (Sun, 16 Jul 2006) | 4 lines

  proto was dereffed above and is known to be good.  No need for X.

  Reported by Klocwork, #39.
........
  r50677 | neal.norwitz | 2006-07-16 04:15:27 +0200 (Sun, 16 Jul 2006) | 5 lines

  Fix memory leaks in some conditions.

  Reported by Klocwork #152.
........
  r50678 | neal.norwitz | 2006-07-16 04:17:36 +0200 (Sun, 16 Jul 2006) | 4 lines

  Fix memory leak under some conditions.

  Reported by Klocwork, #98.
........
  r50679 | neal.norwitz | 2006-07-16 04:22:30 +0200 (Sun, 16 Jul 2006) | 8 lines

  Use sizeof(buffer) instead of duplicating the constants to ensure they won't
  be wrong.

  The real change is to pass (bufsz - 1) to PyOS_ascii_formatd and 1
  to strncat.  strncat copies n+1 bytes from src (not dest).

  Reported by Klocwork #58.
........
  r50680 | neal.norwitz | 2006-07-16 04:32:03 +0200 (Sun, 16 Jul 2006) | 5 lines

  Handle a NULL name properly.

  Reported by Klocwork #67
........
  r50681 | neal.norwitz | 2006-07-16 04:35:47 +0200 (Sun, 16 Jul 2006) | 6 lines

  PyFunction_SetDefaults() is documented as taking None or a tuple.
  A NULL would crash the PyTuple_Check().  Now make NULL return a SystemError.

  Reported by Klocwork #73.
........
  r50683 | neal.norwitz | 2006-07-17 02:55:45 +0200 (Mon, 17 Jul 2006) | 5 lines

  Stop INCREFing name, then checking if it's NULL.  name (f_name) should never
  be NULL so assert it.  Fix one place where we could have passed NULL.

  Reported by Klocwork #66.
........
  r50684 | neal.norwitz | 2006-07-17 02:57:15 +0200 (Mon, 17 Jul 2006) | 5 lines

  otherset is known to be non-NULL based on checks before and DECREF after.
  DECREF otherset rather than XDECREF in error conditions too.

  Reported by Klockwork #154.
........
  r50685 | neal.norwitz | 2006-07-17 02:59:04 +0200 (Mon, 17 Jul 2006) | 7 lines

  Reported by Klocwork #151.

  v2 can be NULL if exception2 is NULL.  I don't think that condition can happen,
  but I'm not sure it can't either.  Now the code will protect against either
  being NULL.
........
  r50686 | neal.norwitz | 2006-07-17 03:00:16 +0200 (Mon, 17 Jul 2006) | 1 line

  Add NEWS entry for a bunch of fixes due to warnings produced by Klocworks static analysis tool.
........
  r50687 | fred.drake | 2006-07-17 07:47:52 +0200 (Mon, 17 Jul 2006) | 3 lines

  document xmlcore (still minimal; needs mention in each of the xml.* modules)
  SF bug #1504456 (partial)
........
  r50688 | georg.brandl | 2006-07-17 15:23:46 +0200 (Mon, 17 Jul 2006) | 3 lines

  Remove usage of sets module (patch #1500609).
........
  r50689 | georg.brandl | 2006-07-17 15:26:33 +0200 (Mon, 17 Jul 2006) | 3 lines

  Add missing NEWS item (#1522771)
........
  r50690 | andrew.kuchling | 2006-07-17 18:47:54 +0200 (Mon, 17 Jul 2006) | 1 line

  Attribute more features
........
  r50692 | kurt.kaiser | 2006-07-17 23:59:27 +0200 (Mon, 17 Jul 2006) | 8 lines

  Patch 1479219 - Tal Einat
  1. 'as' highlighted as builtin in comment string on import line
  2. Comments such as "#False identity" which start with a keyword immediately
     after the '#' character aren't colored as comments.
  3. u or U beginning unicode string not correctly highlighted

  Closes bug 1325071
........
  r50693 | barry.warsaw | 2006-07-18 01:07:51 +0200 (Tue, 18 Jul 2006) | 16 lines

  decode_rfc2231(): Be more robust against buggy RFC 2231 encodings.
  Specifically, instead of raising a ValueError when there is a single tick in
  the parameter, simply return that the entire string unquoted, with None for
  both the charset and the language.  Also, if there are more than 2 ticks in
  the parameter, interpret the first three parts as the standard RFC 2231 parts,
  then the rest of the parts as the encoded string.

  Test cases added.

  Original fewer-than-3-parts fix by Tokio Kikuchi.

  Resolves SF bug # 1218081.  I will back port the fix and tests to Python 2.4
  (email 3.0) and Python 2.3 (email 2.5).

  Also, bump the version number to email 4.0.1, removing the 'alpha' moniker.
........
  r50695 | kurt.kaiser | 2006-07-18 06:03:16 +0200 (Tue, 18 Jul 2006) | 2 lines

  Rebinding Tab key was inserting 'tab' instead of 'Tab'.  Bug 1179168.
........
  r50696 | brett.cannon | 2006-07-18 06:41:36 +0200 (Tue, 18 Jul 2006) | 6 lines

  Fix bug #1520914.  Starting in 2.4, time.strftime() began to check the bounds
  of values in the time tuple passed in.  Unfortunately people came to rely on
  undocumented behaviour of setting unneeded values to 0, regardless of if it was
  within the valid range.  Now those values force the value internally to the
  minimum value when 0 is passed in.
........
  r50697 | facundo.batista | 2006-07-18 14:16:13 +0200 (Tue, 18 Jul 2006) | 1 line

  Comments and docs cleanups, and some little fixes, provided by Santiágo Peresón
........
  r50704 | martin.v.loewis | 2006-07-18 19:46:31 +0200 (Tue, 18 Jul 2006) | 2 lines

  Patch #1524429: Use repr instead of backticks again.
........
  r50706 | tim.peters | 2006-07-18 23:55:15 +0200 (Tue, 18 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50708 | tim.peters | 2006-07-19 02:03:19 +0200 (Wed, 19 Jul 2006) | 18 lines

  SF bug 1524317: configure --without-threads fails to build

  Moved the code for _PyThread_CurrentFrames() up, so it's no longer
  in a huge "#ifdef WITH_THREAD" block (I didn't realize it /was/ in
  one).

  Changed test_sys's test_current_frames() so it passes with or without
  thread supported compiled in.

  Note that test_sys fails when Python is compiled without threads,
  but for an unrelated reason (the old test_exit() fails with an
  indirect ImportError on the `thread` module).  There are also
  other unrelated compilation failures without threads, in extension
  modules (like ctypes); at least the core compiles again.

  Do we really support --without-threads?  If so, there are several
  problems remaining.
........
  r50713 | thomas.heller | 2006-07-19 11:09:32 +0200 (Wed, 19 Jul 2006) | 4 lines

  Make sure the _ctypes extension can be compiled when WITH_THREAD is
  not defined on Windows, even if that configuration is probably not
  supported at all.
........
  r50715 | martin.v.loewis | 2006-07-19 19:18:32 +0200 (Wed, 19 Jul 2006) | 4 lines

  Revert r50706 (Whitespace normalization) and
  r50697: Comments and docs cleanups, and some little fixes
  per recommendation from Raymond Hettinger.
........
  r50719 | phillip.eby | 2006-07-20 17:54:16 +0200 (Thu, 20 Jul 2006) | 4 lines

  Fix SF#1516184 (again) and add a test to prevent regression.
  (There was a problem with empty filenames still causing recursion)
........
  r50720 | georg.brandl | 2006-07-20 18:28:39 +0200 (Thu, 20 Jul 2006) | 3 lines

  Guard for _active being None in __del__ method.
........
  r50721 | vinay.sajip | 2006-07-20 18:28:39 +0200 (Thu, 20 Jul 2006) | 1 line

  Updated documentation for TimedRotatingFileHandler relating to how rollover files are named. The previous documentation was wrongly the same as for RotatingFileHandler.
........
  r50731 | fred.drake | 2006-07-20 22:11:57 +0200 (Thu, 20 Jul 2006) | 1 line

  markup fix
........
  r50739 | kurt.kaiser | 2006-07-21 00:22:52 +0200 (Fri, 21 Jul 2006) | 7 lines

  Avoid occasional failure to detect closing paren properly.
  Patch 1407280 Tal Einat

  M    ParenMatch.py
  M    NEWS.txt
  M    CREDITS.txt
........
  r50740 | vinay.sajip | 2006-07-21 01:20:12 +0200 (Fri, 21 Jul 2006) | 1 line

  Addressed SF#1524081 by using a dictionary to map level names to syslog priority names, rather than a string.lower().
........
  r50741 | neal.norwitz | 2006-07-21 07:29:58 +0200 (Fri, 21 Jul 2006) | 1 line

  Add some asserts that we got good params passed
........
  r50742 | neal.norwitz | 2006-07-21 07:31:02 +0200 (Fri, 21 Jul 2006) | 5 lines

  Move the initialization of some pointers earlier.  The problem is
  that if we call Py_DECREF(frame) like we do if allocating locals fails,
  frame_dealloc() will try to use these bogus values and crash.
........
  r50743 | neal.norwitz | 2006-07-21 07:32:28 +0200 (Fri, 21 Jul 2006) | 4 lines

  Handle allocation failures gracefully.  Found with failmalloc.
  Many (all?) of these could be backported.
........
  r50745 | neal.norwitz | 2006-07-21 09:59:02 +0200 (Fri, 21 Jul 2006) | 1 line

  Speel initialise write.  Tanks Anthony.
........
  r50746 | neal.norwitz | 2006-07-21 09:59:47 +0200 (Fri, 21 Jul 2006) | 2 lines

  Handle more memory allocation failures without crashing.
........
  r50754 | barry.warsaw | 2006-07-21 16:51:07 +0200 (Fri, 21 Jul 2006) | 23 lines

  More RFC 2231 improvements for the email 4.0 package.  As Mark Sapiro rightly
  points out there are really two types of continued headers defined in this
  RFC (i.e. "encoded" parameters with the form "name*0*=" and unencoded
  parameters with the form "name*0="), but we were were handling them both the
  same way and that isn't correct.

  This patch should be much more RFC compliant in that only encoded params are
  %-decoded and the charset/language information is only extract if there are
  any encoded params in the segments.  If there are no encoded params then the
  RFC says that there will be no charset/language parts.

  Note however that this will change the return value for Message.get_param() in
  some cases.  For example, whereas before if you had all unencoded param
  continuations you would have still gotten a 3-tuple back from this method
  (with charset and language == None), you will now get just a string.  I don't
  believe this is a backward incompatible change though because the
  documentation for this method already indicates that either return value is
  possible and that you must do an isinstance(val, tuple) check to discriminate
  between the two.  (Yeah that API kind of sucks but we can't change /that/
  without breaking code.)

  Test cases, some documentation updates, and a NEWS item accompany this patch.
........
  r50759 | georg.brandl | 2006-07-21 19:36:31 +0200 (Fri, 21 Jul 2006) | 3 lines

  Fix check for empty list (vs. None).
........
  r50771 | brett.cannon | 2006-07-22 00:44:07 +0200 (Sat, 22 Jul 2006) | 2 lines

  Remove an XXX marker in a comment.
........
  r50773 | neal.norwitz | 2006-07-22 18:20:49 +0200 (Sat, 22 Jul 2006) | 1 line

  Fix more memory allocation issues found with failmalloc.
........
  r50774 | neal.norwitz | 2006-07-22 19:00:57 +0200 (Sat, 22 Jul 2006) | 1 line

  Don't fail if the directory already exists
........
  r50775 | greg.ward | 2006-07-23 04:25:53 +0200 (Sun, 23 Jul 2006) | 6 lines

  Be a lot smarter about whether this test passes: instead of assuming
  that a 2.93 sec audio file will always take 3.1 sec (as it did on the
  hardware I had when I first wrote the test), expect that it will take
  2.93 sec +/- 10%, and only fail if it's outside of that range.
  Compute the expected
........
  r50776 | kurt.kaiser | 2006-07-23 06:19:49 +0200 (Sun, 23 Jul 2006) | 2 lines

  Tooltips failed on new-syle class __init__ args.  Bug 1027566 Loren Guthrie
........
  r50777 | neal.norwitz | 2006-07-23 09:50:36 +0200 (Sun, 23 Jul 2006) | 1 line

  Handle more mem alloc issues found with failmalloc
........
  r50778 | neal.norwitz | 2006-07-23 09:51:58 +0200 (Sun, 23 Jul 2006) | 5 lines

  If the for loop isn't entered, entryblock will be NULL.  If passed
  to stackdepth_walk it will be dereffed.

  Not sure if I found with failmalloc or Klockwork #55.
........
  r50779 | neal.norwitz | 2006-07-23 09:53:14 +0200 (Sun, 23 Jul 2006) | 4 lines

  Move the initialization of size_a down below the check for a being NULL.

  Reported by Klocwork #106
........
  r50780 | neal.norwitz | 2006-07-23 09:55:55 +0200 (Sun, 23 Jul 2006) | 9 lines

  Check the allocation of b_objects and return if there was a failure.
  Also fix a few memory leaks in other failure scenarios.

  It seems that if b_objects == Py_None, we will have an extra ref to
  b_objects.  Add XXX comment so hopefully someone documents why the
  else isn't necessary or adds it in.

  Reported by Klocwork #20
........
  r50781 | neal.norwitz | 2006-07-23 09:57:11 +0200 (Sun, 23 Jul 2006) | 2 lines

  Fix memory leaks spotted by Klocwork #37.
........
  r50782 | neal.norwitz | 2006-07-23 09:59:00 +0200 (Sun, 23 Jul 2006) | 5 lines

  nextlink can be NULL if teedataobject_new fails, so use XINCREF.
  Ensure that dataobj is never NULL.

  Reported by Klocwork #102
........
  r50783 | neal.norwitz | 2006-07-23 10:01:43 +0200 (Sun, 23 Jul 2006) | 8 lines

  Ensure we don't write beyond errText.  I think I got this right, but
  it definitely could use some review to ensure I'm not off by one
  and there's no possible overflow/wrap-around of bytes_left.
  Reported by Klocwork #1.

  Fix a problem if there is a failure allocating self->db.
  Found with failmalloc.
........
  r50784 | ronald.oussoren | 2006-07-23 11:41:09 +0200 (Sun, 23 Jul 2006) | 3 lines

  Without this patch CMD-W won't close EditorWindows on MacOS X. This solves
  part of bug #1517990.
........
  r50785 | ronald.oussoren | 2006-07-23 11:46:11 +0200 (Sun, 23 Jul 2006) | 5 lines

  Fix for bug #1517996: Class and Path browsers show Tk menu

  This patch replaces the menubar that is used by AquaTk for windows without a
  menubar of their own by one that is more appropriate for IDLE.
........
  r50786 | andrew.macintyre | 2006-07-23 14:57:02 +0200 (Sun, 23 Jul 2006) | 2 lines

  Build updates for OS/2 EMX port
........
  r50787 | andrew.macintyre | 2006-07-23 15:00:04 +0200 (Sun, 23 Jul 2006) | 3 lines

  bugfix: PyThread_start_new_thread() returns the thread ID, not a flag;
  will backport.
........
  r50789 | andrew.macintyre | 2006-07-23 15:04:00 +0200 (Sun, 23 Jul 2006) | 2 lines

  Get mailbox module working on OS/2 EMX port.
........
  r50791 | greg.ward | 2006-07-23 18:05:51 +0200 (Sun, 23 Jul 2006) | 1 line

  Resync optparse with Optik 1.5.3: minor tweaks for/to tests.
........
  r50794 | martin.v.loewis | 2006-07-24 07:05:22 +0200 (Mon, 24 Jul 2006) | 2 lines

  Update list of unsupported systems. Fixes #1510853.
........
  r50795 | martin.v.loewis | 2006-07-24 12:26:33 +0200 (Mon, 24 Jul 2006) | 1 line

  Patch #1448199: Release GIL around ConnectRegistry.
........
  r50796 | martin.v.loewis | 2006-07-24 13:54:53 +0200 (Mon, 24 Jul 2006) | 3 lines

  Patch #1232023: Don't include empty path component from registry,
  so that the current directory does not get added to sys.path.
  Also fixes #1526785.
........
  r50797 | martin.v.loewis | 2006-07-24 14:54:17 +0200 (Mon, 24 Jul 2006) | 3 lines

  Bug #1524310: Properly report errors from FindNextFile in os.listdir.
  Will backport to 2.4.
........
  r50800 | georg.brandl | 2006-07-24 15:28:57 +0200 (Mon, 24 Jul 2006) | 7 lines

  Patch #1523356: fix determining include dirs in python-config.

  Also don't install "python-config" when doing altinstall, but
  always install "python-config2.x" and make a link to it like
  with the main executable.
........
  r50802 | georg.brandl | 2006-07-24 15:46:47 +0200 (Mon, 24 Jul 2006) | 3 lines

  Patch #1527744: right order of includes in order to have HAVE_CONIO_H defined properly.
........
  r50803 | georg.brandl | 2006-07-24 16:09:56 +0200 (Mon, 24 Jul 2006) | 3 lines

  Patch #1515343: Fix printing of deprecated string exceptions with a
  value in the traceback module.
........
  r50804 | kurt.kaiser | 2006-07-24 19:13:23 +0200 (Mon, 24 Jul 2006) | 7 lines

  EditorWindow failed when used stand-alone if sys.ps1 not set.
  Bug 1010370 Dave Florek

  M    EditorWindow.py
  M    PyShell.py
  M    NEWS.txt
........
  r50805 | kurt.kaiser | 2006-07-24 20:05:51 +0200 (Mon, 24 Jul 2006) | 6 lines

  - EditorWindow.test() was failing.  Bug 1417598

  M    EditorWindow.py
  M    ScriptBinding.py
  M    NEWS.txt
........
  r50808 | georg.brandl | 2006-07-24 22:11:35 +0200 (Mon, 24 Jul 2006) | 3 lines

  Repair accidental NameError.
........
  r50809 | tim.peters | 2006-07-24 23:02:15 +0200 (Mon, 24 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50810 | greg.ward | 2006-07-25 04:11:12 +0200 (Tue, 25 Jul 2006) | 3 lines

  Don't use standard assert: want tests to fail even when run with -O.
  Delete cruft.
........
  r50811 | tim.peters | 2006-07-25 06:07:22 +0200 (Tue, 25 Jul 2006) | 10 lines

  current_frames_with_threads():  There's actually no way
  to guess /which/ line the spawned thread is in at the time
  sys._current_frames() is called:  we know it finished
  enter_g.set(), but can't know whether the instruction
  counter has advanced to the following leave_g.wait().
  The latter is overwhelming most likely, but not guaranteed,
  and I see that the "x86 Ubuntu dapper (icc) trunk" buildbot
  found it on the other line once.  Changed the test so it
  passes in either case.
........
  r50815 | martin.v.loewis | 2006-07-25 11:53:12 +0200 (Tue, 25 Jul 2006) | 2 lines

  Bug #1525817: Don't truncate short lines in IDLE's tool tips.
........
  r50816 | martin.v.loewis | 2006-07-25 12:05:47 +0200 (Tue, 25 Jul 2006) | 3 lines

  Bug #978833: Really close underlying socket in _socketobject.close.
  Will backport to 2.4.
........
  r50817 | martin.v.loewis | 2006-07-25 12:11:14 +0200 (Tue, 25 Jul 2006) | 1 line

  Revert incomplete checkin.
........
  r50819 | georg.brandl | 2006-07-25 12:22:34 +0200 (Tue, 25 Jul 2006) | 4 lines

  Patch #1525766: correctly pass onerror arg to recursive calls
  of pkg.walk_packages. Also improve the docstrings.
........
  r50825 | brett.cannon | 2006-07-25 19:32:20 +0200 (Tue, 25 Jul 2006) | 2 lines

  Add comment for changes to test_ossaudiodev.
........
  r50826 | brett.cannon | 2006-07-25 19:34:36 +0200 (Tue, 25 Jul 2006) | 3 lines

  Fix a bug in the messages for an assert failure where not enough arguments to a string
  were being converted in the format.
........
  r50828 | armin.rigo | 2006-07-25 20:09:57 +0200 (Tue, 25 Jul 2006) | 2 lines

  Document why is and is not a good way to fix the gc_inspection crasher.
........
  r50829 | armin.rigo | 2006-07-25 20:11:07 +0200 (Tue, 25 Jul 2006) | 5 lines

  Added another crasher, which hit me today (I was not intentionally
  writing such code, of course, but it took some gdb time to figure out
  what my bug was).
........
  r50830 | armin.rigo | 2006-07-25 20:38:39 +0200 (Tue, 25 Jul 2006) | 3 lines

  Document the crashers that will not go away soon as "won't fix",
  and explain why.
........
  r50831 | ronald.oussoren | 2006-07-25 21:13:35 +0200 (Tue, 25 Jul 2006) | 3 lines

  Install the compatibility symlink to libpython.a on OSX using 'ln -sf' instead
  of 'ln -s', this avoid problems when reinstalling python.
........
  r50832 | ronald.oussoren | 2006-07-25 21:20:54 +0200 (Tue, 25 Jul 2006) | 7 lines

  Fix for bug #1525447 (renaming to MacOSmodule.c would also work, but not
  without causing problems for anyone that is on a case-insensitive filesystem).

  Setup.py tries to compile the MacOS extension from MacOSmodule.c, while the
  actual file is named macosmodule.c. This is no problem on the (default)
  case-insensitive filesystem, but doesn't work on case-sensitive filesystems.
........
  r50833 | ronald.oussoren | 2006-07-25 22:28:55 +0200 (Tue, 25 Jul 2006) | 7 lines

  Fix bug #1517990: IDLE keybindings on OSX

  This adds a new key definition for OSX, which is slightly different from the
  classic mac definition.

  Also add NEWS item for a couple of bugfixes I added recently.
........
  r50834 | tim.peters | 2006-07-26 00:30:24 +0200 (Wed, 26 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50839 | neal.norwitz | 2006-07-26 06:00:18 +0200 (Wed, 26 Jul 2006) | 1 line

  Hmm, only python2.x is installed, not plain python.  Did that change recently?
........
  r50840 | barry.warsaw | 2006-07-26 07:54:46 +0200 (Wed, 26 Jul 2006) | 6 lines

  Forward port some fixes that were in email 2.5 but for some reason didn't make
  it into email 4.0.  Specifically, in Message.get_content_charset(), handle RFC
  2231 headers that contain an encoding not known to Python, or a character in
  the data that isn't in the charset encoding.  Also forward port the
  appropriate unit tests.
........
  r50841 | georg.brandl | 2006-07-26 09:23:32 +0200 (Wed, 26 Jul 2006) | 3 lines

  NEWS entry for #1525766.
........
  r50842 | georg.brandl | 2006-07-26 09:40:17 +0200 (Wed, 26 Jul 2006) | 3 lines

  Bug #1459963: properly capitalize HTTP header names.
........
  r50843 | georg.brandl | 2006-07-26 10:03:10 +0200 (Wed, 26 Jul 2006) | 6 lines

  Part of bug #1523610: fix miscalculation of buffer length.

  Also add a guard against NULL in converttuple and add a test case
  (that previously would have crashed).
........
  r50844 | martin.v.loewis | 2006-07-26 14:12:56 +0200 (Wed, 26 Jul 2006) | 3 lines

  Bug #978833: Really close underlying socket in _socketobject.close.
  Fix httplib.HTTPConnection.getresponse to not close the
  socket if it is still needed for the response.
........
  r50845 | andrew.kuchling | 2006-07-26 19:16:52 +0200 (Wed, 26 Jul 2006) | 1 line

  [Bug #1471938] Fix build problem on Solaris 8 by conditionalizing the use of mvwgetnstr(); it was conditionalized a few lines below.  Fix from Paul Eggert.  I also tried out the STRICT_SYSV_CURSES case and am therefore removing the 'untested' comment.
........
  r50846 | andrew.kuchling | 2006-07-26 19:18:01 +0200 (Wed, 26 Jul 2006) | 1 line

  Correct error message
........
  r50847 | andrew.kuchling | 2006-07-26 19:19:39 +0200 (Wed, 26 Jul 2006) | 1 line

  Minor grammar fix
........
  r50848 | andrew.kuchling | 2006-07-26 19:22:21 +0200 (Wed, 26 Jul 2006) | 1 line

  Put news item in right section
........
  r50850 | andrew.kuchling | 2006-07-26 20:03:12 +0200 (Wed, 26 Jul 2006) | 1 line

  Use sys.exc_info()
........
  r50851 | andrew.kuchling | 2006-07-26 20:15:45 +0200 (Wed, 26 Jul 2006) | 1 line

  Use sys.exc_info()
........
  r50852 | phillip.eby | 2006-07-26 21:48:27 +0200 (Wed, 26 Jul 2006) | 4 lines

  Allow the 'onerror' argument to walk_packages() to catch any Exception, not
  just ImportError.  This allows documentation tools to better skip unimportable
  packages.
........
  r50854 | tim.peters | 2006-07-27 01:23:15 +0200 (Thu, 27 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50855 | tim.peters | 2006-07-27 03:14:53 +0200 (Thu, 27 Jul 2006) | 21 lines

  Bug #1521947:  possible bug in mystrtol.c with recent gcc.

  In general, C doesn't define anything about what happens when
  an operation on a signed integral type overflows, and PyOS_strtol()
  did several formally undefined things of that nature on signed
  longs.  Some version of gcc apparently tries to exploit that now,
  and PyOS_strtol() could fail to detect overflow then.

  Tried to repair all that, although it seems at least as likely to me
  that we'll get screwed by bad platform definitions for LONG_MIN
  and/or LONG_MAX now.  For that reason, I don't recommend backporting
  this.

  Note that I have no box on which this makes a lick of difference --
  can't really test it, except to note that it didn't break anything
  on my boxes.

  Silent change:  PyOS_strtol() used to return the hard-coded 0x7fffffff
  in case of overflow.  Now it returns LONG_MAX.  They're the same only on
  32-bit boxes (although C doesn't guarantee that either ...).
........
  r50856 | neal.norwitz | 2006-07-27 05:51:58 +0200 (Thu, 27 Jul 2006) | 6 lines

  Don't kill a normal instance of python running on windows when checking
  to kill a cygwin instance.  build\\python.exe was matching a normal windows
  instance.  Prefix that with a \\ to ensure build is a directory and not
  PCbuild.  As discussed on python-dev.
........
  r50857 | neal.norwitz | 2006-07-27 05:55:39 +0200 (Thu, 27 Jul 2006) | 5 lines

  Closure can't be NULL at this point since we know it's a tuple.

  Reported by Klocwork # 74.
........
  r50858 | neal.norwitz | 2006-07-27 06:04:50 +0200 (Thu, 27 Jul 2006) | 1 line

  No functional change.  Add comment and assert to describe why there cannot be overflow which was reported by Klocwork.  Discussed on python-dev
........
  r50859 | martin.v.loewis | 2006-07-27 08:38:16 +0200 (Thu, 27 Jul 2006) | 3 lines

  Bump distutils version to 2.5, as several new features
  have been introduced since 2.4.
........
  r50860 | andrew.kuchling | 2006-07-27 14:18:20 +0200 (Thu, 27 Jul 2006) | 1 line

  Reformat docstring; fix typo
........
  r50861 | georg.brandl | 2006-07-27 17:05:36 +0200 (Thu, 27 Jul 2006) | 6 lines

  Add test_main() methods. These three tests were never run
  by regrtest.py.

  We really need a simpler testing framework.
........
  r50862 | tim.peters | 2006-07-27 17:09:20 +0200 (Thu, 27 Jul 2006) | 2 lines

  News for patch #1529686.
........
  r50863 | tim.peters | 2006-07-27 17:11:00 +0200 (Thu, 27 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50864 | georg.brandl | 2006-07-27 17:38:33 +0200 (Thu, 27 Jul 2006) | 3 lines

  Amend news entry.
........
  r50865 | georg.brandl | 2006-07-27 18:08:15 +0200 (Thu, 27 Jul 2006) | 3 lines

  Make uuid test suite pass on this box by requesting output with LC_ALL=C.
........
  r50866 | andrew.kuchling | 2006-07-27 20:37:33 +0200 (Thu, 27 Jul 2006) | 1 line

  Add example
........
  r50867 | thomas.heller | 2006-07-27 20:39:55 +0200 (Thu, 27 Jul 2006) | 9 lines

  Remove code that is no longer used (ctypes.com).

  Fix the DllGetClassObject and DllCanUnloadNow so that they forward the
  call to the comtypes.server.inprocserver module.

  The latter was never documented, never used by published code, and
  didn't work anyway, so I think it does not deserve a NEWS entry (but I
  might be wrong).
........
  r50868 | andrew.kuchling | 2006-07-27 20:41:21 +0200 (Thu, 27 Jul 2006) | 1 line

  Typo fix ('publically' is rare, poss. non-standard)
........
  r50869 | andrew.kuchling | 2006-07-27 20:42:41 +0200 (Thu, 27 Jul 2006) | 1 line

  Add missing word
........
  r50870 | andrew.kuchling | 2006-07-27 20:44:10 +0200 (Thu, 27 Jul 2006) | 1 line

  Repair typos
........
  r50872 | andrew.kuchling | 2006-07-27 20:53:33 +0200 (Thu, 27 Jul 2006) | 1 line

  Update URL; add example
........
  r50873 | andrew.kuchling | 2006-07-27 21:07:29 +0200 (Thu, 27 Jul 2006) | 1 line

  Add punctuation mark; add some examples
........
  r50874 | andrew.kuchling | 2006-07-27 21:11:07 +0200 (Thu, 27 Jul 2006) | 1 line

  Mention base64 module; rewrite last sentence to be more positive
........
  r50875 | andrew.kuchling | 2006-07-27 21:12:49 +0200 (Thu, 27 Jul 2006) | 1 line

  If binhex is higher-level than binascii, it should come first in the chapter
........
  r50876 | tim.peters | 2006-07-27 22:47:24 +0200 (Thu, 27 Jul 2006) | 28 lines

  check_node():  stop spraying mystery output to stderr.

  When a node number disagrees, keep track of all sources & the
  node numbers they reported, and stick all that in the error message.

  Changed all callers to supply a non-empty "source" argument; made
  the "source" argument non-optional.

  On my box, test_uuid still fails, but with the less confusing output:

  AssertionError: different sources disagree on node:
      from source 'getnode1', node was 00038a000015
      from source 'getnode2', node was 00038a000015
      from source 'ipconfig', node was 001111b2b7bf

  Only the last one appears to be correct; e.g.,

  C:\Code\python\PCbuild>getmac

  Physical Address    Transport Name
  =================== ==========================================================
  00-11-11-B2-B7-BF   \Device\Tcpip_{190FB163-5AFD-4483-86A1-2FE16AC61FF1}
  62-A1-AC-6C-FD-BE   \Device\Tcpip_{8F77DF5A-EA3D-4F1D-975E-D472CEE6438A}
  E2-1F-01-C6-5D-88   \Device\Tcpip_{CD18F76B-2EF3-409F-9B8A-6481EE70A1E4}

  I can't find anything on my box with MAC 00-03-8a-00-00-15, and am
  not clear on where that comes from.
........
  r50878 | andrew.kuchling | 2006-07-28 00:40:05 +0200 (Fri, 28 Jul 2006) | 1 line

  Reword paragraph
........
  r50879 | andrew.kuchling | 2006-07-28 00:49:38 +0200 (Fri, 28 Jul 2006) | 1 line

  Add example
........
  r50880 | andrew.kuchling | 2006-07-28 00:49:54 +0200 (Fri, 28 Jul 2006) | 1 line

  Add example
........
  r50881 | barry.warsaw | 2006-07-28 01:43:15 +0200 (Fri, 28 Jul 2006) | 27 lines

  Patch #1520294: Support for getset and member descriptors in types.py,
  inspect.py, and pydoc.py.  Specifically, this allows for querying the type of
  an object against these built-in C types and more importantly, for getting
  their docstrings printed in the interactive interpreter's help() function.

  This patch includes a new built-in module called _types which provides
  definitions of getset and member descriptors for use by the types.py module.
  These types are exposed as types.GetSetDescriptorType and
  types.MemberDescriptorType.  Query functions are provided as
  inspect.isgetsetdescriptor() and inspect.ismemberdescriptor().  The
  implementations of these are robust enough to work with Python implementations
  other than CPython, which may not have these fundamental types.

  The patch also includes documentation and test suite updates.

  I commit these changes now under these guiding principles:

  1. Silence is assent.  The release manager has not said "no", and of the few
     people that cared enough to respond to the thread, the worst vote was "0".

  2. It's easier to ask for forgiveness than permission.

  3. It's so dang easy to revert stuff in svn, that you could view this as a
     forcing function. :)

  Windows build patches will follow.
........
  r50882 | tim.peters | 2006-07-28 01:44:37 +0200 (Fri, 28 Jul 2006) | 4 lines

  Bug #1529297:  The rewrite of doctest for Python 2.4 unintentionally
  lost that tests are sorted by name before being run.  ``DocTestFinder``
  has been changed to sort the list of tests it returns.
........
  r50883 | tim.peters | 2006-07-28 01:45:48 +0200 (Fri, 28 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50884 | tim.peters | 2006-07-28 01:46:36 +0200 (Fri, 28 Jul 2006) | 2 lines

  Add missing svn:eol-style property to text files.
........
  r50885 | barry.warsaw | 2006-07-28 01:50:40 +0200 (Fri, 28 Jul 2006) | 4 lines

  Enable the building of the _types module on Windows.

  Note that this has only been tested for VS 2003 since that's all I have.
........
  r50887 | tim.peters | 2006-07-28 02:23:15 +0200 (Fri, 28 Jul 2006) | 7 lines

  defdict_reduce():  Plug leaks.

  We didn't notice these before because test_defaultdict didn't
  actually do anything before Georg fixed that earlier today.
  Neal's next refleak run then showed test_defaultdict leaking
  9 references on each run.  That's repaired by this checkin.
........
  r50888 | tim.peters | 2006-07-28 02:30:00 +0200 (Fri, 28 Jul 2006) | 2 lines

  News about the repaired memory leak in defaultdict.
........
  r50889 | gregory.p.smith | 2006-07-28 03:35:25 +0200 (Fri, 28 Jul 2006) | 7 lines

  - pybsddb Bug #1527939: bsddb module DBEnv dbremove and dbrename
    methods now allow their database parameter to be None as the
    sleepycat API allows.

  Also adds an appropriate test case for DBEnv.dbrename and dbremove.
........
  r50895 | neal.norwitz | 2006-07-28 06:22:34 +0200 (Fri, 28 Jul 2006) | 1 line

  Ensure the actual number matches the expected count
........
  r50896 | tim.peters | 2006-07-28 06:51:59 +0200 (Fri, 28 Jul 2006) | 6 lines

  Live with that "the hardware address" is an ill-defined
  concept, and that different ways of trying to find "the
  hardware address" may return different results.  Certainly
  true on both of my Windows boxes, and in different ways
  (see whining on python-dev).
........
  r50897 | neal.norwitz | 2006-07-28 09:21:27 +0200 (Fri, 28 Jul 2006) | 3 lines

  Try to find the MAC addr on various flavours of Unix.  This seems hopeless.
  The reduces the test_uuid failures, but there's still another method failing.
........
  r50898 | martin.v.loewis | 2006-07-28 09:45:49 +0200 (Fri, 28 Jul 2006) | 2 lines

  Add UUID for upcoming 2.5b3.
........
  r50899 | matt.fleming | 2006-07-28 13:27:27 +0200 (Fri, 28 Jul 2006) | 3 lines

  Allow socketmodule to compile on NetBSD -current, whose bluetooth API
  differs from both Linux and FreeBSD. Accepted by Neal Norwitz.
........
  r50900 | andrew.kuchling | 2006-07-28 14:07:12 +0200 (Fri, 28 Jul 2006) | 1 line

  [Patch #1529811] Correction to description of r|* mode
........
  r50901 | andrew.kuchling | 2006-07-28 14:18:22 +0200 (Fri, 28 Jul 2006) | 1 line

  Typo fix
........
  r50902 | andrew.kuchling | 2006-07-28 14:32:43 +0200 (Fri, 28 Jul 2006) | 1 line

  Add example
........
  r50903 | andrew.kuchling | 2006-07-28 14:33:19 +0200 (Fri, 28 Jul 2006) | 1 line

  Add example
........
  r50904 | andrew.kuchling | 2006-07-28 14:45:55 +0200 (Fri, 28 Jul 2006) | 1 line

  Don't overwrite built-in name; add some blank lines for readability
........
  r50905 | andrew.kuchling | 2006-07-28 14:48:07 +0200 (Fri, 28 Jul 2006) | 1 line

  Add example.  Should I propagate this example to all the other DBM-ish modules, too?
........
  r50912 | georg.brandl | 2006-07-28 20:31:39 +0200 (Fri, 28 Jul 2006) | 3 lines

  Patch #1529686: also run test_email_codecs with regrtest.py.
........
  r50913 | georg.brandl | 2006-07-28 20:36:01 +0200 (Fri, 28 Jul 2006) | 3 lines

  Fix spelling.
........
  r50915 | thomas.heller | 2006-07-28 21:42:40 +0200 (Fri, 28 Jul 2006) | 3 lines

  Remove a useless XXX comment.
  Cosmetic changes to the code so that the #ifdef _UNICODE block
  doesn't mess emacs code formatting.
........
  r50916 | phillip.eby | 2006-07-28 23:12:07 +0200 (Fri, 28 Jul 2006) | 5 lines

  Bug #1529871: The speed enhancement patch #921466 broke Python's compliance
  with PEP 302.  This was fixed by adding an ``imp.NullImporter`` type that is
  used in ``sys.path_importer_cache`` to cache non-directory paths and avoid
  excessive filesystem operations during imports.
........
  r50917 | phillip.eby | 2006-07-28 23:31:54 +0200 (Fri, 28 Jul 2006) | 2 lines

  Fix svn merge spew.
........
  r50918 | thomas.heller | 2006-07-28 23:43:20 +0200 (Fri, 28 Jul 2006) | 4 lines

  Patch #1529514: More openbsd platforms for ctypes.
  Regenerated Modules/_ctypes/libffi/configure with autoconf 2.59.

  Approved by Neal.
........
  r50922 | georg.brandl | 2006-07-29 10:51:21 +0200 (Sat, 29 Jul 2006) | 2 lines

  Bug #835255: The "closure" argument to new.function() is now documented.
........
  r50924 | georg.brandl | 2006-07-29 11:33:26 +0200 (Sat, 29 Jul 2006) | 3 lines

  Bug #1441397: The compiler module now recognizes module and function
  docstrings correctly as it did in Python 2.4.
........
  r50925 | georg.brandl | 2006-07-29 12:25:46 +0200 (Sat, 29 Jul 2006) | 4 lines

  Revert rev 42617, it was introduced to work around bug #1441397.
  test_compiler now passes again.
........
  r50926 | fred.drake | 2006-07-29 15:22:49 +0200 (Sat, 29 Jul 2006) | 1 line

  update target version number
........
  r50927 | andrew.kuchling | 2006-07-29 15:56:48 +0200 (Sat, 29 Jul 2006) | 1 line

  Add example
........
  r50928 | andrew.kuchling | 2006-07-29 16:04:47 +0200 (Sat, 29 Jul 2006) | 1 line

  Update URL
........
  r50930 | andrew.kuchling | 2006-07-29 16:08:15 +0200 (Sat, 29 Jul 2006) | 1 line

  Reword paragraph to match the order of the subsequent sections
........
  r50931 | andrew.kuchling | 2006-07-29 16:21:15 +0200 (Sat, 29 Jul 2006) | 1 line

  [Bug #1529157] Mention raw_input() and input(); while I'm at it, reword the description a bit
........
  r50932 | andrew.kuchling | 2006-07-29 16:42:48 +0200 (Sat, 29 Jul 2006) | 1 line

  [Bug #1519571] Document some missing functions: setup(), title(), done()
........
  r50933 | andrew.kuchling | 2006-07-29 16:43:55 +0200 (Sat, 29 Jul 2006) | 1 line

  Fix docstring punctuation
........
  r50934 | andrew.kuchling | 2006-07-29 17:10:32 +0200 (Sat, 29 Jul 2006) | 1 line

  [Bug #1414697] Change docstring of set/frozenset types to specify that the contents are unique.  Raymond, please feel free to edit or revert.
........
  r50935 | andrew.kuchling | 2006-07-29 17:35:21 +0200 (Sat, 29 Jul 2006) | 1 line

  [Bug #1530382] Document SSL.server(), .issuer() methods
........
  r50936 | andrew.kuchling | 2006-07-29 17:42:46 +0200 (Sat, 29 Jul 2006) | 1 line

  Typo fix
........
  r50937 | andrew.kuchling | 2006-07-29 17:43:13 +0200 (Sat, 29 Jul 2006) | 1 line

  Tweak wording
........
  r50938 | matt.fleming | 2006-07-29 17:55:30 +0200 (Sat, 29 Jul 2006) | 2 lines

  Fix typo
........
  r50939 | andrew.kuchling | 2006-07-29 17:57:08 +0200 (Sat, 29 Jul 2006) | 6 lines

  [Bug #1528258] Mention that the 'data' argument can be None.

  The constructor docs referred the reader to the add_data() method's docs,
  but they weren't very helpful.  I've simply copied an earlier explanation
  of 'data' that's more useful.
........
  r50940 | andrew.kuchling | 2006-07-29 18:08:40 +0200 (Sat, 29 Jul 2006) | 1 line

  Set bug/patch count.  Take a bow, everyone!
........
  r50941 | fred.drake | 2006-07-29 18:56:15 +0200 (Sat, 29 Jul 2006) | 18 lines

  expunge the xmlcore changes:
    41667, 41668 - initial switch to xmlcore
    47044        - mention of xmlcore in What's New
    50687        - mention of xmlcore in the library reference

  re-apply xmlcore changes to xml:
    41674        - line ending changes (re-applied manually), directory props
    41677        - add cElementTree wrapper
    41678        - PSF licensing for etree
    41812        - whitespace normalization
    42724        - fix svn:eol-style settings
    43681, 43682 - remove Python version-compatibility cruft from minidom
    46773        - fix encoding of \r\n\t in attr values in saxutils
    47269        - added XMLParser alias for cElementTree compatibility

  additional tests were added in Lib/test/test_sax.py that failed with
  the xmlcore changes; these relate to SF bugs #1511497, #1513611
........
  r50942 | andrew.kuchling | 2006-07-29 20:14:07 +0200 (Sat, 29 Jul 2006) | 17 lines

  Reorganize the docs for 'file' and 'open()' after some discussion with Fred.

  We want to encourage users to write open() when opening a file, but
  open() was described with a single paragraph and
  'file' had lots of explanation of the mode and bufsize arguments.

  I've shrunk the description of 'file' to cross-reference to the 'File
  objects' section, and to open() for an explanation of the arguments.

  open() now has all the paragraphs about the mode string.  The bufsize
  argument was moved up so that it isn't buried at the end; now there's
  1 paragraph on mode, 1 on bufsize, and then 3 more on mode.  Various
  other edits and rearrangements were made in the process.

  It's probably best to read the final text and not to try to make sense
  of the diffs.
........
  r50943 | fred.drake | 2006-07-29 20:19:19 +0200 (Sat, 29 Jul 2006) | 1 line

  restore test un-intentionally removed in the xmlcore purge (revision 50941)
........
  r50944 | fred.drake | 2006-07-29 20:33:29 +0200 (Sat, 29 Jul 2006) | 3 lines

  make the reference to older versions of the documentation a link
  to the right page on python.org
........
  r50945 | fred.drake | 2006-07-29 21:09:01 +0200 (Sat, 29 Jul 2006) | 1 line

  document the footnote usage pattern
........
  r50947 | fred.drake | 2006-07-29 21:14:10 +0200 (Sat, 29 Jul 2006) | 1 line

  emphasize and oddball nuance of LaTeX comment syntax
........
  r50948 | andrew.kuchling | 2006-07-29 21:24:04 +0200 (Sat, 29 Jul 2006) | 1 line

  [Patch #1490989 from Skip Montanaro]  Mention debugging builds in the API documentation.  I've changed Skip's patch to point to Misc/SpecialBuilds and fiddled with the markup a bit.
........
  r50949 | neal.norwitz | 2006-07-29 21:29:35 +0200 (Sat, 29 Jul 2006) | 6 lines

  Disable these tests until they are reliable across platforms.
  These problems may mask more important, real problems.

  One or both methods are known to fail on: Solaris, OpenBSD, Debian, Ubuntu.
  They pass on Windows and some Linux boxes.
........
  r50950 | andrew.kuchling | 2006-07-29 21:50:37 +0200 (Sat, 29 Jul 2006) | 1 line

  [Patch #1068277] Clarify that os.path.exists() can return False depending on permissions.  Fred approved committing this patch in December 2004!
........
  r50952 | fred.drake | 2006-07-29 22:04:42 +0200 (Sat, 29 Jul 2006) | 6 lines

  SF bug #1193966: Weakref types documentation misplaced

  The information about supporting weakrefs with types defined in C extensions
  is moved to the Extending & Embedding manual.  Py_TPFLAGS_HAVE_WEAKREFS is
  no longer mentioned since it is part of Py_TPFLAGS_DEFAULT.
........
  r50953 | skip.montanaro | 2006-07-29 22:06:05 +0200 (Sat, 29 Jul 2006) | 4 lines

  Add a comment to the csv reader documentation that explains why the
  treatment of newlines changed in 2.5.  Pulled almost verbatim from a comment
  by Andrew McNamara in <http://python.org/sf/1465014>.
........
  r50954 | neal.norwitz | 2006-07-29 22:20:52 +0200 (Sat, 29 Jul 2006) | 3 lines

  If the executable doesn't exist, there's no reason to try to start it.
  This prevents garbage about command not found being printed on Solaris.
........
  r50955 | fred.drake | 2006-07-29 22:21:25 +0200 (Sat, 29 Jul 2006) | 1 line

  fix minor markup error that introduced extra punctuation
........
  r50957 | neal.norwitz | 2006-07-29 22:37:08 +0200 (Sat, 29 Jul 2006) | 3 lines

  Disable test_getnode too, since this is also unreliable.
........
  r50958 | andrew.kuchling | 2006-07-29 23:27:12 +0200 (Sat, 29 Jul 2006) | 1 line

  Follow TeX's conventions for hyphens
........
  r50959 | andrew.kuchling | 2006-07-29 23:30:21 +0200 (Sat, 29 Jul 2006) | 1 line

  Fix case for 'Unix'
........
  r50960 | fred.drake | 2006-07-30 01:34:57 +0200 (Sun, 30 Jul 2006) | 1 line

  markup cleanups
........
  r50961 | andrew.kuchling | 2006-07-30 02:27:34 +0200 (Sun, 30 Jul 2006) | 1 line

  Minor typo fixes
........
  r50962 | andrew.kuchling | 2006-07-30 02:37:56 +0200 (Sun, 30 Jul 2006) | 1 line

  [Bug #793553] Correct description of keyword arguments for SSL authentication
........
  r50963 | tim.peters | 2006-07-30 02:58:15 +0200 (Sun, 30 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50964 | fred.drake | 2006-07-30 05:03:43 +0200 (Sun, 30 Jul 2006) | 1 line

  lots of markup nits, most commonly Unix/unix --> \UNIX
........
  r50965 | fred.drake | 2006-07-30 07:41:28 +0200 (Sun, 30 Jul 2006) | 1 line

  update information on wxPython, from Robin Dunn
........
  r50966 | fred.drake | 2006-07-30 07:49:49 +0200 (Sun, 30 Jul 2006) | 4 lines

  remove possibly-outdated comment on what GUI toolkit is most commonly used;
  it is hard to know whether this is right, and it does not add valuable reference information
  at any rate
........
  r50967 | fred.drake | 2006-07-30 07:55:39 +0200 (Sun, 30 Jul 2006) | 3 lines

  - remove yet another reference to how commonly Tkinter is (thought to be) used
  - fix an internal section reference
........
  r50968 | neal.norwitz | 2006-07-30 08:53:31 +0200 (Sun, 30 Jul 2006) | 4 lines

  Patch #1531113: Fix augmented assignment with yield expressions.
  Also fix a SystemError when trying to assign to yield expressions.
........
  r50969 | neal.norwitz | 2006-07-30 08:55:48 +0200 (Sun, 30 Jul 2006) | 5 lines

  Add PyErr_WarnEx() so C code can pass the stacklevel to warnings.warn().
  This provides the proper warning for struct.pack().
  PyErr_Warn() is now deprecated in favor of PyErr_WarnEx().
  As mentioned by Tim Peters on python-dev.
........
  r50970 | neal.norwitz | 2006-07-30 08:57:04 +0200 (Sun, 30 Jul 2006) | 3 lines

  Bug #1515471: string.replace() accepts character buffers again.
  Pass the char* and size around rather than PyObject's.
........
  r50971 | neal.norwitz | 2006-07-30 08:59:13 +0200 (Sun, 30 Jul 2006) | 1 line

  Whitespace normalization
........
  r50973 | georg.brandl | 2006-07-30 12:53:32 +0200 (Sun, 30 Jul 2006) | 3 lines

  Clarify that __op__ methods must return NotImplemented if they don't support the operation.
........
  r50974 | georg.brandl | 2006-07-30 13:07:23 +0200 (Sun, 30 Jul 2006) | 3 lines

  Bug #1002398: The documentation for os.path.sameopenfile now correctly
  refers to file descriptors, not file objects.
........
  r50977 | martin.v.loewis | 2006-07-30 15:00:31 +0200 (Sun, 30 Jul 2006) | 3 lines

  Don't copy directory stat times in shutil.copytree on Windows
  Fixes #1525866.
........
  r50978 | martin.v.loewis | 2006-07-30 15:14:05 +0200 (Sun, 30 Jul 2006) | 3 lines

  Base __version__ on sys.version_info, as distutils is
  no longer maintained separatedly.
........
  r50979 | martin.v.loewis | 2006-07-30 15:27:31 +0200 (Sun, 30 Jul 2006) | 3 lines

  Mention Cygwin in distutils error message about a missing VS 2003.
  Fixes #1257728.
........
  r50982 | martin.v.loewis | 2006-07-30 16:09:47 +0200 (Sun, 30 Jul 2006) | 5 lines

  Drop usage of test -e in configure as it is not portable.
  Fixes #1439538
  Will backport to 2.4
  Also regenerate pyconfig.h.in.
........
  r50984 | georg.brandl | 2006-07-30 18:20:10 +0200 (Sun, 30 Jul 2006) | 3 lines

  Fix makefile changes for python-config.
........
  r50985 | george.yoshida | 2006-07-30 18:37:37 +0200 (Sun, 30 Jul 2006) | 2 lines

  Rename struct.pack_to to struct.pack_into as changed in revision 46642.
........
  r50986 | george.yoshida | 2006-07-30 18:41:30 +0200 (Sun, 30 Jul 2006) | 2 lines

  Typo fix
........
  r50987 | neal.norwitz | 2006-07-30 21:18:13 +0200 (Sun, 30 Jul 2006) | 1 line

  Add some asserts and update comments
........
  r50988 | neal.norwitz | 2006-07-30 21:18:38 +0200 (Sun, 30 Jul 2006) | 1 line

  Verify that the signal handlers were really called
........
  r50989 | neal.norwitz | 2006-07-30 21:20:42 +0200 (Sun, 30 Jul 2006) | 3 lines

  Try to prevent hangs on Tru64/Alpha buildbot.  I'm not certain this will help
  and may need to be reverted if it causes problems.
........
  r50990 | georg.brandl | 2006-07-30 22:18:51 +0200 (Sun, 30 Jul 2006) | 2 lines

  Bug #1531349: right <-> left glitch in __rop__ description.
........
  r50992 | tim.peters | 2006-07-31 03:46:03 +0200 (Mon, 31 Jul 2006) | 2 lines

  Whitespace normalization.
........
  r50993 | andrew.mcnamara | 2006-07-31 04:27:48 +0200 (Mon, 31 Jul 2006) | 2 lines

  Redo the comment about the 2.5 change in quoted-newline handling.
........
  r50994 | tim.peters | 2006-07-31 04:40:23 +0200 (Mon, 31 Jul 2006) | 10 lines

  ZipFile.close():  Killed one of the struct.pack deprecation
  warnings on Win32.

  Also added an XXX about the line:

                  pos3 = self.fp.tell()

  `pos3` is never referenced, and I have no idea what the code
  intended to do instead.
........
  r50996 | tim.peters | 2006-07-31 04:53:03 +0200 (Mon, 31 Jul 2006) | 8 lines

  ZipFile.close():  Kill the other struct.pack deprecation
  warning on Windows.

  Afraid I can't detect a pattern to when the pack formats decide
  to use a signed or unsigned format code -- appears nearly
  arbitrary to my eyes.  So I left all the pack formats alone and
  changed the special-case data values instead.
........
  r50997 | skip.montanaro | 2006-07-31 05:09:45 +0200 (Mon, 31 Jul 2006) | 1 line

  minor tweaks
........
  r50998 | skip.montanaro | 2006-07-31 05:11:11 +0200 (Mon, 31 Jul 2006) | 1 line

  minor tweaks
........
  r50999 | andrew.kuchling | 2006-07-31 14:20:24 +0200 (Mon, 31 Jul 2006) | 1 line

  Add refcounts for PyErr_WarnEx
........
  r51000 | andrew.kuchling | 2006-07-31 14:39:05 +0200 (Mon, 31 Jul 2006) | 9 lines

  Document PyErr_WarnEx.  (Bad Neal!  No biscuit!)

  Is the explanation of the 'stacklevel' parameter clear?  Please feel free
  to edit it.

  I don't have LaTeX installed on this machine, so haven't verified that the
  markup is correct.  Will check tonight, or maybe the automatic doc build will
  tell me.
........
  r51001 | andrew.kuchling | 2006-07-31 14:52:26 +0200 (Mon, 31 Jul 2006) | 1 line

  Add PyErr_WarnEx()
........
  r51002 | andrew.kuchling | 2006-07-31 15:18:27 +0200 (Mon, 31 Jul 2006) | 1 line

  Mention csv newline changes
........
  r51003 | andrew.kuchling | 2006-07-31 17:22:58 +0200 (Mon, 31 Jul 2006) | 1 line

  Typo fix
........
  r51004 | andrew.kuchling | 2006-07-31 17:23:43 +0200 (Mon, 31 Jul 2006) | 1 line

  Remove reference to  notation
........
  r51005 | georg.brandl | 2006-07-31 18:00:34 +0200 (Mon, 31 Jul 2006) | 3 lines

  Fix function name.
........
  r51006 | andrew.kuchling | 2006-07-31 18:10:24 +0200 (Mon, 31 Jul 2006) | 1 line

  [Bug #1514540] Instead of putting the standard types in a section, put them in a chapter of their own.  This means string methods will now show up in the ToC.  (Should the types come before or after the functions+exceptions+constants chapter?  I've put them after, for now.)
........
  r51007 | andrew.kuchling | 2006-07-31 18:22:05 +0200 (Mon, 31 Jul 2006) | 1 line

  [Bug #848556] Remove \d* from second alternative to avoid exponential case when repeating match
........
  r51008 | andrew.kuchling | 2006-07-31 18:27:57 +0200 (Mon, 31 Jul 2006) | 1 line

  Update list of files; fix a typo
........
  r51013 | andrew.kuchling | 2006-08-01 18:24:30 +0200 (Tue, 01 Aug 2006) | 1 line

  typo fix
........
  r51018 | thomas.heller | 2006-08-01 18:54:43 +0200 (Tue, 01 Aug 2006) | 2 lines

  Fix a potential segfault and various potentail refcount leaks
  in the cast() function.
........
  r51020 | thomas.heller | 2006-08-01 19:46:10 +0200 (Tue, 01 Aug 2006) | 1 line

  Minimal useful docstring for CopyComPointer.
........
  r51021 | andrew.kuchling | 2006-08-01 20:16:15 +0200 (Tue, 01 Aug 2006) | 8 lines

  [Patch #1520905] Attempt to suppress core file created by test_subprocess.py.
  Patch by Douglas Greiman.

  The test_run_abort() testcase produces a core file on Unix systems,
  even though the test is successful. This can be confusing or alarming
  to someone who runs 'make test' and then finds that the Python
  interpreter apparently crashed.
........
  r51023 | georg.brandl | 2006-08-01 20:49:24 +0200 (Tue, 01 Aug 2006) | 3 lines

  os.urandom no longer masks unrelated exceptions like SystemExit or
  KeyboardInterrupt.
........
  r51025 | thomas.heller | 2006-08-01 21:14:15 +0200 (Tue, 01 Aug 2006) | 2 lines

  Speed up PyType_stgdict and PyObject_stgdict.
........
  r51027 | ronald.oussoren | 2006-08-01 22:30:31 +0200 (Tue, 01 Aug 2006) | 3 lines

  Make sure the postinstall action that optionally updates the user's profile
  on MacOS X actually works correctly in all cases.
........
  r51028 | ronald.oussoren | 2006-08-01 23:00:57 +0200 (Tue, 01 Aug 2006) | 4 lines

  This fixes bug #1527397: PythonLauncher runs scripts with the wrong working
  directory. It also fixes a bug where PythonLauncher failed to launch scripts
  when the scriptname (or the path to the script) contains quotes.
........
  r51031 | tim.peters | 2006-08-02 05:27:46 +0200 (Wed, 02 Aug 2006) | 2 lines

  Whitespace normalization.
........
  r51032 | tim.peters | 2006-08-02 06:12:36 +0200 (Wed, 02 Aug 2006) | 19 lines

  Try to squash struct.pack warnings on the "amd64 gentoo trunk"
  buildbot (& possibly other 64-bit boxes) during test_gzip.

  The native zlib crc32 function returns an unsigned 32-bit integer,
  which the Python wrapper implicitly casts to C long.  Therefore the
  same crc can "look negative" on a 32-bit box but "look positive" on
  a 64-bit box.  This patch papers over that platform difference when
  writing the crc to file.

  It may be better to change the Python wrapper, either to make
  the result "look positive" on all platforms (which means it may
  have to return a Python long at times on a 32-bit box), or to
  keep the sign the same across boxes.  But that would be a visible
  change in what users see, while the current hack changes no
  visible behavior (well, apart from stopping the struct deprecation
  warning).

  Note that the module-level write32() function is no longer used.
........
  r51033 | neal.norwitz | 2006-08-02 06:27:11 +0200 (Wed, 02 Aug 2006) | 4 lines

  Prevent memory leak on error.

  Reported by Klocwork #36
........
  r51034 | tim.peters | 2006-08-02 07:20:08 +0200 (Wed, 02 Aug 2006) | 9 lines

  _Stream.close():  Try to kill struct.pack() warnings when
  writing the crc to file on the "PPC64 Debian trunk" buildbot
  when running test_tarfile.

  This is again a case where the native zlib crc is an unsigned
  32-bit int, but the Python wrapper implicitly casts it to
  signed C long, so that "the sign bit looks different" on
  different platforms.
........
  r51035 | ronald.oussoren | 2006-08-02 08:10:10 +0200 (Wed, 02 Aug 2006) | 2 lines

  Updated documentation for the script that builds the OSX installer.
........
  r51036 | neal.norwitz | 2006-08-02 08:14:22 +0200 (Wed, 02 Aug 2006) | 2 lines

  _PyWeakref_GetWeakrefCount() now returns a Py_ssize_t instead of long.
........
  r51037 | neal.norwitz | 2006-08-02 08:15:10 +0200 (Wed, 02 Aug 2006) | 1 line

  v is already checked for NULL, so just DECREF it
........
  r51038 | neal.norwitz | 2006-08-02 08:19:19 +0200 (Wed, 02 Aug 2006) | 1 line

  Let us know when there was a problem and the child had to kill the parent
........
  r51039 | neal.norwitz | 2006-08-02 08:46:21 +0200 (Wed, 02 Aug 2006) | 5 lines

  Patch #1519025 and bug #926423: If a KeyboardInterrupt occurs during
  a socket operation on a socket with a timeout, the exception will be
  caught correctly.  Previously, the exception was not caught.
........
  r51040 | neal.norwitz | 2006-08-02 09:09:32 +0200 (Wed, 02 Aug 2006) | 1 line

  Add some explanation about Klocwork and Coverity static analysis
........
  r51041 | anthony.baxter | 2006-08-02 09:43:09 +0200 (Wed, 02 Aug 2006) | 1 line

  pre-release machinations
........
  r51043 | thomas.heller | 2006-08-02 13:35:31 +0200 (Wed, 02 Aug 2006) | 4 lines

  A few nore words about what ctypes does.
  Document that using the wrong calling convention can also raise
  'ValueError: Procedure called with the wrong number of arguments'.
........
  r51045 | thomas.heller | 2006-08-02 14:00:13 +0200 (Wed, 02 Aug 2006) | 1 line

  Fix a mistake.
........
  r51046 | martin.v.loewis | 2006-08-02 15:53:55 +0200 (Wed, 02 Aug 2006) | 3 lines

  Correction of patch #1455898: In the mbcs decoder, set final=False
  for stream decoder, but final=True for the decode function.
........
  r51049 | tim.peters | 2006-08-02 20:19:35 +0200 (Wed, 02 Aug 2006) | 2 lines

  Add missing svn:eol-style property to text files.
........
  r51079 | neal.norwitz | 2006-08-04 06:50:21 +0200 (Fri, 04 Aug 2006) | 3 lines

  Bug #1531405, format_exception no longer raises an exception if
  str(exception) raised an exception.
........
  r51080 | neal.norwitz | 2006-08-04 06:58:47 +0200 (Fri, 04 Aug 2006) | 11 lines

  Bug #1191458: tracing over for loops now produces a line event
  on each iteration.  I'm not positive this is the best way to handle
  this.  I'm also not sure that there aren't other cases where
  the lnotab is generated incorrectly.  It would be great if people
  that use pdb or tracing could test heavily.

  Also:
   * Remove dead/duplicated code that wasn't used/necessary
     because we already handled the docstring prior to entering the loop.
   * add some debugging code into the compiler (#if 0'd out).
........
  r51081 | neal.norwitz | 2006-08-04 07:09:28 +0200 (Fri, 04 Aug 2006) | 4 lines

  Bug #1333982: string/number constants were inappropriately stored
  in the byte code and co_consts even if they were not used, ie
  immediately popped off the stack.
........
  r51082 | neal.norwitz | 2006-08-04 07:12:19 +0200 (Fri, 04 Aug 2006) | 1 line

  There were really two issues
........
  r51084 | fred.drake | 2006-08-04 07:17:21 +0200 (Fri, 04 Aug 2006) | 1 line

  SF patch #1534048 (bug #1531003): fix typo in error message
........
  r51085 | gregory.p.smith | 2006-08-04 07:17:47 +0200 (Fri, 04 Aug 2006) | 3 lines

  fix typos
........
  r51087 | georg.brandl | 2006-08-04 08:03:53 +0200 (Fri, 04 Aug 2006) | 3 lines

  Fix bug caused by first decrefing, then increfing.
........
  r51109 | neil.schemenauer | 2006-08-04 18:20:30 +0200 (Fri, 04 Aug 2006) | 5 lines

  Fix the 'compiler' package to generate correct code for MAKE_CLOSURE.
  In the 2.5 development cycle, MAKE_CLOSURE as changed to take free
  variables as a tuple rather than as individual items on the stack.
  Closes patch #1534084.
........
  r51110 | georg.brandl | 2006-08-04 20:03:37 +0200 (Fri, 04 Aug 2006) | 3 lines

  Change fix for segfaulting property(), add a NEWS entry and a test.
........
  r51111 | georg.brandl | 2006-08-04 20:07:34 +0200 (Fri, 04 Aug 2006) | 3 lines

  Better fix for bug #1531405, not executing str(value) twice.
........
  r51112 | thomas.heller | 2006-08-04 20:17:40 +0200 (Fri, 04 Aug 2006) | 1 line

  On Windows, make PyErr_Warn an exported function again.
........
  r51113 | thomas.heller | 2006-08-04 20:57:34 +0200 (Fri, 04 Aug 2006) | 4 lines

  Fix #1530448 - fix ctypes build failure on solaris 10.

  The '-mimpure-text' linker flag is required when linking _ctypes.so.
........
  r51114 | thomas.heller | 2006-08-04 21:49:31 +0200 (Fri, 04 Aug 2006) | 3 lines

  Fix #1534738: win32 debug version of _msi must be _msi_d.pyd, not _msi.pyd.
  Fix the name of the pdb file as well.
........
  r51115 | andrew.kuchling | 2006-08-04 22:37:43 +0200 (Fri, 04 Aug 2006) | 1 line

  Typo fixes
........
  r51116 | andrew.kuchling | 2006-08-04 23:10:03 +0200 (Fri, 04 Aug 2006) | 1 line

  Fix mangled sentence
........
  r51118 | tim.peters | 2006-08-05 00:00:35 +0200 (Sat, 05 Aug 2006) | 2 lines

  Whitespace normalization.
........
  r51119 | bob.ippolito | 2006-08-05 01:59:21 +0200 (Sat, 05 Aug 2006) | 5 lines

  Fix #1530559, struct.pack raises TypeError where it used to convert.
  Passing float arguments to struct.pack when integers are expected
  now triggers a DeprecationWarning.
........
  r51123 | georg.brandl | 2006-08-05 08:10:54 +0200 (Sat, 05 Aug 2006) | 3 lines

  Patch #1534922: correct and enhance unittest docs.
........
  r51126 | georg.brandl | 2006-08-06 09:06:33 +0200 (Sun, 06 Aug 2006) | 2 lines

  Bug #1535182: really test the xreadlines() method of bz2 objects.
........
  r51128 | georg.brandl | 2006-08-06 09:26:21 +0200 (Sun, 06 Aug 2006) | 4 lines

  Bug #1535081: A leading underscore has been added to the names of
  the md5 and sha modules, so add it in Modules/Setup.dist too.
........
  r51129 | georg.brandl | 2006-08-06 10:23:54 +0200 (Sun, 06 Aug 2006) | 3 lines

  Bug #1535165: fixed a segfault in input() and raw_input() when
  sys.stdin is closed.
........
  r51131 | georg.brandl | 2006-08-06 11:17:16 +0200 (Sun, 06 Aug 2006) | 2 lines

  Don't produce output in test_builtin.
........
  r51133 | andrew.macintyre | 2006-08-06 14:37:03 +0200 (Sun, 06 Aug 2006) | 4 lines

  test_threading now skips testing alternate thread stack sizes on
  platforms that don't support changing thread stack size.
........
  r51134 | andrew.kuchling | 2006-08-07 00:07:04 +0200 (Mon, 07 Aug 2006) | 2 lines

  [Patch #1464056] Ensure that we use the panelw library when linking with ncursesw.
  Once I see how the buildbots react, I'll backport this to 2.4.
........
  r51137 | georg.brandl | 2006-08-08 13:52:34 +0200 (Tue, 08 Aug 2006) | 3 lines

  webbrowser: Silence stderr output if no gconftool or gnome browser found
........
  r51138 | georg.brandl | 2006-08-08 13:56:21 +0200 (Tue, 08 Aug 2006) | 7 lines

  Remove "non-mapping" and "non-sequence" from TypeErrors raised by
  PyMapping_Size and PySequence_Size.

  Because len() tries first sequence, then mapping size, it will always
  raise a "non-mapping object has no len" error which is confusing.
........
  r51139 | thomas.heller | 2006-08-08 19:37:00 +0200 (Tue, 08 Aug 2006) | 3 lines

  memcmp() can return values other than -1, 0, and +1 but tp_compare
  must not.
........
  r51140 | thomas.heller | 2006-08-08 19:39:20 +0200 (Tue, 08 Aug 2006) | 1 line

  Remove accidently committed, duplicated test.
........
  r51147 | andrew.kuchling | 2006-08-08 20:50:14 +0200 (Tue, 08 Aug 2006) | 1 line

  Reword paragraph to clarify
........
  r51148 | andrew.kuchling | 2006-08-08 20:56:08 +0200 (Tue, 08 Aug 2006) | 1 line

  Move obmalloc item into C API section
........
  r51149 | andrew.kuchling | 2006-08-08 21:00:14 +0200 (Tue, 08 Aug 2006) | 1 line

  'Other changes' section now has only one item; move the item elsewhere and remove the section
........
  r51150 | andrew.kuchling | 2006-08-08 21:00:34 +0200 (Tue, 08 Aug 2006) | 1 line

  Bump version number
........
  r51151 | georg.brandl | 2006-08-08 22:11:22 +0200 (Tue, 08 Aug 2006) | 2 lines

  Bug #1536828: typo: TypeType should have been StringType.
........
  r51153 | georg.brandl | 2006-08-08 22:13:13 +0200 (Tue, 08 Aug 2006) | 2 lines

  Bug #1536660: separate two words.
........
  r51155 | georg.brandl | 2006-08-08 22:48:10 +0200 (Tue, 08 Aug 2006) | 3 lines

  ``str`` is now the same object as ``types.StringType``.
........
  r51156 | tim.peters | 2006-08-09 02:52:26 +0200 (Wed, 09 Aug 2006) | 2 lines

  Whitespace normalization.
........
  r51158 | georg.brandl | 2006-08-09 09:03:22 +0200 (Wed, 09 Aug 2006) | 4 lines

  Introduce an upper bound on tuple nesting depth in
  C argument format strings; fixes rest of #1523610.
........
  r51160 | martin.v.loewis | 2006-08-09 09:57:39 +0200 (Wed, 09 Aug 2006) | 4 lines

  __hash__ may now return long int; the final hash
    value is obtained by invoking hash on the long int.
  Fixes #1536021.
........
  r51168 | andrew.kuchling | 2006-08-09 15:03:41 +0200 (Wed, 09 Aug 2006) | 1 line

  [Bug #1536021] Mention __hash__ change
........
  r51169 | andrew.kuchling | 2006-08-09 15:57:05 +0200 (Wed, 09 Aug 2006) | 1 line

  [Patch #1534027] Add notes on locale module changes
........
  r51170 | andrew.kuchling | 2006-08-09 16:05:35 +0200 (Wed, 09 Aug 2006) | 1 line

  Add missing 'self' parameters
........
  r51171 | andrew.kuchling | 2006-08-09 16:06:19 +0200 (Wed, 09 Aug 2006) | 1 line

  Reindent code
........
  r51172 | armin.rigo | 2006-08-09 16:55:26 +0200 (Wed, 09 Aug 2006) | 2 lines

  Fix and test for an infinite C recursion.
........
  r51173 | ronald.oussoren | 2006-08-09 16:56:33 +0200 (Wed, 09 Aug 2006) | 2 lines

  It's unlikely that future versions will require _POSIX_C_SOURCE
........
  r51178 | armin.rigo | 2006-08-09 17:37:26 +0200 (Wed, 09 Aug 2006) | 2 lines

  Concatenation on a long string breaks (SF #1526585).
........
  r51180 | kurt.kaiser | 2006-08-09 18:46:15 +0200 (Wed, 09 Aug 2006) | 8 lines

  1.  When used w/o subprocess, all exceptions were preceeded by an error
      message claiming they were IDLE internal errors (since 1.2a1).
  2.  Add Ronald Oussoren to CREDITS

  M    NEWS.txt
  M    PyShell.py
  M    CREDITS.txt
........
  r51181 | kurt.kaiser | 2006-08-09 19:47:15 +0200 (Wed, 09 Aug 2006) | 4 lines

  As a slight enhancement to the previous checkin, improve the
  internal error reporting by moving message to IDLE console.
........
  r51182 | andrew.kuchling | 2006-08-09 20:23:14 +0200 (Wed, 09 Aug 2006) | 1 line

  Typo fix
........
  r51183 | kurt.kaiser | 2006-08-09 22:34:46 +0200 (Wed, 09 Aug 2006) | 2 lines

  ToggleTab dialog was setting indent to 8 even if cancelled (since 1.2a1).
........
  r51184 | martin.v.loewis | 2006-08-10 01:42:18 +0200 (Thu, 10 Aug 2006) | 2 lines

  Add some commentary on -mimpure-text.
........
  r51185 | tim.peters | 2006-08-10 02:58:49 +0200 (Thu, 10 Aug 2006) | 2 lines

  Add missing svn:eol-style property to text files.
........
  r51186 | kurt.kaiser | 2006-08-10 03:41:17 +0200 (Thu, 10 Aug 2006) | 2 lines

  Changing tokenize (39046) to detect dedent broke tabnanny check (since 1.2a1)
........
  r51187 | tim.peters | 2006-08-10 05:01:26 +0200 (Thu, 10 Aug 2006) | 13 lines

  test_copytree_simple():  This was leaving behind two new temp
  directories each time it ran, at least on Windows.

  Several changes:  explicitly closed all files; wrapped long
  lines; stopped suppressing errors when removing a file or
  directory fails (removing /shouldn't/ fail!); and changed
  what appeared to be incorrect usage of os.removedirs() (that
  doesn't remove empty directories at and /under/ the given
  path, instead it must be given an empty leaf directory and
  then deletes empty directories moving /up/ the path -- could
  be that the conceptually simpler shutil.rmtree() was really
  actually intended here).
........
This commit is contained in:
Thomas Wouters 2006-08-11 14:57:12 +00:00
parent 3cf5b1eef9
commit 0e3f591aee
538 changed files with 19943 additions and 6323 deletions

View File

@ -190,6 +190,7 @@ Eddy Welbourne
Mats Wichmann
Gerry Wiener
Timothy Wild
Collin Winter
Blake Winton
Dan Wolfe
Steven Work

View File

@ -691,7 +691,7 @@ distlatex: bziplatex ziplatex
# The small amount of additional work is a small price to pay for not
# having to remember which order to do it in. ;)
paperdist: distpdf distps pkglist
edist: disthtml distinfo zipisilo pkglist
edist: disthtml pkglist
# The pkglist.html file is used as part of the download.html page on
# python.org; it is not used as intermediate input here or as part of

View File

@ -270,6 +270,7 @@ LIBFILES= $(MANSTYLES) $(INDEXSTYLES) $(COMMONTEX) \
lib/xmlsaxhandler.tex \
lib/xmlsaxutils.tex \
lib/xmlsaxreader.tex \
lib/libetree.tex \
lib/libqueue.tex \
lib/liblocale.tex \
lib/libgettext.tex \

View File

@ -48,11 +48,6 @@ code releases.}
\input{newtypes}
% \chapter{Debugging \label{debugging}}
%
% XXX Explain Py_DEBUG, Py_TRACE_REFS, Py_REF_DEBUG.
\appendix
\chapter{Reporting Bugs}
\input{reportingbugs}

View File

@ -31,7 +31,7 @@ This section describes Python type objects and the singleton object
\begin{cvardesc}{PyObject*}{PyType_Type}
This is the type object for type objects; it is the same object as
\code{types.TypeType} in the Python layer.
\code{type} and \code{types.TypeType} in the Python layer.
\withsubitem{(in module types)}{\ttindex{TypeType}}
\end{cvardesc}
@ -117,7 +117,8 @@ There is no \cfunction{PyNone_Check()} function for the same reason.
\begin{cvardesc}{PyTypeObject}{PyInt_Type}
This instance of \ctype{PyTypeObject} represents the Python plain
integer type. This is the same object as \code{types.IntType}.
integer type. This is the same object as \code{int} and
\code{types.IntType}.
\withsubitem{(in modules types)}{\ttindex{IntType}}
\end{cvardesc}
@ -260,7 +261,8 @@ booleans. The following macros are available, however.
\begin{cvardesc}{PyTypeObject}{PyLong_Type}
This instance of \ctype{PyTypeObject} represents the Python long
integer type. This is the same object as \code{types.LongType}.
integer type. This is the same object as \code{long} and
\code{types.LongType}.
\withsubitem{(in modules types)}{\ttindex{LongType}}
\end{cvardesc}
@ -376,7 +378,7 @@ booleans. The following macros are available, however.
\versionadded{2.3}
\end{cfuncdesc}
\begin{cfuncdesc}{unsigned long}{PyLong_AsUnsignedLongLongMask}{PyObject *io}
\begin{cfuncdesc}{unsigned PY_LONG_LONG}{PyLong_AsUnsignedLongLongMask}{PyObject *io}
Return a C \ctype{unsigned long long} from a Python long integer, without
checking for overflow.
\versionadded{2.3}
@ -411,7 +413,8 @@ booleans. The following macros are available, however.
\begin{cvardesc}{PyTypeObject}{PyFloat_Type}
This instance of \ctype{PyTypeObject} represents the Python floating
point type. This is the same object as \code{types.FloatType}.
point type. This is the same object as \code{float} and
\code{types.FloatType}.
\withsubitem{(in modules types)}{\ttindex{FloatType}}
\end{cvardesc}
@ -520,7 +523,8 @@ typedef struct {
\begin{cvardesc}{PyTypeObject}{PyComplex_Type}
This instance of \ctype{PyTypeObject} represents the Python complex
number type.
number type. It is the same object as \code{complex} and
\code{types.ComplexType}.
\end{cvardesc}
\begin{cfuncdesc}{int}{PyComplex_Check}{PyObject *p}
@ -580,8 +584,8 @@ parameter and are called with a non-string parameter.
\begin{cvardesc}{PyTypeObject}{PyString_Type}
This instance of \ctype{PyTypeObject} represents the Python string
type; it is the same object as \code{types.TypeType} in the Python
layer.
type; it is the same object as \code{str} and \code{types.StringType}
in the Python layer.
\withsubitem{(in module types)}{\ttindex{StringType}}.
\end{cvardesc}
@ -850,7 +854,8 @@ Please keep this in mind when writing extensions or interfaces.
\begin{cvardesc}{PyTypeObject}{PyUnicode_Type}
This instance of \ctype{PyTypeObject} represents the Python Unicode
type.
type. It is exposed to Python code as \code{unicode} and
\code{types.UnicodeType}.
\end{cvardesc}
The following APIs are really C macros and can be used to do fast
@ -1001,21 +1006,14 @@ use these APIs:
const char *errors}
Coerce an encoded object \var{obj} to an Unicode object and return a
reference with incremented refcount.
String and other char buffer compatible objects are decoded
according to the given encoding and using the error handling
defined by errors. Both can be \NULL{} to have the interface
use the default values (see the next section for details).
Coercion is done in the following way:
\begin{enumerate}
\item Unicode objects are passed back as-is with incremented
refcount. \note{These cannot be decoded; passing a non-\NULL{}
value for encoding will result in a \exception{TypeError}.}
\item String and other char buffer compatible objects are decoded
according to the given encoding and using the error handling
defined by errors. Both can be \NULL{} to have the interface
use the default values (see the next section for details).
\item All other objects cause an exception.
\end{enumerate}
All other objects, including Unicode objects, cause a
\exception{TypeError} to be set.
The API returns \NULL{} if there was an error. The caller is
responsible for decref'ing the returned objects.
@ -1431,6 +1429,18 @@ machine running the codec.
raised by the codec.
\end{cfuncdesc}
\begin{cfuncdesc}{PyObject*}{PyUnicode_DecodeMBCSStateful}{const char *s,
int size,
const char *errors,
int *consumed}
If \var{consumed} is \NULL{}, behave like
\cfunction{PyUnicode_DecodeMBCS()}. If \var{consumed} is not \NULL{},
\cfunction{PyUnicode_DecodeMBCSStateful()} will not decode trailing lead
byte and the number of bytes that have been decoded will be stored in
\var{consumed}.
\versionadded{2.5}
\end{cfuncdesc}
\begin{cfuncdesc}{PyObject*}{PyUnicode_EncodeMBCS}{const Py_UNICODE *s,
Py_ssize_t size,
const char *errors}
@ -1618,8 +1628,9 @@ format.
\begin{cvardesc}{PyTypeObject}{PyBuffer_Type}
The instance of \ctype{PyTypeObject} which represents the Python
buffer type; it is the same object as \code{types.BufferType} in the
Python layer.\withsubitem{(in module types)}{\ttindex{BufferType}}.
buffer type; it is the same object as \code{buffer} and
\code{types.BufferType} in the Python layer.
\withsubitem{(in module types)}{\ttindex{BufferType}}.
\end{cvardesc}
\begin{cvardesc}{int}{Py_END_OF_BUFFER}
@ -1693,8 +1704,8 @@ format.
\begin{cvardesc}{PyTypeObject}{PyTuple_Type}
This instance of \ctype{PyTypeObject} represents the Python tuple
type; it is the same object as \code{types.TupleType} in the Python
layer.\withsubitem{(in module types)}{\ttindex{TupleType}}.
type; it is the same object as \code{tuple} and \code{types.TupleType}
in the Python layer.\withsubitem{(in module types)}{\ttindex{TupleType}}.
\end{cvardesc}
\begin{cfuncdesc}{int}{PyTuple_Check}{PyObject *p}
@ -1790,8 +1801,8 @@ format.
\begin{cvardesc}{PyTypeObject}{PyList_Type}
This instance of \ctype{PyTypeObject} represents the Python list
type. This is the same object as \code{types.ListType}.
\withsubitem{(in module types)}{\ttindex{ListType}}
type. This is the same object as \code{list} and \code{types.ListType}
in the Python layer.\withsubitem{(in module types)}{\ttindex{ListType}}
\end{cvardesc}
\begin{cfuncdesc}{int}{PyList_Check}{PyObject *p}
@ -1919,7 +1930,7 @@ format.
\begin{cvardesc}{PyTypeObject}{PyDict_Type}
This instance of \ctype{PyTypeObject} represents the Python
dictionary type. This is exposed to Python programs as
\code{types.DictType} and \code{types.DictionaryType}.
\code{dict} and \code{types.DictType}.
\withsubitem{(in module types)}{\ttindex{DictType}\ttindex{DictionaryType}}
\end{cvardesc}
@ -2134,7 +2145,8 @@ implementation detail and may change in future releases of Python.
\begin{cvardesc}{PyTypeObject}{PyFile_Type}
This instance of \ctype{PyTypeObject} represents the Python file
type. This is exposed to Python programs as \code{types.FileType}.
type. This is exposed to Python programs as \code{file} and
\code{types.FileType}.
\withsubitem{(in module types)}{\ttindex{FileType}}
\end{cvardesc}
@ -2583,7 +2595,7 @@ They are found in the dictionary of type objects.
\begin{cvardesc}{PyTypeObject}{PySlice_Type}
The type object for slice objects. This is the same as
\code{types.SliceType}.
\code{slice} and \code{types.SliceType}.
\withsubitem{(in module types)}{\ttindex{SliceType}}
\end{cvardesc}

View File

@ -256,10 +256,14 @@ error indicator for each thread.
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
@ -291,6 +295,16 @@ error indicator for each thread.
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}

View File

@ -577,3 +577,59 @@ information about these functions is given in a later chapter.
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.

View File

@ -303,6 +303,11 @@ PyErr_Warn:int:::
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:::

View File

@ -5,5 +5,5 @@
Email: \email{docs@python.org}
}
\date{\today} % XXX update before final release!
\date{3rd August, 2006} % XXX update before final release!
\input{patchlevel} % include Python version information

27
Doc/dist/dist.tex vendored
View File

@ -530,7 +530,7 @@ If you need to include header files from some other Python extension,
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 @@ constructor
\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}
@ -2873,9 +2873,20 @@ C compiler:
\modulesynopsis{Microsoft Compiler}
This module provides \class{MSVCCompiler}, an implementation of the abstract
\class{CCompiler} class for Microsoft Visual Studio. It should also work using
the freely available compiler provided as part of the .Net SDK download. XXX
download link.
\class{CCompiler} class for Microsoft Visual Studio. Typically, extension
modules need to be compiled with the same compiler that was used to compile
Python. For Python 2.3 and earlier, the compiler was Visual Studio 6. For
Python 2.4 and 2.5, the compiler is Visual Studio .NET 2003. The AMD64
and Itanium binaries are created using the Platform SDK.
\class{MSVCCompiler} will normally choose the right compiler, linker etc.
on its own. To override this choice, the environment variables
\var{DISTUTILS\_USE\_SDK} and \var{MSSdk} must be both set. \var{MSSdk}
indicates that the current environment has been setup by the SDK's
\code{SetEnv.Cmd} script, or that the environment variables had been
registered when the SDK was installed; \var{DISTUTILS\_USE\_SDK} indicates
that the distutils user has made an explicit choice to override the
compiler selection by \class{MSVCCompiler}.
\section{\module{distutils.bcppcompiler} --- Borland Compiler}
\declaremodule{standard}{distutils.bcppcompiler}
@ -3088,7 +3099,7 @@ name of the output file, and \var{copied} is true if the file was copied
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}
@ -3131,7 +3142,7 @@ For non-\POSIX{} platforms, currently just returns \code{sys.platform}.
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.
@ -3180,7 +3191,7 @@ with \var{prefix}.
\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

View File

@ -187,6 +187,20 @@ text contributions are more than welcome as well.
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 @@ text contributions are more than welcome as well.
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

View File

@ -16,8 +16,9 @@ get started.
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 @@ this?
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 @@ eventually figure out that the list is garbage and free it.
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 @@ without setting an exception or it may set \exception{StopIteration};
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

View File

@ -28,13 +28,15 @@ Python; typically Microsoft Visual \Cpp.
\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.

View File

@ -1,88 +1,84 @@
# Makefile for the HOWTO directory
# LaTeX HOWTOs can be turned into HTML, PDF, PS, DVI or plain text output.
# reST HOWTOs can only be turned into HTML.
# Variables to change
# Paper size for non-HTML formats (letter or a4)
PAPER=letter
# Arguments to rst2html.py, and location of the script
RSTARGS = --input-encoding=utf-8
RST2HTML = rst2html.py
# List of HOWTOs that aren't to be processed. This should contain the
# base name of the HOWTO without any extension (e.g. 'advocacy',
# 'unicode').
REMOVE_HOWTOS =
MKHOWTO=../tools/mkhowto
WEBDIR=.
RSTARGS = --input-encoding=utf-8
VPATH=.:dvi:pdf:ps:txt
# List of HOWTOs that aren't to be processed
REMOVE_HOWTO =
PAPERDIR=../paper-$(PAPER)
HTMLDIR=../html
# Determine list of files to be built
TEX_SOURCES = $(wildcard *.tex)
RST_SOURCES = $(wildcard *.rst)
TEX_NAMES = $(filter-out $(REMOVE_HOWTOS),$(patsubst %.tex,%,$(TEX_SOURCES)))
HOWTO=$(filter-out $(REMOVE_HOWTO),$(wildcard *.tex))
RST_SOURCES = $(shell echo *.rst)
DVI =$(patsubst %.tex,%.dvi,$(HOWTO))
PDF =$(patsubst %.tex,%.pdf,$(HOWTO))
PS =$(patsubst %.tex,%.ps,$(HOWTO))
TXT =$(patsubst %.tex,%.txt,$(HOWTO))
HTML =$(patsubst %.tex,%,$(HOWTO))
PAPER_PATHS=$(addprefix $(PAPERDIR)/,$(TEX_NAMES))
DVI =$(addsuffix .dvi,$(PAPER_PATHS))
PDF =$(addsuffix .pdf,$(PAPER_PATHS))
PS =$(addsuffix .ps,$(PAPER_PATHS))
ALL_HOWTO_NAMES = $(TEX_NAMES) $(patsubst %.rst,%,$(RST_SOURCES))
HOWTO_NAMES = $(filter-out $(REMOVE_HOWTOS),$(ALL_HOWTO_NAMES))
HTML = $(addprefix $(HTMLDIR)/,$(HOWTO_NAMES))
# Rules for building various formats
%.dvi : %.tex
# reST to HTML
$(HTMLDIR)/%: %.rst
if [ ! -d $@ ] ; then mkdir $@ ; fi
$(RST2HTML) $(RSTARGS) $< >$@/index.html
# LaTeX to various output formats
$(PAPERDIR)/%.dvi : %.tex
$(MKHOWTO) --dvi $<
mv $@ dvi
mv $*.dvi $@
%.pdf : %.tex
$(PAPERDIR)/%.pdf : %.tex
$(MKHOWTO) --pdf $<
mv $@ pdf
mv $*.pdf $@
%.ps : %.tex
$(PAPERDIR)/%.ps : %.tex
$(MKHOWTO) --ps $<
mv $@ ps
mv $*.ps $@
%.txt : %.tex
$(HTMLDIR)/% : %.tex
$(MKHOWTO) --html --iconserver="." --dir $@ $<
# Rule that isn't actually used -- we no longer support the 'txt' target.
$(PAPERDIR)/%.txt : %.tex
$(MKHOWTO) --text $<
mv $@ txt
% : %.tex
$(MKHOWTO) --html --iconserver="." $<
tar -zcvf html/$*.tgz $*
#zip -r html/$*.zip $*
default:
@echo "'all' -- build all files"
@echo "'dvi', 'pdf', 'ps', 'txt', 'html' -- build one format"
@echo "'dvi', 'pdf', 'ps', 'html' -- build one format"
all: $(HTML)
all: dvi pdf ps html
.PHONY : dvi pdf ps txt html rst
dvi: $(DVI)
pdf: $(PDF)
ps: $(PS)
txt: $(TXT)
html:$(HTML)
# Rule to build collected tar files
dist: #all
for i in dvi pdf ps txt ; do \
cd $$i ; \
tar -zcf All.tgz *.$$i ;\
cd .. ;\
done
# Rule to copy files to the Web tree on AMK's machine
web: dist
cp dvi/* $(WEBDIR)/dvi
cp ps/* $(WEBDIR)/ps
cp pdf/* $(WEBDIR)/pdf
cp txt/* $(WEBDIR)/txt
for dir in $(HTML) ; do cp -rp $$dir $(WEBDIR) ; done
for ltx in $(HOWTO) ; do cp -p $$ltx $(WEBDIR)/latex ; done
rst: unicode.html
%.html: %.rst
rst2html $(RSTARGS) $< >$@
.PHONY : dvi pdf ps html
dvi: $(DVI)
pdf: $(PDF)
ps: $(PS)
html: $(HTML)
clean:
rm -f *~ *.log *.ind *.l2h *.aux *.toc *.how
rm -f *.dvi *.ps *.pdf *.bkm
rm -f unicode.html
rm -f *~ *.log *.ind *.l2h *.aux *.toc *.how *.bkm
rm -f *.dvi *.pdf *.ps
clobber:
rm dvi/* ps/* pdf/* txt/* html/*
rm -rf $(HTML)
rm -rf $(DVI) $(PDF) $(PS)

View File

@ -288,8 +288,9 @@ More useful functions in \module{os.path}: \function{basename},
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}

View File

@ -213,34 +213,39 @@ Assuming you don't want to end the connection, the simplest solution
is a fixed length message:
\begin{verbatim}
class mysocket:
'''demonstration class only
- coded for clarity, not efficiency'''
def __init__(self, sock=None):
if sock is None:
self.sock = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
else:
self.sock = sock
def connect(host, port):
self.sock.connect((host, port))
def mysend(msg):
totalsent = 0
while totalsent < MSGLEN:
sent = self.sock.send(msg[totalsent:])
if sent == 0:
raise RuntimeError, \\
"socket connection broken"
totalsent = totalsent + sent
def myreceive():
msg = ''
while len(msg) < MSGLEN:
chunk = self.sock.recv(MSGLEN-len(msg))
if chunk == '':
raise RuntimeError, \\
"socket connection broken"
msg = msg + chunk
return msg
class mysocket:
'''demonstration class only
- coded for clarity, not efficiency
'''
def __init__(self, sock=None):
if sock is None:
self.sock = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
else:
self.sock = sock
def connect(self, host, port):
self.sock.connect((host, port))
def mysend(self, msg):
totalsent = 0
while totalsent < MSGLEN:
sent = self.sock.send(msg[totalsent:])
if sent == 0:
raise RuntimeError, \\
"socket connection broken"
totalsent = totalsent + sent
def myreceive(self):
msg = ''
while len(msg) < MSGLEN:
chunk = self.sock.recv(MSGLEN-len(msg))
if chunk == '':
raise RuntimeError, \\
"socket connection broken"
msg = msg + chunk
return msg
\end{verbatim}
The sending code here is usable for almost any messaging scheme - in

View File

@ -262,7 +262,7 @@ If you don't choose an installation directory---i.e., if you just run
\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}%

View File

@ -105,7 +105,7 @@ of the package.
\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 @@ Here are the major differences between \module{email} verson 4 and version 3:
\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:

View File

@ -31,11 +31,11 @@ Optional \var{mangle_from_} is a flag that, when \code{True}, puts a
\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

View File

@ -71,12 +71,12 @@ and how to embed it in other applications.
% 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 @@ and how to embed it in other applications.
% encoding stuff
\input{libbase64}
\input{libbinascii}
\input{libbinhex}
\input{libbinascii}
\input{libquopri}
\input{libuu}
@ -171,6 +171,7 @@ and how to embed it in other applications.
\input{xmlsaxhandler}
\input{xmlsaxutils}
\input{xmlsaxreader}
\input{libetree}
% \input{libxmllib}
\input{fileformats} % Miscellaneous file formats
@ -245,7 +246,6 @@ and how to embed it in other applications.
\input{libplatform}
\input{liberrno}
\input{libctypes}
\input{libctypesref}
\input{libsomeos} % Optional Operating System Services
\input{libselect}
@ -292,6 +292,7 @@ and how to embed it in other applications.
\input{libwebbrowser}
\input{libcgi}
\input{libcgitb}
\input{libwsgiref}
\input{liburllib}
\input{liburllib2}
\input{libhttplib}
@ -303,6 +304,7 @@ and how to embed it in other applications.
\input{libsmtplib}
\input{libsmtpd}
\input{libtelnetlib}
\input{libuuid}
\input{liburlparse}
\input{libsocksvr}
\input{libbasehttp}

View File

@ -46,6 +46,32 @@ be stored, retrieved, and deleted, and the \method{has_key()} and
\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.}

View File

@ -146,6 +146,18 @@ string containing one or more lines of base64-encoded data
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.}

View File

@ -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:

View File

@ -13,23 +13,29 @@ using the appropriate open call. Bsddb objects behave generally like
dictionaries. Keys and values must be strings, however, so to use
other objects as keys or to store other kinds of objects the user must
serialize them somehow, typically using \function{marshal.dumps()} or
\function{pickle.dumps}.
\function{pickle.dumps()}.
The \module{bsddb} module requires a Berkeley DB library version from
3.3 thru 4.4.
\begin{seealso}
\seeurl{http://pybsddb.sourceforge.net/}{Website with documentation
for the new python Berkeley DB interface that closely mirrors the
sleepycat object oriented interface provided in Berkeley DB 3 and 4.}
\seeurl{http://pybsddb.sourceforge.net/}{The website with documentation
for the \module{bsddb.db} python Berkeley DB interface that closely mirrors
the Sleepycat object oriented interface provided in Berkeley DB 3 and 4.}
\seeurl{http://www.sleepycat.com/}{Sleepycat Software produces the
modern Berkeley DB library.}
Berkeley DB library.}
\end{seealso}
A more modern DB, DBEnv and DBSequence object interface is available in the
\module{bsddb.db} module which closely matches the Sleepycat Berkeley DB C API
documented at the above URLs. Additional features provided by the
\module{bsddb.db} API include fine tuning, transactions, logging, and
multiprocess concurrent database access.
The following is a description of the legacy \module{bsddb} interface
compatible with the old python bsddb module. For details about the more
modern Db and DbEnv object oriented interface see the above mentioned
pybsddb URL.
compatible with the old python bsddb module. Starting in Python 2.5 this
interface should be safe for multithreaded access. The \module{bsddb.db}
API is recommended for threading users as it provides better control.
The \module{bsddb} module defines the following functions that create
objects that access the appropriate type of Berkeley DB file. The
@ -88,7 +94,7 @@ interpretation.
\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.

View File

@ -44,6 +44,19 @@ compile Python sources in directories named on the command line or in
\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.}

View File

@ -24,7 +24,7 @@ Internet are Netscape cookies. \module{cookielib} attempts to follow
the de-facto Netscape cookie protocol (which differs substantially
from that set out in the original Netscape specification), including
taking note of the \code{max-age} and \code{port} cookie-attributes
introduced with RFC 2109. \note{The various named parameters found in
introduced with RFC 2965. \note{The various named parameters found in
\mailheader{Set-Cookie} and \mailheader{Set-Cookie2} headers
(eg. \code{domain} and \code{expires}) are conventionally referred to
as \dfn{attributes}. To distinguish them from Python attributes, the

View File

@ -55,7 +55,7 @@ The \module{csv} module defines the following functions:
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 @@ Parameters'' for details of these parameters.
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 @@ csv.register_dialect('unixpwd', delimiter=':', quoting=csv.QUOTE_NONE)
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

File diff suppressed because it is too large Load Diff

View File

@ -1,457 +0,0 @@
\subsection{ctypes reference\label{ctypes-reference}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% functions
\subsubsection{ctypes functions}
\begin{funcdesc}{addressof}{obj}
Returns the address of the memory buffer as integer. \var{obj} must
be an instance of a ctypes type.
\end{funcdesc}
\begin{funcdesc}{alignment}{obj_or_type}
Returns the alignment requirements of a ctypes type.
\var{obj_or_type} must be a ctypes type or an instance.
\end{funcdesc}
\begin{excclassdesc}{ArgumentError}{}
This exception is raised when a foreign function call cannot convert
one of the passed arguments.
\end{excclassdesc}
\begin{funcdesc}{byref}{obj}
Returns a light-weight pointer to \var{obj}, which must be an instance
of a ctypes type. The returned object can only be used as a foreign
function call parameter. It behaves similar to \code{pointer(obj)},
but the construction is a lot faster.
\end{funcdesc}
\begin{funcdesc}{cast}{obj, type}
This function is similar to the cast operator in C. It returns a new
instance of \var{type} which points to the same memory block as
\code{obj}. \code{type} must be a pointer type, and \code{obj}
must be an object that can be interpreted as a pointer.
\end{funcdesc}
% XXX separate section for CFUNCTYPE, WINFUNCTYPE, PYFUNCTYPE?
\begin{funcdesc}{CFUNCTYPE}{restype, *argtypes}
This is a factory function that returns a function prototype. The
function prototype describes a function that has a result type of
\code{restype}, and accepts arguments as specified by \code{argtypes}.
The function prototype can be used to construct several kinds of
functions, depending on how the prototype is called.
The prototypes returned by \code{CFUNCTYPE} or \code{PYFUNCTYPE}
create functions that use the standard C calling convention,
prototypes returned from \code{WINFUNCTYPE} (on Windows) use the
\code{__stdcall} calling convention.
Functions created by calling the \code{CFUNCTYPE} and
\code{WINFUNCTYPE} prototypes release the Python GIL
before entering the foreign function, and acquire it back after
leaving the function code.
% XXX differences between CFUNCTYPE / WINFUNCTYPE / PYFUNCTYPE
\end{funcdesc}
\begin{funcdesc}{create_string_buffer}{init_or_size\optional{, size}}
This function creates a mutable character buffer. The returned object
is a ctypes array of \code{c_char}.
\var{init_or_size} must be an integer which specifies the size of the
array, or a string which will be used to initialize the array items.
If a string is specified as first argument, the buffer is made one
item larger than the length of the string so that the last element in
the array is a NUL termination character. An integer can be passed as
second argument which allows to specify the size of the array if the
length of the string should not be used.
If the first parameter is a unicode string, it is converted into an
8-bit string according to ctypes conversion rules.
\end{funcdesc}
\begin{funcdesc}{create_unicode_buffer}{init_or_size\optional{, size}}
This function creates a mutable unicode character buffer. The
returned object is a ctypes array of \code{c_wchar}.
\var{init_or_size} must be an integer which specifies the size of the
array, or a unicode string which will be used to initialize the array
items.
If a unicode string is specified as first argument, the buffer is made
one item larger than the length of the string so that the last element
in the array is a NUL termination character. An integer can be passed
as second argument which allows to specify the size of the array if
the length of the string should not be used.
If the first parameter is a 8-bit string, it is converted into an
unicode string according to ctypes conversion rules.
\end{funcdesc}
\begin{funcdesc}{DllCanUnloadNow}{}
Windows only: This function is a hook which allows to implement
inprocess COM servers with ctypes. It is called from the
\code{DllCanUnloadNow} function that the \code{_ctypes}
extension dll exports.
\end{funcdesc}
\begin{funcdesc}{DllGetClassObject}{}
Windows only: This function is a hook which allows to implement
inprocess COM servers with ctypes. It is called from the
\code{DllGetClassObject} function that the \code{_ctypes}
extension dll exports.
\end{funcdesc}
\begin{funcdesc}{FormatError}{\optional{code}}
Windows only: Returns a textual description of the error code. If no
error code is specified, the last error code is used by calling the
Windows api function \code{GetLastError}.
\end{funcdesc}
\begin{funcdesc}{GetLastError}{}
Windows only: Returns the last error code set by Windows in the
calling thread.
\end{funcdesc}
\begin{funcdesc}{memmove}{dst, src, count}
Same as the standard C \code{memmove} library function: copies
\var{count} bytes from \code{src} to \code{dst}. \code{dst} and
\code{src} must be integers or ctypes instances that can be converted to pointers.
\end{funcdesc}
\begin{funcdesc}{memset}{dst, c, count}
Same as the standard C \code{memset} library function: fills the
memory clock at address \code{dst} with \var{count} bytes of value
\var{c}. \var{dst} must be an integer specifying an address, or a ctypes instance.
\end{funcdesc}
\begin{funcdesc}{POINTER}{type}
This factory function creates and returns a new ctypes pointer type.
Pointer types are cached an reused internally, so calling this
function repeatedly is cheap. \var{type} must be a ctypes type.
\end{funcdesc}
\begin{funcdesc}{pointer}{obj}
This function creates a new pointer instance, pointing to \var{obj}.
The returned object is of the type \code{POINTER(type(obj))}.
Note: If you just want to pass a pointer to an object to a foreign
function call, you should use \code{byref(obj)} which is much faster.
\end{funcdesc}
\begin{funcdesc}{PYFUNCTYPE}{restype, *argtypes}
\end{funcdesc}
\begin{funcdesc}{pythonapi}{}
\end{funcdesc}
\begin{funcdesc}{resize}{obj, size}
This function resizes the internal memory buffer of \var{obj}, which
must be an instance of a ctypes type. It is not possible to make the
buffer smaller than the native size of the objects type, as given by
\code{sizeof(type(obj))}, but it is possible to enlarge the buffer.
\end{funcdesc}
\begin{funcdesc}{set_conversion_mode}{encoding, errors}
This function sets the rules that ctypes objects use when converting
between 8-bit strings and unicode strings. \var{encoding} must be a
string specifying an encoding, like 'utf-8' or 'mbcs', \var{errors}
must be a string specifying the error handling on encoding/decoding
errors. Examples of possible values are ``strict'', ``replace'', or
``ignore''.
\code{set_conversion_mode} returns a 2-tuple containing the previous
conversion rules. On windows, the initial conversion rules are
\code{('mbcs', 'ignore')}, on other systems \code{('ascii', 'strict')}.
\end{funcdesc}
\begin{funcdesc}{sizeof}{obj_or_type}
Returns the size in bytes of a ctypes type or instance memory buffer.
Does the same as the C sizeof() function.
\end{funcdesc}
\begin{funcdesc}{string_at}{address\optional{size}}
This function returns the string starting at memory address
\var{address}. If \var{size} is specified, it is used as size,
otherwise the string is assumed to be zero-terminated.
\end{funcdesc}
\begin{funcdesc}{WinError}{code=None, descr=None}
Windows only: this function is probably the worst-named thing in
ctypes. It creates an instance of \code{WindowsError}. If \var{code}
is not specified, \code{GetLastError} is called to determine the error
code. If \var{descr} is not spcified, \var{FormatError} is called to
get a textual description of the error.
\end{funcdesc}
\begin{funcdesc}{WINFUNCTYPE}{restype, *argtypes}
\end{funcdesc}
\begin{funcdesc}{wstring_at}{address}
This function returns the wide character string starting at memory
address \var{address} as unicode string. If \var{size} is specified,
it is used as size, otherwise the string is assumed to be
zero-terminated.
\end{funcdesc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% data types
\subsubsection{data types}
ctypes defines a lot of C compatible datatypes, and also allows to
define your own types. Among other things, a ctypes type instance
holds a memory block that contains C compatible data.
\begin{classdesc}{_ctypes._CData}{}
This non-public class is the base class of all ctypes data types. It
is mentioned here because it contains the common methods of the ctypes
data types.
\end{classdesc}
Common methods of ctypes data types, these are all class methods (to
be exact, they are methods of the metaclass):
\begin{methoddesc}{from_address}{address}
This method returns a ctypes type instance using the memory specified
by \code{address}.
\end{methoddesc}
\begin{methoddesc}{from_param}{obj}
This method adapts \code{obj} to a ctypes type.
\end{methoddesc}
\begin{methoddesc}{in_dll}{name, library}
This method returns a ctypes type instance exported by a shared
library. \var{name} is the name of the symbol that exports the data,
\var{library} is the loaded shared library.
\end{methoddesc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% simple data types
\subsubsection{simple data types}
\begin{classdesc}{_ctypes._SimpleCData}{}
This non-public class is the base class of all ctypes data types. It
is mentioned here because it contains the common attributes of the
ctypes data types.
\end{classdesc}
\begin{memberdesc}{value}
This attribute contains the actual value of the instance. For integer
types, it is an integer.
\end{memberdesc}
Here are the simple ctypes data types:
\begin{classdesc}{c_byte}{\optional{value}}
Represents a C \code{signed char} datatype, and interprets the value
as small integer. The constructor accepts an optional integer
initializer; no overflow checking is done.
\end{classdesc}
\begin{classdesc}{c_char}{\optional{value}}
Represents a C \code{char} datatype, and interprets the value as a
single character. The constructor accepts an optional string
initializer, the length of the string must be exactly one character.
\end{classdesc}
\begin{classdesc}{c_char_p}{\optional{value}}
Represents a C \code{char *} datatype, which must be a pointer to a
zero-terminated string. The constructor accepts an integer address,
or a string.
% XXX Explain the difference to POINTER(c_char)
\end{classdesc}
\begin{classdesc}{c_double}{\optional{value}}
Represents a C \code{double} datatype. The constructor accepts an
optional float initializer.
\end{classdesc}
\begin{classdesc}{c_float}{\optional{value}}
Represents a C \code{double} datatype. The constructor accepts an
optional float initializer.
\end{classdesc}
\begin{classdesc}{c_int}{\optional{value}}
Represents a C \code{signed int} datatype. The constructor accepts an
optional integer initializer; no overflow checking is done. On
platforms where \code{sizeof(int) == sizeof(long)} \var{c_int} is an
alias to \var{c_long}.
\end{classdesc}
\begin{classdesc}{c_int16}{\optional{value}}
Represents a C 16-bit \code{signed int} datatype. Usually an alias
for \var{c_short}.
\end{classdesc}
\begin{classdesc}{c_int32}{\optional{value}}
Represents a C 32-bit \code{signed int} datatype. Usually an alias
for \code{c_int}.
\end{classdesc}
\begin{classdesc}{c_int64}{\optional{value}}
Represents a C 64-bit \code{signed int} datatype. Usually an alias
for \code{c_longlong}.
\end{classdesc}
\begin{classdesc}{c_int8}{\optional{value}}
Represents a C 8-bit \code{signed int} datatype. Usually an alias for \code{c_byte}.
\end{classdesc}
\begin{classdesc}{c_long}{\optional{value}}
Represents a C \code{signed long} datatype. The constructor accepts
an optional integer initializer; no overflow checking is done.
\end{classdesc}
\begin{classdesc}{c_longlong}{\optional{value}}
Represents a C \code{signed long long} datatype. The constructor
accepts an optional integer initializer; no overflow checking is done.
\end{classdesc}
\begin{classdesc}{c_short}{\optional{value}}
Represents a C \code{signed short} datatype. The constructor accepts
an optional integer initializer; no overflow checking is done.
\end{classdesc}
\begin{classdesc}{c_size_t}{\optional{value}}
Represents a C \code{size_t} datatype.
\end{classdesc}
\begin{classdesc}{c_ubyte}{\optional{value}}
Represents a C \code{unsigned char} datatype, and interprets the value
as small integer. The constructor accepts an optional integer
initializer; no overflow checking is done.
\end{classdesc}
\begin{classdesc}{c_uint}{\optional{value}}
Represents a C \code{unsigned int} datatype. The constructor accepts
an optional integer initializer; no overflow checking is done. On
platforms where \code{sizeof(int) == sizeof(long)} \var{c_int} is an
alias to \var{c_long}.
\end{classdesc}
\begin{classdesc}{c_uint16}{\optional{value}}
Represents a C 16-bit \code{unsigned int} datatype. Usually an alias
for \code{c_ushort}.
\end{classdesc}
\begin{classdesc}{c_uint32}{\optional{value}}
Represents a C 32-bit \code{unsigned int} datatype. Usually an alias
for \code{c_uint}.
\end{classdesc}
\begin{classdesc}{c_uint64}{\optional{value}}
Represents a C 64-bit \code{unsigned int} datatype. Usually an alias
for \code{c_ulonglong}.
\end{classdesc}
\begin{classdesc}{c_uint8}{\optional{value}}
Represents a C 8-bit \code{unsigned int} datatype. Usually an alias
for \code{c_ubyte}.
\end{classdesc}
\begin{classdesc}{c_ulong}{\optional{value}}
Represents a C \code{unsigned long} datatype. The constructor accepts
an optional integer initializer; no overflow checking is done.
\end{classdesc}
\begin{classdesc}{c_ulonglong}{\optional{value}}
Represents a C \code{unsigned long long} datatype. The constructor
accepts an optional integer initializer; no overflow checking is done.
\end{classdesc}
\begin{classdesc}{c_ushort}{\optional{value}}
Represents a C \code{unsigned short} datatype. The constructor accepts
an optional integer initializer; no overflow checking is done.
\end{classdesc}
\begin{classdesc}{c_void_p}{\optional{value}}
Represents a C \code{void *} type. The value is represented as
integer. The constructor accepts an optional integer initializer.
\end{classdesc}
\begin{classdesc}{c_wchar}{\optional{value}}
Represents a C \code{wchar_t} datatype, and interprets the value as a
single character unicode string. The constructor accepts an optional
string initializer, the length of the string must be exactly one
character.
\end{classdesc}
\begin{classdesc}{c_wchar_p}{\optional{value}}
Represents a C \code{wchar_t *} datatype, which must be a pointer to a
zero-terminated wide character string. The constructor accepts an
integer address, or a string.
% XXX Explain the difference to POINTER(c_wchar)
\end{classdesc}
\begin{classdesc}{HRESULT}{}
Windows only: Represents a \code{HRESULT} value, which contains
success or error information for a function or method call.
\end{classdesc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% structured data types
\subsubsection{structured data types}
\begin{classdesc}{BigEndianStructure}{}
\end{classdesc}
\begin{classdesc}{LittleEndianStructure}{}
\end{classdesc}
\begin{classdesc}{Structure}{}
Base class for Structure data types.
\end{classdesc}
\begin{classdesc}{Union}{}
\end{classdesc}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% libraries
\subsubsection{libraries}
\begin{classdesc}{CDLL}{name, mode=RTLD_LOCAL, handle=None}
\end{classdesc}
\begin{datadesc}{cdll}
\end{datadesc}
\begin{classdesc}{LibraryLoader}{dlltype}
\begin{memberdesc}{LoadLibrary}{name, mode=RTLD_LOCAL, handle=None}
\end{memberdesc}
\end{classdesc}
\begin{classdesc}{OleDLL}{name, mode=RTLD_LOCAL, handle=None}
\end{classdesc}
\begin{datadesc}{oledll}
\end{datadesc}
\begin{classdesc}{py_object}{}
\end{classdesc}
\begin{classdesc}{PyDLL}{name, mode=RTLD_LOCAL, handle=None}
\end{classdesc}
\begin{datadesc}{pydll}{}
\end{datadesc}
\begin{datadesc}{RTLD_GLOBAL}
\end{datadesc}
\begin{datadesc}{RTLD_LOCAL}
\end{datadesc}
\begin{classdesc}{WinDLL}{name, mode=RTLD_LOCAL, handle=None}
\end{classdesc}
\begin{datadesc}{windll}
\end{datadesc}

View File

@ -419,6 +419,16 @@ of the other sequences.
len(\var{b}), 0)}. It is the only triple with \code{\var{n} == 0}.
% Explain why a dummy is used!
If
\code{(\var{i}, \var{j}, \var{n})} and
\code{(\var{i'}, \var{j'}, \var{n'})} are adjacent triples in the list,
and the second is not the last triple in the list, then
\code{\var{i}+\var{n} != \var{i'}} or
\code{\var{j}+\var{n} != \var{j'}}; in other words, adjacent triples
always describe non-adjacent equal blocks.
\versionchanged[The guarantee that adjacent triples always describe
non-adjacent blocks was implemented]{2.5}
\begin{verbatim}
>>> s = SequenceMatcher(None, "abxcd", "abcd")
>>> s.get_matching_blocks()

367
Doc/lib/libetree.tex Normal file
View File

@ -0,0 +1,367 @@
\section{\module{elementtree} --- The xml.etree.ElementTree Module}
\declaremodule{standard}{elementtree}
\moduleauthor{Fredrik Lundh}{fredrik@pythonware.com}
\modulesynopsis{This module provides implementations
of the Element and ElementTree types, plus support classes.
A C version of this API is available as xml.etree.cElementTree.}
\versionadded{2.5}
\subsection{Overview\label{elementtree-overview}}
The Element type is a flexible container object, designed to store
hierarchical data structures in memory. The type can be described as a
cross between a list and a dictionary.
Each element has a number of properties associated with it:
\begin{itemize}
\item {}
a tag which is a string identifying what kind of data
this element represents (the element type, in other words).
\item {}
a number of attributes, stored in a Python dictionary.
\item {}
a text string.
\item {}
an optional tail string.
\item {}
a number of child elements, stored in a Python sequence
\end{itemize}
To create an element instance, use the Element or SubElement factory
functions.
The ElementTree class can be used to wrap an element
structure, and convert it from and to XML.
\subsection{Functions\label{elementtree-functions}}
\begin{funcdesc}{Comment}{\optional{text}}
Comment element factory. This factory function creates a special
element that will be serialized as an XML comment.
The comment string can be either an 8-bit ASCII string or a Unicode
string.
\var{text} is a string containing the comment string.
\begin{datadescni}{Returns:}
An element instance, representing a comment.
\end{datadescni}
\end{funcdesc}
\begin{funcdesc}{dump}{elem}
Writes an element tree or element structure to sys.stdout. This
function should be used for debugging only.
The exact output format is implementation dependent. In this
version, it's written as an ordinary XML file.
\var{elem} is an element tree or an individual element.
\end{funcdesc}
\begin{funcdesc}{Element}{tag\optional{, attrib}\optional{, **extra}}
Element factory. This function returns an object implementing the
standard Element interface. The exact class or type of that object
is implementation dependent, but it will always be compatible with
the {\_}ElementInterface class in this module.
The element name, attribute names, and attribute values can be
either 8-bit ASCII strings or Unicode strings.
\var{tag} is the element name.
\var{attrib} is an optional dictionary, containing element attributes.
\var{extra} contains additional attributes, given as keyword arguments.
\begin{datadescni}{Returns:}
An element instance.
\end{datadescni}
\end{funcdesc}
\begin{funcdesc}{fromstring}{text}
Parses an XML section from a string constant. Same as XML.
\var{text} is a string containing XML data.
\begin{datadescni}{Returns:}
An Element instance.
\end{datadescni}
\end{funcdesc}
\begin{funcdesc}{iselement}{element}
Checks if an object appears to be a valid element object.
\var{element} is an element instance.
\begin{datadescni}{Returns:}
A true value if this is an element object.
\end{datadescni}
\end{funcdesc}
\begin{funcdesc}{iterparse}{source\optional{, events}}
Parses an XML section into an element tree incrementally, and reports
what's going on to the user.
\var{source} is a filename or file object containing XML data.
\var{events} is a list of events to report back. If omitted, only ``end''
events are reported.
\begin{datadescni}{Returns:}
A (event, elem) iterator.
\end{datadescni}
\end{funcdesc}
\begin{funcdesc}{parse}{source\optional{, parser}}
Parses an XML section into an element tree.
\var{source} is a filename or file object containing XML data.
\var{parser} is an optional parser instance. If not given, the
standard XMLTreeBuilder parser is used.
\begin{datadescni}{Returns:}
An ElementTree instance
\end{datadescni}
\end{funcdesc}
\begin{funcdesc}{ProcessingInstruction}{target\optional{, text}}
PI element factory. This factory function creates a special element
that will be serialized as an XML processing instruction.
\var{target} is a string containing the PI target.
\var{text} is a string containing the PI contents, if given.
\begin{datadescni}{Returns:}
An element instance, representing a PI.
\end{datadescni}
\end{funcdesc}
\begin{funcdesc}{SubElement}{parent, tag\optional{, attrib} \optional{, **extra}}
Subelement factory. This function creates an element instance, and
appends it to an existing element.
The element name, attribute names, and attribute values can be
either 8-bit ASCII strings or Unicode strings.
\var{parent} is the parent element.
\var{tag} is the subelement name.
\var{attrib} is an optional dictionary, containing element attributes.
\var{extra} contains additional attributes, given as keyword arguments.
\begin{datadescni}{Returns:}
An element instance.
\end{datadescni}
\end{funcdesc}
\begin{funcdesc}{tostring}{element\optional{, encoding}}
Generates a string representation of an XML element, including all
subelements.
\var{element} is an Element instance.
\var{encoding} is the output encoding (default is US-ASCII).
\begin{datadescni}{Returns:}
An encoded string containing the XML data.
\end{datadescni}
\end{funcdesc}
\begin{funcdesc}{XML}{text}
Parses an XML section from a string constant. This function can
be used to embed ``XML literals'' in Python code.
\var{text} is a string containing XML data.
\begin{datadescni}{Returns:}
An Element instance.
\end{datadescni}
\end{funcdesc}
\begin{funcdesc}{XMLID}{text}
Parses an XML section from a string constant, and also returns
a dictionary which maps from element id:s to elements.
\var{text} is a string containing XML data.
\begin{datadescni}{Returns:}
A tuple containing an Element instance and a dictionary.
\end{datadescni}
\end{funcdesc}
\subsection{ElementTree Objects\label{elementtree-elementtree-objects}}
\begin{classdesc}{ElementTree}{\optional{element,} \optional{file}}
ElementTree wrapper class. This class represents an entire element
hierarchy, and adds some extra support for serialization to and from
standard XML.
\var{element} is the root element.
The tree is initialized with the contents of the XML \var{file} if given.
\end{classdesc}
\begin{methoddesc}{_setroot}{element}
Replaces the root element for this tree. This discards the
current contents of the tree, and replaces it with the given
element. Use with care.
\var{element} is an element instance.
\end{methoddesc}
\begin{methoddesc}{find}{path}
Finds the first toplevel element with given tag.
Same as getroot().find(path).
\var{path} is the element to look for.
\begin{datadescni}{Returns:}
The first matching element, or None if no element was found.
\end{datadescni}
\end{methoddesc}
\begin{methoddesc}{findall}{path}
Finds all toplevel elements with the given tag.
Same as getroot().findall(path).
\var{path} is the element to look for.
\begin{datadescni}{Returns:}
A list or iterator containing all matching elements,
in section order.
\end{datadescni}
\end{methoddesc}
\begin{methoddesc}{findtext}{path\optional{, default}}
Finds the element text for the first toplevel element with given
tag. Same as getroot().findtext(path).
\var{path} is the toplevel element to look for.
\var{default} is the value to return if the element was not found.
\begin{datadescni}{Returns:}
The text content of the first matching element, or the
default value no element was found. Note that if the element
has is found, but has no text content, this method returns an
empty string.
\end{datadescni}
\end{methoddesc}
\begin{methoddesc}{getiterator}{\optional{tag}}
Creates a tree iterator for the root element. The iterator loops
over all elements in this tree, in section order.
\var{tag} is the tag to look for (default is to return all elements)
\begin{datadescni}{Returns:}
An iterator.
\end{datadescni}
\end{methoddesc}
\begin{methoddesc}{getroot}{}
Gets the root element for this tree.
\begin{datadescni}{Returns:}
An element instance.
\end{datadescni}
\end{methoddesc}
\begin{methoddesc}{parse}{source\optional{, parser}}
Loads an external XML section into this element tree.
\var{source} is a file name or file object.
\var{parser} is an optional parser instance. If not given, the
standard XMLTreeBuilder parser is used.
\begin{datadescni}{Returns:}
The section root element.
\end{datadescni}
\end{methoddesc}
\begin{methoddesc}{write}{file\optional{, encoding}}
Writes the element tree to a file, as XML.
\var{file} is a file name, or a file object opened for writing.
\var{encoding} is the output encoding (default is US-ASCII).
\end{methoddesc}
\subsection{QName Objects\label{elementtree-qname-objects}}
\begin{classdesc}{QName}{text_or_uri\optional{, tag}}
QName wrapper. This can be used to wrap a QName attribute value, in
order to get proper namespace handling on output.
\var{text_or_uri} is a string containing the QName value,
in the form {\{}uri{\}}local, or, if the tag argument is given,
the URI part of a QName.
If \var{tag} is given, the first argument is interpreted as
an URI, and this argument is interpreted as a local name.
\begin{datadescni}{Returns:}
An opaque object, representing the QName.
\end{datadescni}
\end{classdesc}
\subsection{TreeBuilder Objects\label{elementtree-treebuilder-objects}}
\begin{classdesc}{TreeBuilder}{\optional{element_factory}}
Generic element structure builder. This builder converts a sequence
of start, data, and end method calls to a well-formed element structure.
You can use this class to build an element structure using a custom XML
parser, or a parser for some other XML-like format.
The \var{element_factory} is called to create new Element instances when
given.
\end{classdesc}
\begin{methoddesc}{close}{}
Flushes the parser buffers, and returns the toplevel documen
element.
\begin{datadescni}{Returns:}
An Element instance.
\end{datadescni}
\end{methoddesc}
\begin{methoddesc}{data}{data}
Adds text to the current element.
\var{data} is a string. This should be either an 8-bit string
containing ASCII text, or a Unicode string.
\end{methoddesc}
\begin{methoddesc}{end}{tag}
Closes the current element.
\var{tag} is the element name.
\begin{datadescni}{Returns:}
The closed element.
\end{datadescni}
\end{methoddesc}
\begin{methoddesc}{start}{tag, attrs}
Opens a new element.
\var{tag} is the element name.
\var{attrs} is a dictionary containing element attributes.
\begin{datadescni}{Returns:}
The opened element.
\end{datadescni}
\end{methoddesc}
\subsection{XMLTreeBuilder Objects\label{elementtree-xmltreebuilder-objects}}
\begin{classdesc}{XMLTreeBuilder}{\optional{html,} \optional{target}}
Element structure builder for XML source data, based on the
expat parser.
\var{html} are predefined HTML entities. This flag is not supported
by the current implementation.
\var{target} is the target object. If omitted, the builder uses an
instance of the standard TreeBuilder class.
\end{classdesc}
\begin{methoddesc}{close}{}
Finishes feeding data to the parser.
\begin{datadescni}{Returns:}
An element structure.
\end{datadescni}
\end{methoddesc}
\begin{methoddesc}{doctype}{name, pubid, system}
Handles a doctype declaration.
\var{name} is the doctype name.
\var{pubid} is the public identifier.
\var{system} is the system identifier.
\end{methoddesc}
\begin{methoddesc}{feed}{data}
Feeds data to the parser.
\var{data} is encoded data.
\end{methoddesc}

View File

@ -401,77 +401,27 @@ class C:
\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}
Construct a list from those elements of \var{list} for which
\var{function} returns true. \var{list} may be either a sequence, a
container which supports iteration, or an iterator, If \var{list}
is a string or a tuple, the result also has that type; otherwise it
is always a list. If \var{function} is \code{None}, the identity
function is assumed, that is, all elements of \var{list} that are false
(zero or empty) are removed.
is a string or a tuple, the result
also has that type; otherwise it is always a list. If \var{function} is
\code{None}, the identity function is assumed, that is, all elements of
\var{list} that are false are removed.
Note that \code{filter(function, \var{list})} is equivalent to
\code{[item for item in \var{list} if function(item)]} if function is
@ -709,10 +659,71 @@ class C:
\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}
@ -764,15 +775,30 @@ class C:
\begin{verbatim}
class C(object):
def __init__(self): self.__x = None
def getx(self): return self.__x
def setx(self, value): self.__x = value
def delx(self): del self.__x
def getx(self): return self._x
def setx(self, value): self._x = value
def delx(self): del self._x
x = property(getx, setx, delx, "I'm the 'x' property.")
\end{verbatim}
If given, \var{doc} will be the docstring of the property attribute.
Otherwise, the property will copy \var{fget}'s docstring (if it
exists).
exists). This makes it possible to create read-only properties
easily using \function{property()} as a decorator:
\begin{verbatim}
class Parrot(object):
def __init__(self):
self._voltage = 100000
@property
def voltage(self):
"""Get the current voltage."""
return self._voltage
\end{verbatim}
turns the \method{voltage()} method into a ``getter'' for a read-only
attribute with the same name.
\versionadded{2.2}
\versionchanged[Use \var{fget}'s docstring if no \var{doc} given]{2.5}
@ -958,8 +984,30 @@ except NameError:
\begin{funcdesc}{sorted}{iterable\optional{, cmp\optional{,
key\optional{, reverse}}}}
Return a new sorted list from the items in \var{iterable}.
The optional arguments \var{cmp}, \var{key}, and \var{reverse}
have the same meaning as those for the \method{list.sort()} method.
The optional arguments \var{cmp}, \var{key}, and \var{reverse} have
the same meaning as those for the \method{list.sort()} method
(described in section~\ref{typesseq-mutable}).
\var{cmp} specifies a custom comparison function of two arguments
(iterable elements) which should return a negative, zero or positive
number depending on whether the first argument is considered smaller
than, equal to, or larger than the second argument:
\samp{\var{cmp}=\keyword{lambda} \var{x},\var{y}:
\function{cmp}(x.lower(), y.lower())}
\var{key} specifies a function of one argument that is used to
extract a comparison key from each list element:
\samp{\var{key}=\function{str.lower}}
\var{reverse} is a boolean value. If set to \code{True}, then the
list elements are sorted as if each comparison were reversed.
In general, the \var{key} and \var{reverse} conversion processes are
much faster than specifying an equivalent \var{cmp} function. This is
because \var{cmp} is called multiple times for each list element while
\var{key} and \var{reverse} touch each element only once.
\versionadded{2.4}
\end{funcdesc}

View File

@ -549,7 +549,7 @@ The \program{pygettext}\footnote{Fran\c cois Pinard has
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 @@ files are what the \module{gettext} module uses for the actual
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}

View File

@ -232,6 +232,24 @@ properly matching byte-compiled file (with suffix \file{.pyc} or
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 @@ def __import__(name, globals=None, locals=None, fromlist=None):
# 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:

View File

@ -180,13 +180,32 @@ Note:
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}}
@ -272,18 +291,18 @@ Note:
\end{funcdesc}
\begin{funcdesc}{formatargspec}{args\optional{, varargs, varkw, defaults,
argformat, varargsformat, varkwformat, defaultformat}}
formatarg, formatvarargs, formatvarkw, formatvalue, join}}
Format a pretty argument spec from the four values returned by
\function{getargspec()}. The other four arguments are the
\function{getargspec()}. The format* arguments are the
corresponding optional formatting functions that are called to turn
names and values into strings.
\end{funcdesc}
\begin{funcdesc}{formatargvalues}{args\optional{, varargs, varkw, locals,
argformat, varargsformat, varkwformat, valueformat}}
formatarg, formatvarargs, formatvarkw, formatvalue, join}}
Format a pretty argument spec from the four values returned by
\function{getargvalues()}. The other four arguments are the
\function{getargvalues()}. The format* arguments are the
corresponding optional formatting functions that are called to turn
names and values into strings.
\end{funcdesc}

View File

@ -38,7 +38,7 @@ files previously read using \function{getline()}.
\begin{funcdesc}{checkcache}{\optional{filename}}
Check the cache for validity. Use this function if files in the cache
may have changed on disk, and you require the updated version. If
\var{filename} is omitted, it will check the whole cache entries.
\var{filename} is omitted, it will check all the entries in the cache.
\end{funcdesc}
Example:

View File

@ -1068,13 +1068,11 @@ list of possible values is, note that they are not case sensitive:
\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 start the server, and which you can \method{join()} when appropriate.
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}{}

View File

@ -1367,9 +1367,8 @@ for message in mailbox.mbox('~/mbox'):
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

View File

@ -158,6 +158,20 @@ want more than one MIME-type database:
\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}}

View File

@ -22,13 +22,16 @@ unbound if \var{instance} is \code{None}. \var{function} must be
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,

View File

@ -1,3 +1,5 @@
% THIS FILE IS AUTO-GENERATED! DO NOT EDIT!
% (Your changes will be lost the next time it is generated.)
\section{\module{optparse} --- More powerful command line option parser}
\declaremodule{standard}{optparse}
\moduleauthor{Greg Ward}{gward@python.net}
@ -306,7 +308,7 @@ Of these, \member{action} is the most fundamental.
Actions tell \module{optparse} what to do when it encounters an option on the
command line. There is a fixed set of actions hard-coded into \module{optparse};
adding new actions is an advanced topic covered in section~\ref{optparse-extending}, Extending \module{optparse}.
adding new actions is an advanced topic covered in section~\ref{optparse-extending-optparse}, Extending \module{optparse}.
Most actions tell \module{optparse} to store a value in some variable{---}for
example, take a string from the command line and store it in an
attribute of \code{options}.
@ -371,7 +373,7 @@ are no long option strings, \module{optparse} looks at the first short option
string: the default destination for \code{"-f"} is \code{f}.
\module{optparse} also includes built-in \code{long} and \code{complex} types. Adding
types is covered in section~\ref{optparse-extending}, Extending \module{optparse}.
types is covered in section~\ref{optparse-extending-optparse}, Extending \module{optparse}.
\subsubsection{Handling boolean (flag) options\label{optparse-handling-boolean-options}}
@ -566,7 +568,7 @@ argument to OptionParser:
parser = OptionParser(usage="%prog [-f] [-q]", version="%prog 1.0")
\end{verbatim}
Note that \code{"{\%}prog"} is expanded just like it is in \code{usage}. Apart
\code{"{\%}prog"} is expanded just like it is in \code{usage}. Apart
from that, \code{version} can contain anything you like. When you supply
it, \module{optparse} automatically adds a \code{"-{}-version"} option to your parser.
If it encounters this option on the command line, it expands your
@ -659,7 +661,7 @@ def main():
if __name__ == "__main__":
main()
\end{verbatim}
% $Id: tutorial.txt 505 2005-07-22 01:52:40Z gward $
% $Id: tutorial.txt 515 2006-06-10 15:37:45Z gward $
\subsection{Reference Guide\label{optparse-reference-guide}}
@ -1146,7 +1148,7 @@ See section~\ref{optparse-tutorial}, the tutorial for an example.
\module{optparse} has six built-in option types: \code{string}, \code{int}, \code{long},
\code{choice}, \code{float} and \code{complex}. If you need to add new option
types, see section~\ref{optparse-extending}, Extending \module{optparse}.
types, see section~\ref{optparse-extending-optparse}, Extending \module{optparse}.
Arguments to string options are not checked or converted in any way: the
text on the command line is stored in the destination (or passed to the
@ -1195,16 +1197,16 @@ its \method{parse{\_}args()} method:
where the input parameters are
\begin{description}
\item[\code{args}]
the list of arguments to process (\code{sys.argv{[}1:]} by default)
the list of arguments to process (default: \code{sys.argv{[}1:]})
\item[\code{options}]
object to store option arguments in (a new instance of
optparse.Values by default)
object to store option arguments in (default: a new instance of
optparse.Values)
\end{description}
and the return values are
\begin{description}
\item[\code{options}]
the same object as was passed in as \code{options}, or the new
the same object that was passed in as \code{options}, or the
optparse.Values instance created by \module{optparse}
\item[\code{args}]
the leftover positional arguments after all options have been
@ -1212,9 +1214,9 @@ processed
\end{description}
The most common usage is to supply neither keyword argument. If you
supply a \code{values} object, it will be repeatedly modified with a
\code{setattr()} call for every option argument written to an option
destination, and finally returned by \method{parse{\_}args()}.
supply \code{options}, it will be modified with repeated \code{setattr()}
calls (roughly one for every option argument stored to an option
destination) and returned by \method{parse{\_}args()}.
If \method{parse{\_}args()} encounters any errors in the argument list, it calls
the OptionParser's \method{error()} method with an appropriate end-user error
@ -1388,7 +1390,7 @@ parser.add_option("--novice", action="store_const",
\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}}
@ -1681,3 +1683,206 @@ further options (probably causing an error), rather than as arguments to
\code{"-c"}. Fixing this is left as an exercise for the reader.
% $Id: callbacks.txt 415 2004-09-30 02:26:17Z greg $
\subsection{Extending \module{optparse}\label{optparse-extending-optparse}}
Since the two major controlling factors in how \module{optparse} interprets
command-line options are the action and type of each option, the most
likely direction of extension is to add new actions and new types.
\subsubsection{Adding new types\label{optparse-adding-new-types}}
To add new types, you need to define your own subclass of \module{optparse}'s Option
class. This class has a couple of attributes that define \module{optparse}'s types:
\member{TYPES} and \member{TYPE{\_}CHECKER}.
\member{TYPES} is a tuple of type names; in your subclass, simply define a new
tuple \member{TYPES} that builds on the standard one.
\member{TYPE{\_}CHECKER} is a dictionary mapping type names to type-checking
functions. A type-checking function has the following signature:
\begin{verbatim}
def check_mytype(option, opt, value)
\end{verbatim}
where \code{option} is an \class{Option} instance, \code{opt} is an option string
(e.g., \code{"-f"}), and \code{value} is the string from the command line that
must be checked and converted to your desired type. \code{check{\_}mytype()}
should return an object of the hypothetical type \code{mytype}. The value
returned by a type-checking function will wind up in the OptionValues
instance returned by \method{OptionParser.parse{\_}args()}, or be passed to a
callback as the \code{value} parameter.
Your type-checking function should raise OptionValueError if it
encounters any problems. OptionValueError takes a single string
argument, which is passed as-is to OptionParser's \method{error()} method,
which in turn prepends the program name and the string \code{"error:"} and
prints everything to stderr before terminating the process.
Here's a silly example that demonstrates adding a \code{complex} option
type to parse Python-style complex numbers on the command line. (This
is even sillier than it used to be, because \module{optparse} 1.3 added built-in
support for complex numbers, but never mind.)
First, the necessary imports:
\begin{verbatim}
from copy import copy
from optparse import Option, OptionValueError
\end{verbatim}
You need to define your type-checker first, since it's referred to later
(in the \member{TYPE{\_}CHECKER} class attribute of your Option subclass):
\begin{verbatim}
def check_complex(option, opt, value):
try:
return complex(value)
except ValueError:
raise OptionValueError(
"option %s: invalid complex value: %r" % (opt, value))
\end{verbatim}
Finally, the Option subclass:
\begin{verbatim}
class MyOption (Option):
TYPES = Option.TYPES + ("complex",)
TYPE_CHECKER = copy(Option.TYPE_CHECKER)
TYPE_CHECKER["complex"] = check_complex
\end{verbatim}
(If we didn't make a \function{copy()} of \member{Option.TYPE{\_}CHECKER}, we would end
up modifying the \member{TYPE{\_}CHECKER} attribute of \module{optparse}'s Option class.
This being Python, nothing stops you from doing that except good manners
and common sense.)
That's it! Now you can write a script that uses the new option type
just like any other \module{optparse}-based script, except you have to instruct your
OptionParser to use MyOption instead of Option:
\begin{verbatim}
parser = OptionParser(option_class=MyOption)
parser.add_option("-c", type="complex")
\end{verbatim}
Alternately, you can build your own option list and pass it to
OptionParser; if you don't use \method{add{\_}option()} in the above way, you
don't need to tell OptionParser which option class to use:
\begin{verbatim}
option_list = [MyOption("-c", action="store", type="complex", dest="c")]
parser = OptionParser(option_list=option_list)
\end{verbatim}
\subsubsection{Adding new actions\label{optparse-adding-new-actions}}
Adding new actions is a bit trickier, because you have to understand
that \module{optparse} has a couple of classifications for actions:
\begin{description}
\item[``store'' actions]
actions that result in \module{optparse} storing a value to an attribute of the
current OptionValues instance; these options require a \member{dest}
attribute to be supplied to the Option constructor
\item[``typed'' actions]
actions that take a value from the command line and expect it to be
of a certain type; or rather, a string that can be converted to a
certain type. These options require a \member{type} attribute to the
Option constructor.
\end{description}
These are overlapping sets: some default ``store'' actions are \code{store},
\code{store{\_}const}, \code{append}, and \code{count}, while the default ``typed''
actions are \code{store}, \code{append}, and \code{callback}.
When you add an action, you need to categorize it by listing it in at
least one of the following class attributes of Option (all are lists of
strings):
\begin{description}
\item[\member{ACTIONS}]
all actions must be listed in ACTIONS
\item[\member{STORE{\_}ACTIONS}]
``store'' actions are additionally listed here
\item[\member{TYPED{\_}ACTIONS}]
``typed'' actions are additionally listed here
\item[\code{ALWAYS{\_}TYPED{\_}ACTIONS}]
actions that always take a type (i.e. whose options always take a
value) are additionally listed here. The only effect of this is
that \module{optparse} assigns the default type, \code{string}, to options with no
explicit type whose action is listed in \code{ALWAYS{\_}TYPED{\_}ACTIONS}.
\end{description}
In order to actually implement your new action, you must override
Option's \method{take{\_}action()} method and add a case that recognizes your
action.
For example, let's add an \code{extend} action. This is similar to the
standard \code{append} action, but instead of taking a single value from
the command-line and appending it to an existing list, \code{extend} will
take multiple values in a single comma-delimited string, and extend an
existing list with them. That is, if \code{"-{}-names"} is an \code{extend}
option of type \code{string}, the command line
\begin{verbatim}
--names=foo,bar --names blah --names ding,dong
\end{verbatim}
would result in a list
\begin{verbatim}
["foo", "bar", "blah", "ding", "dong"]
\end{verbatim}
Again we define a subclass of Option:
\begin{verbatim}
class MyOption (Option):
ACTIONS = Option.ACTIONS + ("extend",)
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
def take_action(self, action, dest, opt, value, values, parser):
if action == "extend":
lvalue = value.split(",")
values.ensure_value(dest, []).extend(lvalue)
else:
Option.take_action(
self, action, dest, opt, value, values, parser)
\end{verbatim}
Features of note:
\begin{itemize}
\item {}
\code{extend} both expects a value on the command-line and stores that
value somewhere, so it goes in both \member{STORE{\_}ACTIONS} and
\member{TYPED{\_}ACTIONS}
\item {}
to ensure that \module{optparse} assigns the default type of \code{string} to
\code{extend} actions, we put the \code{extend} action in
\code{ALWAYS{\_}TYPED{\_}ACTIONS} as well
\item {}
\method{MyOption.take{\_}action()} implements just this one new action, and
passes control back to \method{Option.take{\_}action()} for the standard
\module{optparse} actions
\item {}
\code{values} is an instance of the optparse{\_}parser.Values class,
which provides the very useful \method{ensure{\_}value()} method.
\method{ensure{\_}value()} is essentially \function{getattr()} with a safety valve;
it is called as
\begin{verbatim}
values.ensure_value(attr, value)
\end{verbatim}
If the \code{attr} attribute of \code{values} doesn't exist or is None, then
ensure{\_}value() first sets it to \code{value}, and then returns 'value.
This is very handy for actions like \code{extend}, \code{append}, and
\code{count}, all of which accumulate data in a variable and expect that
variable to be of a certain type (a list for the first two, an integer
for the latter). Using \method{ensure{\_}value()} means that scripts using
your action don't have to worry about setting a default value for the
option destinations in question; they can just leave the default as
None and \method{ensure{\_}value()} will take care of getting it right when
it's needed.
\end{itemize}
% $Id: extending.txt 517 2006-06-10 16:18:11Z gward $

View File

@ -68,7 +68,7 @@ raises \exception{IOError}. Errors detected directly by
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.

View File

@ -725,7 +725,50 @@ source of the strings your application unpickles.
\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

View File

@ -30,7 +30,7 @@ __path__ = extend_path(__path__, __name__)
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

View File

@ -42,8 +42,11 @@ half of the pair returned by \code{split(\var{path})}.
\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 @@ Availability: Macintosh, \UNIX.
\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}

View File

@ -236,7 +236,7 @@ these equations can be found in any statistics text.
\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 @@ called.
\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

View File

@ -897,7 +897,7 @@ offers some more-or-less equivalent mappings between
\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}}

View File

@ -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:

View File

@ -132,27 +132,59 @@ nothing.
\begin{methoddesc}{handle_charref}{ref}
This method is called to process a character reference of the form
\samp{\&\#\var{ref};}. In the base implementation, \var{ref} must
be a decimal number in the
range 0-255. It translates the character to \ASCII{} and calls the
method \method{handle_data()} with the character as argument. If
\var{ref} is invalid or out of range, the method
\code{unknown_charref(\var{ref})} is called to handle the error. A
subclass must override this method to provide support for named
character entities.
\samp{\&\#\var{ref};}. The base implementation uses
\method{convert_charref()} to convert the reference to a string. If
that method returns a string, it is passed to \method{handle_data()},
otherwise \method{unknown_charref(\var{ref})} is called to handle the
error.
\versionchanged[Use \method{convert_charref()} instead of hard-coding
the conversion]{2.5}
\end{methoddesc}
\begin{methoddesc}{convert_charref}{ref}
Convert a character reference to a string, or \code{None}. \var{ref}
is the reference passed in as a string. In the base implementation,
\var{ref} must be a decimal number in the range 0-255. It converts
the code point found using the \method{convert_codepoint()} method.
If \var{ref} is invalid or out of range, this method returns
\code{None}. This method is called by the default
\method{handle_charref()} implementation and by the attribute value
parser.
\versionadded{2.5}
\end{methoddesc}
\begin{methoddesc}{convert_codepoint}{codepoint}
Convert a codepoint to a \class{str} value. Encodings can be handled
here if appropriate, though the rest of \module{sgmllib} is oblivious
on this matter.
\versionadded{2.5}
\end{methoddesc}
\begin{methoddesc}{handle_entityref}{ref}
This method is called to process a general entity reference of the
form \samp{\&\var{ref};} where \var{ref} is an general entity
reference. It looks for \var{ref} in the instance (or class)
variable \member{entitydefs} which should be a mapping from entity
names to corresponding translations. If a translation is found, it
reference. It converts \var{ref} by passing it to
\method{convert_entityref()}. If a translation is returned, it
calls the method \method{handle_data()} with the translation;
otherwise, it calls the method \code{unknown_entityref(\var{ref})}.
The default \member{entitydefs} defines translations for
\code{\&amp;}, \code{\&apos}, \code{\&gt;}, \code{\&lt;}, and
\code{\&quot;}.
\versionchanged[Use \method{convert_entityref()} instead of hard-coding
the conversion]{2.5}
\end{methoddesc}
\begin{methoddesc}{convert_entityref}{ref}
Convert a named entity reference to a \class{str} value, or
\code{None}. The resulting value will not be parsed. \var{ref} will
be only the name of the entity. The default implementation looks for
\var{ref} in the instance (or class) variable \member{entitydefs}
which should be a mapping from entity names to corresponding
translations. If no translation is available for \var{ref}, this
method returns \code{None}. This method is called by the default
\method{handle_entityref()} implementation and by the attribute value
parser.
\versionadded{2.5}
\end{methoddesc}
\begin{methoddesc}{handle_comment}{comment}

View File

@ -143,15 +143,17 @@ data = d[key] # retrieve a COPY of data at key (raise KeyError if no
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.

View File

@ -16,12 +16,13 @@ search path.
It starts by constructing up to four directories from a head and a
tail part. For the head part, it uses \code{sys.prefix} and
\code{sys.exec_prefix}; empty heads are skipped. For
the tail part, it uses the empty string (on Windows) or
\file{lib/python\shortversion/site-packages} (on \UNIX{} and Macintosh)
and then \file{lib/site-python}. For each of the distinct
head-tail combinations, it sees if it refers to an existing directory,
and if so, adds it to \code{sys.path} and also inspects the newly added
path for configuration files.
the tail part, it uses the empty string and then
\file{lib/site-packages} (on Windows) or
\file{lib/python\shortversion/site-packages} and then
\file{lib/site-python} (on \UNIX{} and Macintosh). For each of the
distinct head-tail combinations, it sees if it refers to an existing
directory, and if so, adds it to \code{sys.path} and also inspects
the newly added path for configuration files.
\indexii{site-python}{directory}
\indexii{site-packages}{directory}

View File

@ -711,6 +711,17 @@ If \var{n} is provided, read \var{n} bytes from the SSL connection, otherwise
read until EOF. The return value is a string of the bytes read.
\end{methoddesc}
\begin{methoddesc}{server}{}
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 @@ data = s.recv(1024)
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}

View File

@ -74,9 +74,9 @@ synchronous servers of four types:
\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

View File

@ -195,6 +195,14 @@ This can be used to build a shell for SQLite, like in the following example:
\verbatiminput{sqlite3/complete_statement.py}
\end{funcdesc}
\begin{funcdesc}{}enable_callback_tracebacks{flag}
By default you will not get any tracebacks in user-defined functions,
aggregates, converters, authorizer callbacks etc. If you want to debug them,
you can call this function with \var{flag} as True. Afterwards, you will get
tracebacks from callbacks on \code{sys.stderr}. Use \constant{False} to disable
the feature again.
\end{funcdesc}
\subsection{Connection Objects \label{sqlite3-Connection-Objects}}
A \class{Connection} instance has the following attributes and methods:
@ -237,8 +245,7 @@ of parameters the function accepts, and \var{func} is a Python callable that is
called as SQL function.
The function can return any of the types supported by SQLite: unicode, str,
int, long, float, buffer and None. Exceptions in the function are ignored and
they are handled as if the function returned None.
int, long, float, buffer and None.
Example:
@ -254,7 +261,7 @@ number of parameters \var{num_params}, and a \code{finalize} method which
will return the final result of the aggregate.
The \code{finalize} method can return any of the types supported by SQLite:
unicode, str, int, long, float, buffer and None. Any exceptions are ignored.
unicode, str, int, long, float, buffer and None.
Example:
@ -283,6 +290,34 @@ To remove a collation, call \code{create_collation} with None as callable:
\end{verbatim}
\end{methoddesc}
\begin{methoddesc}{interrupt}{}
You can call this method from a different thread to abort any queries that
might be executing on the connection. The query will then abort and the caller
will get an exception.
\end{methoddesc}
\begin{methoddesc}{set_authorizer}{authorizer_callback}
This routine registers a callback. The callback is invoked for each attempt to
access a column of a table in the database. The callback should return
\constant{SQLITE_OK} if access is allowed, \constant{SQLITE_DENY} if the entire
SQL statement should be aborted with an error and \constant{SQLITE_IGNORE} if
the column should be treated as a NULL value. These constants are available in
the \module{sqlite3} module.
The first argument to the callback signifies what kind of operation is to be
authorized. The second and third argument will be arguments or \constant{None}
depending on the first argument. The 4th argument is the name of the database
("main", "temp", etc.) if applicable. The 5th argument is the name of the
inner-most trigger or view that is responsible for the access attempt or
\constant{None} if this access attempt is directly from input SQL code.
Please consult the SQLite documentation about the possible values for the first
argument and the meaning of the second and third argument depending on the
first one. All necessary constants are available in the \module{sqlite3}
module.
\end{methoddesc}
\begin{memberdesc}{row_factory}
You can change this attribute to a callable that accepts the cursor and
@ -477,10 +512,10 @@ The type/class to adapt must be a new-style class, i. e. it must have
\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}

View File

@ -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 @@ differed from user-defined types because it was not possible to use
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 @@ and other language statements can be found in the
\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 @@ return one of their operands.)
\index{False}
\index{True}
\subsection{Boolean Operations ---
\section{Boolean Operations ---
\keyword{and}, \keyword{or}, \keyword{not}
\label{boolean}}
@ -107,7 +107,7 @@ These only evaluate their second argument if needed for their outcome.
\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 @@ Two more operations with the same syntactic priority,
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 @@ though the result's type is not necessarily int.
\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 @@ division by \code{pow(2, \var{n})} without overflow check.
\end{description}
\subsection{Iterator Types \label{typeiter}}
\section{Iterator Types \label{typeiter}}
\versionadded{2.2}
\index{iterator protocol}
@ -414,7 +414,7 @@ return an iterator object (technically, a generator object)
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,8 @@ linear concatenation performance across versions and implementations.
\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
objects support:
@ -618,8 +619,11 @@ For a list of possible encodings, see section~\ref{standard-encodings}.
\begin{methoddesc}[string]{endswith}{suffix\optional{, start\optional{, end}}}
Return \code{True} if the string ends with the specified \var{suffix},
otherwise return \code{False}. With optional \var{start}, test beginning at
otherwise return \code{False}. \var{suffix} can also be a tuple of
suffixes to look for. With optional \var{start}, test beginning at
that position. With optional \var{end}, stop comparing at that position.
\versionchanged[Accept tuples as \var{suffix}]{2.5}
\end{methoddesc}
\begin{methoddesc}[string]{expandtabs}{\optional{tabsize}}
@ -829,9 +833,12 @@ boundaries. Line breaks are not included in the resulting list unless
\begin{methoddesc}[string]{startswith}{prefix\optional{,
start\optional{, end}}}
Return \code{True} if string starts with the \var{prefix}, otherwise
return \code{False}. With optional \var{start}, test string beginning at
return \code{False}. \var{prefix} can also be a tuple of
suffixes to look for. With optional \var{start}, test string beginning at
that position. With optional \var{end}, stop comparing string at that
position.
\versionchanged[Accept tuples as \var{prefix}]{2.5}
\end{methoddesc}
\begin{methoddesc}[string]{strip}{\optional{chars}}
@ -894,7 +901,7 @@ of length \var{width}. The original string is returned if
\end{methoddesc}
\subsubsection{String Formatting Operations \label{typesseq-strings}}
\subsection{String Formatting Operations \label{typesseq-strings}}
\index{formatting, string (\%{})}
\index{interpolation, string (\%{})}
@ -1065,7 +1072,7 @@ Additional string operations are defined in standard modules
\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}
@ -1077,7 +1084,7 @@ XRange objects have very little behavior: they only support indexing,
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.
@ -1094,7 +1101,8 @@ The following operations are defined on mutable sequence types (where
\lineiii{\var{s}[\var{i}] = \var{x}}
{item \var{i} of \var{s} is replaced by \var{x}}{}
\lineiii{\var{s}[\var{i}:\var{j}] = \var{t}}
{slice of \var{s} from \var{i} to \var{j} is replaced by \var{t}}{}
{slice of \var{s} from \var{i} to \var{j}
is replaced by the contents of the iterable \var{t}}{}
\lineiii{del \var{s}[\var{i}:\var{j}]}
{same as \code{\var{s}[\var{i}:\var{j}] = []}}{}
\lineiii{\var{s}[\var{i}:\var{j}:\var{k}] = \var{t}}
@ -1208,7 +1216,7 @@ Notes:
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}
@ -1347,7 +1355,7 @@ The design of the set types was based on lessons learned from the
\end{seealso}
\subsection{Mapping Types --- \class{dict} \label{typesmapping}}
\section{Mapping Types --- \class{dict} \label{typesmapping}}
\obindex{mapping}
\obindex{dictionary}
@ -1510,7 +1518,7 @@ For an example, see \module{collections}.\class{defaultdict}.
\end{description}
\subsection{File Objects
\section{File Objects
\label{bltin-file-objects}}
File objects\obindex{file} are implemented using C's \code{stdio}
@ -1783,7 +1791,7 @@ implemented in C will have to provide a writable
\end{memberdesc}
\subsection{Context Manager Types \label{typecontextmanager}}
\section{Context Manager Types \label{typecontextmanager}}
\versionadded{2.5}
\index{context manager}
@ -1864,13 +1872,13 @@ runtime context, the overhead of a single class dictionary lookup
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}
@ -1896,14 +1904,14 @@ written as \code{<module 'os' from
'/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:
@ -1917,7 +1925,7 @@ different object types.
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.
@ -1962,7 +1970,7 @@ See the \citetitle[../ref/ref.html]{Python Reference Manual} for more
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
@ -1985,7 +1993,7 @@ See the \citetitle[../ref/ref.html]{Python Reference Manual} for more
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
@ -1997,7 +2005,7 @@ for all standard built-in types.
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
@ -2006,7 +2014,7 @@ object, named \code{None} (a built-in name).
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
@ -2015,7 +2023,7 @@ special operations. There is exactly one ellipsis object, named
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
@ -2032,14 +2040,14 @@ They are written as \code{False} and \code{True}, respectively.
\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

View File

@ -37,6 +37,24 @@ such mixing can cause this method to raise \exception{UnicodeError}.
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 @@ The following data objects are provided as well:
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}

View File

@ -107,7 +107,7 @@ for the new process.
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 @@ The arguments are the same as for the Popen constructor. Example:
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 @@ should prepare for \exception{OSError} exceptions.
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}

View File

@ -21,7 +21,7 @@ It is always available.
\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}
@ -41,7 +41,7 @@ It is always available.
\code{Include/patchlevel.h} if the branch is a tag. Otherwise,
it is \code{None}.
\versionadded{2.5}
\end{datadesc}
\end{datadesc}
\begin{datadesc}{builtin_module_names}
A tuple of strings giving the names of all modules that are compiled
@ -55,6 +55,23 @@ It is always available.
interpreter.
\end{datadesc}
\begin{funcdesc}{_current_frames}{}
Return a dictionary mapping each thread's identifier to the topmost stack
frame currently active in that thread at the time the function is called.
Note that functions in the \refmodule{traceback} module can build the
call stack given such a frame.
This is most useful for debugging deadlock: this function does not
require the deadlocked threads' cooperation, and such threads' call stacks
are frozen for as long as they remain deadlocked. The frame returned
for a non-deadlocked thread may bear no relationship to that thread's
current activity by the time calling code examines the frame.
This function should be used for internal and specialized purposes
only.
\versionadded{2.5}
\end{funcdesc}
\begin{datadesc}{dllhandle}
Integer specifying the handle of the Python DLL.
Availability: Windows.
@ -142,7 +159,7 @@ It is always available.
function, \function{exc_info()} will return three \code{None} values until
another exception is raised in the current thread or the execution stack
returns to a frame where another exception is being handled.
This function is only needed in only a few obscure situations. These
include logging and error handling systems that report information on the
last or current exception. This function can also be used to try to free
@ -241,14 +258,14 @@ It is always available.
\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}
@ -279,8 +296,8 @@ It is always available.
\end{funcdesc}
\begin{funcdesc}{getwindowsversion}{}
Return a tuple containing five components, describing the Windows
version currently running. The elements are \var{major}, \var{minor},
Return a tuple containing five components, describing the Windows
version currently running. The elements are \var{major}, \var{minor},
\var{build}, \var{platform}, and \var{text}. \var{text} contains
a string while all other values are integers.
@ -491,7 +508,7 @@ else:
be registered using \function{settrace()} for each thread being
debugged. \note{The \function{settrace()} function is intended only
for implementing debuggers, profilers, coverage tools and the like.
Its behavior is part of the implementation platform, rather than
Its behavior is part of the implementation platform, rather than
part of the language definition, and thus may not be available in
all Python implementations.}
\end{funcdesc}

View File

@ -47,12 +47,17 @@ remove indentation from strings that have unwanted whitespace to the
left of the text.
\begin{funcdesc}{dedent}{text}
Remove any whitespace that can be uniformly removed from the left
of every line in \var{text}.
Remove any common leading whitespace from every line in \var{text}.
This is typically used to make triple-quoted strings line up with
the left edge of screen/whatever, while still presenting it in the
source code in indented form.
This can be used to make triple-quoted strings line up with the left
edge of the display, while still presenting them in the source code
in indented form.
Note that tabs and spaces are both treated as whitespace, but they are
not equal: the lines \code{" {} hello"} and \code{"\textbackslash{}thello"}
are considered to have no common leading whitespace. (This behaviour is
new in Python 2.5; older versions of this module incorrectly expanded
tabs before searching for common leading whitespace.)
For example:
\begin{verbatim}

View File

@ -74,6 +74,26 @@ data. Thread identifiers may be recycled when a thread exits and
another thread is created.
\end{funcdesc}
\begin{funcdesc}{stack_size}{\optional{size}}
Return the thread stack size used when creating new threads. The
optional \var{size} argument specifies the stack size to be used for
subsequently created threads, and must be 0 (use platform or
configured default) or a positive integer value of at least 32,768 (32kB).
If changing the thread stack size is unsupported, a \exception{ThreadError}
is raised. If the specified stack size is invalid, a \exception{ValueError}
is raised and the stack size is unmodified. 32kB is currently the minimum
supported stack size value to guarantee sufficient stack space for the
interpreter itself. Note that some platforms may have particular
restrictions on values for the stack size, such as requiring a minimum
stack size > 32kB or requiring allocation in multiples of the system
memory page size - platform documentation should be referred to for
more information (4kB pages are common; using multiples of 4096 for
the stack size is the suggested approach in the absence of more
specific information).
Availability: Windows, systems with \POSIX{} threads.
\versionadded{2.5}
\end{funcdesc}
Lock objects have the following methods:

View File

@ -125,6 +125,26 @@ method is called.
\versionadded{2.3}
\end{funcdesc}
\begin{funcdesc}{stack_size}{\optional{size}}
Return the thread stack size used when creating new threads. The
optional \var{size} argument specifies the stack size to be used for
subsequently created threads, and must be 0 (use platform or
configured default) or a positive integer value of at least 32,768 (32kB).
If changing the thread stack size is unsupported, a \exception{ThreadError}
is raised. If the specified stack size is invalid, a \exception{ValueError}
is raised and the stack size is unmodified. 32kB is currently the minimum
supported stack size value to guarantee sufficient stack space for the
interpreter itself. Note that some platforms may have particular
restrictions on values for the stack size, such as requiring a minimum
stack size > 32kB or requiring allocation in multiples of the system
memory page size - platform documentation should be referred to for
more information (4kB pages are common; using multiples of 4096 for
the stack size is the suggested approach in the absence of more
specific information).
Availability: Windows, systems with \POSIX{} threads.
\versionadded{2.5}
\end{funcdesc}
Detailed interfaces for the objects are documented below.
The design of this module is loosely based on Java's threading model.

View File

@ -226,6 +226,8 @@ if any field in \var{t} is outside of the allowed range.
\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 @@ Where:
'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

View File

@ -27,6 +27,45 @@ Set angle measurement units to degrees.
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.
@ -42,6 +81,19 @@ means line are drawn more slowly, with an animation of an arrow along the
line.
\end{funcdesc}
\begin{funcdesc}{speed}{speed}
Set the speed of the turtle. Valid values for the parameter
\var{speed} are \code{'fastest'} (no delay), \code{'fast'},
(delay 5ms), \code{'normal'} (delay 10ms), \code{'slow'}
(delay 15ms), and \code{'slowest'} (delay 20ms).
\versionadded{2.5}
\end{funcdesc}
\begin{funcdesc}{delay}{delay}
Set the speed of the turtle to \var{delay}, which is given
in ms. \versionadded{2.5}
\end{funcdesc}
\begin{funcdesc}{forward}{distance}
Go forward \var{distance} steps.
\end{funcdesc}
@ -94,6 +146,18 @@ usage is: call \code{fill(1)} before drawing a path you want to fill,
and call \code{fill(0)} when you finish to draw the path.
\end{funcdesc}
\begin{funcdesc}{begin\_fill}{}
Switch turtle into filling mode;
Must eventually be followed by a corresponding end_fill() call.
Otherwise it will be ignored.
\versionadded{2.5}
\end{funcdesc}
\begin{funcdesc}{end\_fill}{}
End filling mode, and fill the shape; equivalent to \code{fill(0)}.
\versionadded{2.5}
\end{funcdesc}
\begin{funcdesc}{circle}{radius\optional{, extent}}
Draw a circle with radius \var{radius} whose center-point is
\var{radius} units left of the turtle.
@ -113,6 +177,49 @@ Go to co-ordinates \var{x}, \var{y}. The co-ordinates may be
specified either as two separate arguments or as a 2-tuple.
\end{funcdesc}
\begin{funcdesc}{towards}{x, y}
Return the angle of the line from the turtle's position
to the point \var{x}, \var{y}. The co-ordinates may be
specified either as two separate arguments, as a 2-tuple,
or as another pen object.
\versionadded{2.5}
\end{funcdesc}
\begin{funcdesc}{heading}{}
Return the current orientation of the turtle.
\versionadded{2.3}
\end{funcdesc}
\begin{funcdesc}{setheading}{angle}
Set the orientation of the turtle to \var{angle}.
\versionadded{2.3}
\end{funcdesc}
\begin{funcdesc}{position}{}
Return the current location of the turtle as an \code{(x,y)} pair.
\versionadded{2.3}
\end{funcdesc}
\begin{funcdesc}{setx}{x}
Set the x coordinate of the turtle to \var{x}.
\versionadded{2.3}
\end{funcdesc}
\begin{funcdesc}{sety}{y}
Set the y coordinate of the turtle to \var{y}.
\versionadded{2.3}
\end{funcdesc}
\begin{funcdesc}{window\_width}{}
Return the width of the canvas window.
\versionadded{2.3}
\end{funcdesc}
\begin{funcdesc}{window\_height}{}
Return the height of the canvas window.
\versionadded{2.3}
\end{funcdesc}
This module also does \code{from math import *}, so see the
documentation for the \refmodule{math} module for additional constants
and functions useful for turtle graphics.
@ -134,19 +241,25 @@ Define a pen. All above functions can be called as a methods on the given
pen. The constructor automatically creates a canvas do be drawn on.
\end{classdesc}
\begin{classdesc}{Turtle}{}
Define a pen. This is essentially a synonym for \code{Pen()};
\class{Turtle} is an empty subclass of \class{Pen}.
\end{classdesc}
\begin{classdesc}{RawPen}{canvas}
Define a pen which draws on a canvas \var{canvas}. This is useful if
you want to use the module to create graphics in a ``real'' program.
\end{classdesc}
\subsection{Pen and RawPen Objects \label{pen-rawpen-objects}}
\subsection{Turtle, Pen and RawPen Objects \label{pen-rawpen-objects}}
\class{Pen} and \class{RawPen} objects have all the global functions
described above, except for \function{demo()} as methods, which
manipulate the given pen.
Most of the global functions available in the module are also
available as methods of the \class{Turtle}, \class{Pen} and
\class{RawPen} classes, affecting only the state of the given pen.
The only method which is more powerful as a method is
\function{degrees()}.
\function{degrees()}, which takes an optional argument letting
you specify the number of units corresponding to a full circle:
\begin{methoddesc}{degrees}{\optional{fullcircle}}
\var{fullcircle} is by default 360. This can cause the pen to have any

View File

@ -176,6 +176,30 @@ The type of buffer objects created by the
\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

View File

@ -49,7 +49,7 @@ document these.
\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}

View File

@ -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 @@ decomposition, and translates each character into its decomposed form.
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 @@ the Unicode database (such as IDNA).
\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}

View File

@ -10,19 +10,19 @@
\versionadded{2.1}
The Python unit testing framework, often referred to as ``PyUnit,'' is
The Python unit testing framework, sometimes referred to as ``PyUnit,'' is
a Python language version of JUnit, by Kent Beck and Erich Gamma.
JUnit is, in turn, a Java version of Kent's Smalltalk testing
framework. Each is the de facto standard unit testing framework for
its respective language.
PyUnit supports test automation, sharing of setup and shutdown code
for tests, aggregation of tests into collections, and independence of
\module{unittest} supports test automation, sharing of setup and shutdown
code for tests, aggregation of tests into collections, and independence of
the tests from the reporting framework. The \module{unittest} module
provides classes that make it easy to support these qualities for a
set of tests.
To achieve this, PyUnit supports some important concepts:
To achieve this, \module{unittest} supports some important concepts:
\begin{definitions}
\term{test fixture}
@ -33,10 +33,9 @@ starting a server process.
\term{test case}
A \dfn{test case} is the smallest unit of testing. It checks for a
specific response to a particular set of inputs. PyUnit provides a
base class, \class{TestCase}, which may be used to create new test
cases. You may provide your own implementation that does not subclass
from \class{TestCase}, of course.
specific response to a particular set of inputs. \module{unittest}
provides a base class, \class{TestCase}, which may be used to create
new test cases.
\term{test suite}
A \dfn{test suite} is a collection of test cases, test suites, or
@ -54,8 +53,8 @@ indicate the results of executing the tests.
The test case and test fixture concepts are supported through the
\class{TestCase} and \class{FunctionTestCase} classes; the former
should be used when creating new tests, and the latter can be used when
integrating existing test code with a PyUnit-driven framework. When
building test fixtures using \class{TestCase}, the \method{setUp()}
integrating existing test code with a \module{unittest}-driven framework.
When building test fixtures using \class{TestCase}, the \method{setUp()}
and \method{tearDown()} methods can be overridden to provide
initialization and cleanup for the fixture. With
\class{FunctionTestCase}, existing functions can be passed to the
@ -74,19 +73,17 @@ the suite is executed, all tests added directly to the suite and in
A test runner is an object that provides a single method,
\method{run()}, which accepts a \class{TestCase} or \class{TestSuite}
object as a parameter, and returns a result object. The class
\class{TestResult} is provided for use as the result object. PyUnit
provide the \class{TextTestRunner} as an example test runner which
reports test results on the standard error stream by default.
Alternate runners can be implemented for other environments (such as
graphical environments) without any need to derive from a specific
class.
\class{TestResult} is provided for use as the result object.
\module{unittest} provides the \class{TextTestRunner} as an example
test runner which reports test results on the standard error stream by
default. Alternate runners can be implemented for other environments
(such as graphical environments) without any need to derive from a
specific class.
\begin{seealso}
\seemodule{doctest}{Another test-support module with a very
different flavor.}
\seetitle[http://pyunit.sourceforge.net/]{PyUnit Web Site}{The
source for further information on PyUnit.}
\seetitle[http://www.XProgramming.com/testfram.htm]{Simple Smalltalk
Testing: With Patterns}{Kent Beck's original paper on
testing frameworks using the pattern shared by
@ -166,7 +163,7 @@ run from the command line. For example, the last two lines may be replaced
with:
\begin{verbatim}
suite = unittest.makeSuite(TestSequenceFunctions)
suite = unittest.TestLoader().loadTestsFromTestCase(TestSequenceFunctions)
unittest.TextTestRunner(verbosity=2).run(suite)
\end{verbatim}
@ -194,8 +191,8 @@ of the documentation explores the full feature set from first principles.
The basic building blocks of unit testing are \dfn{test cases} ---
single scenarios that must be set up and checked for correctness. In
PyUnit, test cases are represented by instances of the
\class{TestCase} class in the \refmodule{unittest} module. To make
\module{unittest}, test cases are represented by instances of
\module{unittest}'s \class{TestCase} class. To make
your own test cases you must write subclasses of \class{TestCase}, or
use \class{FunctionTestCase}.
@ -207,7 +204,7 @@ The testing code of a \class{TestCase} instance should be entirely
self contained, such that it can be run either in isolation or in
arbitrary combination with any number of other test cases.
The simplest test case subclass will simply override the
The simplest \class{TestCase} subclass will simply override the
\method{runTest()} method in order to perform specific testing code:
\begin{verbatim}
@ -221,12 +218,13 @@ class DefaultWidgetSizeTestCase(unittest.TestCase):
Note that in order to test something, we use the one of the
\method{assert*()} or \method{fail*()} methods provided by the
\class{TestCase} base class. If the test fails when the test case
runs, an exception will be raised, and the testing framework will
identify the test case as a \dfn{failure}. Other exceptions that do
not arise from checks made through the \method{assert*()} and
\method{fail*()} methods are identified by the testing framework as
\dfn{errors}.
\class{TestCase} base class. If the test fails, an exception will be
raised, and \module{unittest} will identify the test case as a
\dfn{failure}. Any other exceptions will be treated as \dfn{errors}.
This helps you identify where the problem is: \dfn{failures} are caused by
incorrect results - a 5 where you expected a 6. \dfn{Errors} are caused by
incorrect code - e.g., a \exception{TypeError} caused by an incorrect
function call.
The way to run a test case will be described later. For now, note
that to construct an instance of such a test case, we call its
@ -237,7 +235,7 @@ testCase = DefaultWidgetSizeTestCase()
\end{verbatim}
Now, such test cases can be numerous, and their set-up can be
repetitive. In the above case, constructing a ``Widget'' in each of
repetitive. In the above case, constructing a \class{Widget} in each of
100 Widget test case subclasses would mean unsightly duplication.
Luckily, we can factor out such set-up code by implementing a method
@ -283,7 +281,7 @@ class SimpleWidgetTestCase(unittest.TestCase):
\end{verbatim}
If \method{setUp()} succeeded, the \method{tearDown()} method will be
run regardless of whether or not \method{runTest()} succeeded.
run whether \method{runTest()} succeeded or not.
Such a working environment for the testing code is called a
\dfn{fixture}.
@ -292,8 +290,8 @@ Often, many small test cases will use the same fixture. In this case,
we would end up subclassing \class{SimpleWidgetTestCase} into many
small one-method classes such as
\class{DefaultWidgetSizeTestCase}. This is time-consuming and
discouraging, so in the same vein as JUnit, PyUnit provides a simpler
mechanism:
discouraging, so in the same vein as JUnit, \module{unittest} provides
a simpler mechanism:
\begin{verbatim}
import unittest
@ -329,9 +327,9 @@ resizeTestCase = WidgetTestCase("testResize")
\end{verbatim}
Test case instances are grouped together according to the features
they test. PyUnit provides a mechanism for this: the \class{test
suite}, represented by the class \class{TestSuite} in the
\refmodule{unittest} module:
they test. \module{unittest} provides a mechanism for this: the
\dfn{test suite}, represented by \module{unittest}'s \class{TestSuite}
class:
\begin{verbatim}
widgetTestSuite = unittest.TestSuite()
@ -354,28 +352,30 @@ def suite():
or even:
\begin{verbatim}
class WidgetTestSuite(unittest.TestSuite):
def __init__(self):
unittest.TestSuite.__init__(self,map(WidgetTestCase,
("testDefaultSize",
"testResize")))
\end{verbatim}
def suite():
tests = ["testDefaultSize", "testResize"]
(The latter is admittedly not for the faint-hearted!)
return unittest.TestSuite(map(WidgetTestCase, tests))
\end{verbatim}
Since it is a common pattern to create a \class{TestCase} subclass
with many similarly named test functions, there is a convenience
function called \function{makeSuite()} that constructs a test suite
that comprises all of the test cases in a test case class:
with many similarly named test functions, \module{unittest} provides a
\class{TestLoader} class that can be used to automate the process of
creating a test suite and populating it with individual tests.
For example,
\begin{verbatim}
suite = unittest.makeSuite(WidgetTestCase)
suite = unittest.TestLoader().loadTestsFromTestCase(WidgetTestCase)
\end{verbatim}
Note that when using the \function{makeSuite()} function, the order in
which the various test cases will be run by the test suite is the
order determined by sorting the test function names using the
\function{cmp()} built-in function.
will create a test suite that will run
\code{WidgetTestCase.testDefaultSize()} and \code{WidgetTestCase.testResize}.
\class{TestLoader} uses the \code{'test'} method name prefix to identify
test methods automatically.
Note that the order in which the various test cases will be run is
determined by sorting the test function names with the built-in
\function{cmp()} function.
Often it is desirable to group suites of test cases together, so as to
run tests for the whole system at once. This is easy, since
@ -385,13 +385,13 @@ as \class{TestCase} instances can be added to a \class{TestSuite}:
\begin{verbatim}
suite1 = module1.TheTestSuite()
suite2 = module2.TheTestSuite()
alltests = unittest.TestSuite((suite1, suite2))
alltests = unittest.TestSuite([suite1, suite2])
\end{verbatim}
You can place the definitions of test cases and test suites in the
same modules as the code they are to test (such as \file{widget.py}),
but there are several advantages to placing the test code in a
separate module, such as \file{widgettests.py}:
separate module, such as \file{test_widget.py}:
\begin{itemize}
\item The test module can be run standalone from the command line.
@ -412,13 +412,12 @@ separate module, such as \file{widgettests.py}:
\label{legacy-unit-tests}}
Some users will find that they have existing test code that they would
like to run from PyUnit, without converting every old test function to
a \class{TestCase} subclass.
like to run from \module{unittest}, without converting every old test
function to a \class{TestCase} subclass.
For this reason, PyUnit provides a \class{FunctionTestCase} class.
This subclass of \class{TestCase} can be used to wrap an existing test
function. Set-up and tear-down functions can also optionally be
wrapped.
For this reason, \module{unittest} provides a \class{FunctionTestCase}
class. This subclass of \class{TestCase} can be used to wrap an existing
test function. Set-up and tear-down functions can also be provided.
Given the following test function:
@ -436,7 +435,8 @@ testcase = unittest.FunctionTestCase(testSomething)
\end{verbatim}
If there are additional set-up and tear-down methods that should be
called as part of the test case's operation, they can also be provided:
called as part of the test case's operation, they can also be provided
like so:
\begin{verbatim}
testcase = unittest.FunctionTestCase(testSomething,
@ -444,9 +444,19 @@ testcase = unittest.FunctionTestCase(testSomething,
tearDown=deleteSomethingDB)
\end{verbatim}
\note{PyUnit supports the use of \exception{AssertionError}
as an indicator of test failure, but does not recommend it. Future
versions may treat \exception{AssertionError} differently.}
To make migrating existing test suites easier, \module{unittest}
supports tests raising \exception{AssertionError} to indicate test failure.
However, it is recommended that you use the explicit
\method{TestCase.fail*()} and \method{TestCase.assert*()} methods instead,
as future versions of \module{unittest} may treat \exception{AssertionError}
differently.
\note{Even though \class{FunctionTestCase} can be used to quickly convert
an existing test base over to a \module{unittest}-based system, this
approach is not recommended. Taking the time to set up proper
\class{TestCase} subclasses will make future test refactorings infinitely
easier.}
\subsection{Classes and functions
@ -454,11 +464,12 @@ versions may treat \exception{AssertionError} differently.}
\begin{classdesc}{TestCase}{}
Instances of the \class{TestCase} class represent the smallest
testable units in a set of tests. This class is intended to be used
as a base class, with specific tests being implemented by concrete
subclasses. This class implements the interface needed by the test
runner to allow it to drive the test, and methods that the test code
can use to check for and report various kinds of failures.
testable units in the \module{unittest} universe. This class is
intended to be used as a base class, with specific tests being
implemented by concrete subclasses. This class implements the
interface needed by the test runner to allow it to drive the
test, and methods that the test code can use to check for and
report various kinds of failure.
\end{classdesc}
\begin{classdesc}{FunctionTestCase}{testFunc\optional{,
@ -474,33 +485,33 @@ versions may treat \exception{AssertionError} differently.}
\begin{classdesc}{TestSuite}{\optional{tests}}
This class represents an aggregation of individual tests cases and
test suites. The class presents the interface needed by the test
runner to allow it to be run as any other test case, but all the
contained tests and test suites are executed. Additional methods
are provided to add test cases and suites to the aggregation. If
\var{tests} is given, it must be a sequence of individual tests that
will be added to the suite.
runner to allow it to be run as any other test case. Running a
\class{TestSuite} instance is the same as iterating over the suite,
running each test individually.
If \var{tests} is given, it must be an iterable of individual test cases or
other test suites that will be used to build the suite initially.
Additional methods are provided to add test cases and suites to the
collection later on.
\end{classdesc}
\begin{classdesc}{TestLoader}{}
This class is responsible for loading tests according to various
criteria and returning them wrapped in a \class{TestSuite}.
It can load all tests within a given module or \class{TestCase}
class. When loading from a module, it considers all
\class{TestCase}-derived classes. For each such class, it creates
an instance for each method with a name beginning with the string
\samp{test}.
subclass.
\end{classdesc}
\begin{datadesc}{defaultTestLoader}
Instance of the \class{TestLoader} class which can be shared. If no
Instance of the \class{TestLoader} class intended to be shared. If no
customization of the \class{TestLoader} is needed, this instance can
always be used instead of creating new instances.
be used instead of repeatedly creating new instances.
\end{datadesc}
\begin{classdesc}{TextTestRunner}{\optional{stream\optional{,
descriptions\optional{, verbosity}}}}
A basic test runner implementation which prints results on standard
output. It has a few configurable parameters, but is essentially
error. It has a few configurable parameters, but is essentially
very simple. Graphical applications which run test suites should
provide alternate implementations.
\end{classdesc}
@ -510,7 +521,8 @@ versions may treat \exception{AssertionError} differently.}
testRunner\optional{, testRunner}}}}}}
A command-line program that runs a set of tests; this is primarily
for making test modules conveniently executable. The simplest use
for this function is:
for this function is to include the following line at the end of a
test script:
\begin{verbatim}
if __name__ == '__main__':
@ -518,10 +530,11 @@ if __name__ == '__main__':
\end{verbatim}
\end{funcdesc}
In some cases, the existing tests may have be written using the
In some cases, the existing tests may have been written using the
\refmodule{doctest} module. If so, that module provides a
\class{DocTestSuite} class that can automatically build
\class{unittest.TestSuite} instances from the existing test code.
\class{unittest.TestSuite} instances from the existing
\module{doctest}-based tests.
\versionadded{2.3}
@ -538,7 +551,7 @@ used to run the test, another used by the test implementation to
check conditions and report failures, and some inquiry methods
allowing information about the test itself to be gathered.
Methods in the first group are:
Methods in the first group (running the test) are:
\begin{methoddesc}[TestCase]{setUp}{}
Method called to prepare the test fixture. This is called
@ -562,8 +575,10 @@ Methods in the first group are:
Run the test, collecting the result into the test result object
passed as \var{result}. If \var{result} is omitted or \constant{None},
a temporary result object is created and used, but is not made
available to the caller. This is equivalent to simply calling the
\class{TestCase} instance.
available to the caller.
The same effect may be had by simply calling the \class{TestCase}
instance.
\end{methoddesc}
\begin{methoddesc}[TestCase]{debug}{}
@ -664,10 +679,8 @@ Testing frameworks can use the following methods to collect
information on the test:
\begin{methoddesc}[TestCase]{countTestCases}{}
Return the number of tests represented by the this test object. For
\class{TestCase} instances, this will always be \code{1}, but this
method is also implemented by the \class{TestSuite} class, which can
return larger values.
Return the number of tests represented by this test object. For
\class{TestCase} instances, this will always be \code{1}.
\end{methoddesc}
\begin{methoddesc}[TestCase]{defaultTestResult}{}
@ -678,7 +691,7 @@ information on the test:
\begin{methoddesc}[TestCase]{id}{}
Return a string identifying the specific test case. This is usually
the full name of the test method, including the module and class
names.
name.
\end{methoddesc}
\begin{methoddesc}[TestCase]{shortDescription}{}
@ -694,21 +707,23 @@ information on the test:
\class{TestSuite} objects behave much like \class{TestCase} objects,
except they do not actually implement a test. Instead, they are used
to aggregate tests into groups that should be run together. Some
additional methods are available to add tests to \class{TestSuite}
to aggregate tests into groups of tests that should be run together.
Some additional methods are available to add tests to \class{TestSuite}
instances:
\begin{methoddesc}[TestSuite]{addTest}{test}
Add a \class{TestCase} or \class{TestSuite} to the set of tests that
make up the suite.
Add a \class{TestCase} or \class{TestSuite} to the suite.
\end{methoddesc}
\begin{methoddesc}[TestSuite]{addTests}{tests}
Add all the tests from a sequence of \class{TestCase} and
Add all the tests from an iterable of \class{TestCase} and
\class{TestSuite} instances to this test suite.
This is equivalent to iterating over \var{tests}, calling
\method{addTest()} for each element.
\end{methoddesc}
The \method{run()} method is also slightly different:
\class{TestSuite} shares the following methods with \class{TestCase}:
\begin{methoddesc}[TestSuite]{run}{result}
Run the tests associated with this suite, collecting the result into
@ -717,6 +732,17 @@ The \method{run()} method is also slightly different:
result object to be passed in.
\end{methoddesc}
\begin{methoddesc}[TestSuite]{debug}{}
Run the tests associated with this suite without collecting the result.
This allows exceptions raised by the test to be propagated to the caller
and can be used to support running tests under a debugger.
\end{methoddesc}
\begin{methoddesc}[TestSuite]{countTestCases}{}
Return the number of tests represented by this test object, including
all individual tests and sub-suites.
\end{methoddesc}
In the typical usage of a \class{TestSuite} object, the \method{run()}
method is invoked by a \class{TestRunner} rather than by the end-user
test harness.
@ -727,7 +753,7 @@ test harness.
A \class{TestResult} object stores the results of a set of tests. The
\class{TestCase} and \class{TestSuite} classes ensure that results are
properly stored; test authors do not need to worry about recording the
properly recorded; test authors do not need to worry about recording the
outcome of tests.
Testing frameworks built on top of \refmodule{unittest} may want
@ -745,28 +771,41 @@ formatted version of the traceback for the exception.
be of interest when inspecting the results of running a set of tests:
\begin{memberdesc}[TestResult]{errors}
A list containing pairs of \class{TestCase} instances and the
formatted tracebacks for tests which raised an exception but did not
signal a test failure.
A list containing 2-tuples of \class{TestCase} instances and
formatted tracebacks. Each tuple represents a test which raised an
unexpected exception.
\versionchanged[Contains formatted tracebacks instead of
\function{sys.exc_info()} results]{2.2}
\end{memberdesc}
\begin{memberdesc}[TestResult]{failures}
A list containing pairs of \class{TestCase} instances and the
formatted tracebacks for tests which signalled a failure in the code
under test.
A list containing 2-tuples of \class{TestCase} instances and
formatted tracebacks. Each tuple represents a test where a failure
was explicitly signalled using the \method{TestCase.fail*()} or
\method{TestCase.assert*()} methods.
\versionchanged[Contains formatted tracebacks instead of
\function{sys.exc_info()} results]{2.2}
\end{memberdesc}
\begin{memberdesc}[TestResult]{testsRun}
The number of tests which have been started.
The total number of tests run so far.
\end{memberdesc}
\begin{methoddesc}[TestResult]{wasSuccessful}{}
Returns true if all tests run so far have passed, otherwise returns
false.
Returns \constant{True} if all tests run so far have passed,
otherwise returns \constant{False}.
\end{methoddesc}
\begin{methoddesc}[TestResult]{stop}{}
This method can be called to signal that the set of tests being run
should be aborted by setting the \class{TestResult}'s \code{shouldStop}
attribute to \constant{True}. \class{TestRunner} objects should respect
this flag and return without running any additional tests.
For example, this feature is used by the \class{TextTestRunner} class
to stop the test framework when the user signals an interrupt from
the keyboard. Interactive tools which provide \class{TestRunner}
implementations can use this in a similar manner.
\end{methoddesc}
@ -786,10 +825,9 @@ reporting while tests are being run.
\end{methoddesc}
\begin{methoddesc}[TestResult]{addError}{test, err}
Called when the test case \var{test} raises an exception without
signalling a test failure. \var{err} is a tuple of the form
returned by \function{sys.exc_info()}: \code{(\var{type},
\var{value}, \var{traceback})}.
Called when the test case \var{test} raises an unexpected exception
\var{err} is a tuple of the form returned by \function{sys.exc_info()}:
\code{(\var{type}, \var{value}, \var{traceback})}.
\end{methoddesc}
\begin{methoddesc}[TestResult]{addFailure}{test, err}
@ -800,23 +838,10 @@ reporting while tests are being run.
\end{methoddesc}
\begin{methoddesc}[TestResult]{addSuccess}{test}
This method is called for a test that does not fail; \var{test} is
the test case object.
Called when the test case \var{test} succeeds.
\end{methoddesc}
One additional method is available for \class{TestResult} objects:
\begin{methoddesc}[TestResult]{stop}{}
This method can be called to signal that the set of tests being run
should be aborted. Once this has been called, the
\class{TestRunner} object return to its caller without running any
additional tests. This is used by the \class{TextTestRunner} class
to stop the test framework when the user signals an interrupt from
the keyboard. Interactive tools which provide runners can use this
in a similar manner.
\end{methoddesc}
\subsection{TestLoader Objects
\label{testloader-objects}}
@ -824,15 +849,15 @@ One additional method is available for \class{TestResult} objects:
The \class{TestLoader} class is used to create test suites from
classes and modules. Normally, there is no need to create an instance
of this class; the \refmodule{unittest} module provides an instance
that can be shared as the \code{defaultTestLoader} module attribute.
Using a subclass or instance would allow customization of some
that can be shared as \code{unittest.defaultTestLoader}.
Using a subclass or instance, however, allows customization of some
configurable properties.
\class{TestLoader} objects have the following methods:
\begin{methoddesc}[TestLoader]{loadTestsFromTestCase}{testCaseClass}
Return a suite of all tests cases contained in the
\class{TestCase}-derived class \class{testCaseClass}.
\class{TestCase}-derived \class{testCaseClass}.
\end{methoddesc}
\begin{methoddesc}[TestLoader]{loadTestsFromModule}{module}
@ -842,7 +867,7 @@ configurable properties.
method defined for the class.
\warning{While using a hierarchy of
\class{Testcase}-derived classes can be convenient in sharing
\class{TestCase}-derived classes can be convenient in sharing
fixtures and helper functions, defining test methods on base classes
that are not intended to be instantiated directly does not play well
with this method. Doing so, however, can be useful when the
@ -853,21 +878,23 @@ configurable properties.
Return a suite of all tests cases given a string specifier.
The specifier \var{name} is a ``dotted name'' that may resolve
either to a module, a test case class, a test method within a test
case class, or a callable object which returns a \class{TestCase} or
\class{TestSuite} instance. For example, if you have a module
\module{SampleTests} containing a \class{TestCase}-derived class
\class{SampleTestCase} with three test methods (\method{test_one()},
\method{test_two()}, and \method{test_three()}), the specifier
\code{'SampleTests.SampleTestCase'} would cause this method to
return a suite which will run all three test methods. Using the
specifier \code{'SampleTests.SampleTestCase.test_two'} would cause
it to return a test suite which will run only the
either to a module, a test case class, a \class{TestSuite} instance,
a test method within a test case class, or a callable object which
returns a \class{TestCase} or \class{TestSuite} instance.
For example, if you have a module \module{SampleTests} containing a
\class{TestCase}-derived class \class{SampleTestCase} with three test
methods (\method{test_one()}, \method{test_two()}, and
\method{test_three()}), the specifier \code{'SampleTests.SampleTestCase'}
would cause this method to return a suite which will run all three test
methods. Using the specifier \code{'SampleTests.SampleTestCase.test_two'}
would cause it to return a test suite which will run only the
\method{test_two()} test method. The specifier can refer to modules
and packages which have not been imported; they will be imported as
a side-effect.
The method optionally resolves \var{name} relative to a given module.
The method optionally resolves \var{name} relative to the given
\var{module}.
\end{methoddesc}
\begin{methoddesc}[TestLoader]{loadTestsFromNames}{names\optional{, module}}
@ -888,17 +915,22 @@ either by subclassing or assignment on an instance:
\begin{memberdesc}[TestLoader]{testMethodPrefix}
String giving the prefix of method names which will be interpreted
as test methods. The default value is \code{'test'}.
This affects \method{getTestCaseNames()} and all the
\method{loadTestsFrom*()} methods.
\end{memberdesc}
\begin{memberdesc}[TestLoader]{sortTestMethodsUsing}
Function to be used to compare method names when sorting them in
\method{getTestCaseNames()}. The default value is the built-in
\function{cmp()} function; it can be set to \constant{None} to disable
the sort.
\method{getTestCaseNames()} and all the \method{loadTestsFrom*()} methods.
The default value is the built-in \function{cmp()} function; the attribute
can also be set to \constant{None} to disable the sort.
\end{memberdesc}
\begin{memberdesc}[TestLoader]{suiteClass}
Callable object that constructs a test suite from a list of tests.
No methods on the resulting object are needed. The default value is
the \class{TestSuite} class.
This affects all the \method{loadTestsFrom*()} methods.
\end{memberdesc}

View File

@ -270,10 +270,10 @@ off completely. Its default value is \code{None}, in which case
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.

View File

@ -19,7 +19,8 @@ Open the URL \var{url}, which can be either a string or a \class{Request}
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 @@ The following classes are provided:
\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.

234
Doc/lib/libuuid.tex Normal file
View File

@ -0,0 +1,234 @@
\section{\module{uuid} ---
UUID objects according to RFC 4122}
\declaremodule{builtin}{uuid}
\modulesynopsis{UUID objects (universally unique identifiers) according to RFC 4122}
\moduleauthor{Ka-Ping Yee}{ping@zesty.ca}
\sectionauthor{George Yoshida}{quiver@users.sourceforge.net}
\versionadded{2.5}
This module provides immutable \class{UUID} objects (the \class{UUID} class)
and the functions \function{uuid1()}, \function{uuid3()},
\function{uuid4()}, \function{uuid5()} for generating version 1, 3, 4,
and 5 UUIDs as specified in \rfc{4122}.
If all you want is a unique ID, you should probably call
\function{uuid1()} or \function{uuid4()}. Note that \function{uuid1()}
may compromise privacy since it creates a UUID containing the computer's
network address. \function{uuid4()} creates a random UUID.
\begin{classdesc}{UUID}{\optional{hex\optional{, bytes\optional{,
fields\optional{, int\optional{, version}}}}}}
%Instances of the UUID class represent UUIDs as specified in RFC 4122.
%UUID objects are immutable, hashable, and usable as dictionary keys.
%Converting a UUID to a string with str() yields something in the form
%'12345678-1234-1234-1234-123456789abc'. The UUID constructor accepts
%four possible forms: a similar string of hexadecimal digits, or a
%string of 16 raw bytes as an argument named 'bytes', or a tuple of
%six integer fields (with 32-bit, 16-bit, 16-bit, 8-bit, 8-bit, and
%48-bit values respectively) as an argument named 'fields', or a single
%128-bit integer as an argument named 'int'.
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},
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}
argument. When a string of hex digits is given, curly braces,
hyphens, and a URN prefix are all optional. For example, these
expressions all yield the same UUID:
\begin{verbatim}
UUID('{12345678-1234-5678-1234-567812345678}')
UUID('12345678123456781234567812345678')
UUID('urn:uuid:12345678-1234-5678-1234-567812345678')
UUID(bytes='\x12\x34\x56\x78'*4)
UUID(fields=(0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x567812345678))
UUID(int=0x12345678123456781234567812345678)
\end{verbatim}
Exactly one of \var{hex}, \var{bytes}, \var{fields}, or \var{int} must
be given. The \var{version} argument is optional; if given, the
resulting UUID will have its variant and version number set according to
RFC 4122, overriding bits in the given \var{hex}, \var{bytes},
\var{fields}, or \var{int}.
\end{classdesc}
\class{UUID} instances have these read-only attributes:
\begin{memberdesc}{bytes}
The UUID as a 16-byte string.
\end{memberdesc}
\begin{memberdesc}{fields}
A tuple of the six integer fields of the UUID, which are also available
as six individual attributes and two derived attributes:
\begin{tableii}{l|l}{member}{Field}{Meaning}
\lineii{time_low}{the first 32 bits of the UUID}
\lineii{time_mid}{the next 16 bits of the UUID}
\lineii{time_hi_version}{the next 16 bits of the UUID}
\lineii{clock_seq_hi_variant}{the next 8 bits of the UUID}
\lineii{clock_seq_low}{the next 8 bits of the UUID}
\lineii{node}{the last 48 bits of the UUID}
\lineii{time}{the 60-bit timestamp}
\lineii{clock_seq}{the 14-bit sequence number}
\end{tableii}
\end{memberdesc}
\begin{memberdesc}{hex}
The UUID as a 32-character hexadecimal string.
\end{memberdesc}
\begin{memberdesc}{int}
The UUID as a 128-bit integer.
\end{memberdesc}
\begin{memberdesc}{urn}
The UUID as a URN as specified in RFC 4122.
\end{memberdesc}
\begin{memberdesc}{variant}
The UUID variant, which determines the internal layout of the UUID.
This will be an integer equal to one of the constants
\constant{RESERVED_NCS},
\constant{RFC_4122}, \constant{RESERVED_MICROSOFT}, or
\constant{RESERVED_FUTURE}).
\end{memberdesc}
\begin{memberdesc}{version}
The UUID version number (1 through 5, meaningful only
when the variant is \constant{RFC_4122}).
\end{memberdesc}
The \module{uuid} module defines the following functions
\begin{funcdesc}{getnode}{}
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. "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}
\begin{funcdesc}{uuid1}{\optional{node\optional{, clock_seq}}}
Generate a UUID from a host ID, sequence number, and the current time.
If \var{node} is not given, \function{getnode()} is used to obtain the
hardware address.
If \var{clock_seq} is given, it is used as the sequence number;
otherwise a random 14-bit sequence number is chosen.
\end{funcdesc}
\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}
must be one of \constant{NAMESPACE_DNS},
\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID},
or \constant{NAMESPACE_X500}.
\end{funcdesc}
\index{uuid3}
\begin{funcdesc}{uuid4}{}
Generate a random UUID.
\end{funcdesc}
\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}
must be one of \constant{NAMESPACE_DNS},
\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID},
or \constant{NAMESPACE_X500}.
\end{funcdesc}
\index{uuid5}
The \module{uuid} module defines the following namespace constants
for use with \function{uuid3()} or \function{uuid5()}.
\begin{datadesc}{NAMESPACE_DNS}
Fully-qualified domain name namespace UUID.
\end{datadesc}
\begin{datadesc}{NAMESPACE_URL}
URL namespace UUID.
\end{datadesc}
\begin{datadesc}{NAMESPACE_OID}
ISO OID namespace UUID.
\end{datadesc}
\begin{datadesc}{NAMESPACE_X500}
X.500 DN namespace UUID.
\end{datadesc}
The \module{uuid} module defines the following constants
for the possible values of the \member{variant} attribute:
\begin{datadesc}{RESERVED_NCS}
Reserved for NCS compatibility.
\end{datadesc}
\begin{datadesc}{RFC_4122}
Uses UUID layout specified in \rfc{4122}.
\end{datadesc}
\begin{datadesc}{RESERVED_MICROSOFT}
Reserved for Microsoft backward compatibility.
\end{datadesc}
\begin{datadesc}{RESERVED_FUTURE}
Reserved for future definition.
\end{datadesc}
\begin{seealso}
\seerfc{4122}{A Universally Unique IDentifier (UUID) URN Namespace}{
This specifies a Uniform Resource Name namespace for UUIDs.}
\end{seealso}
\subsection{Example \label{uuid-example}}
Here is a typical usage:
\begin{verbatim}
>>> import uuid
# make a UUID based on the host ID and current time
>>> uuid.uuid1()
UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
# make a UUID using an MD5 hash of a namespace UUID and a name
>>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
# make a random UUID
>>> uuid.uuid4()
UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
# make a UUID using a SHA-1 hash of a namespace UUID and a name
>>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')
# make a UUID from a string of hex digits (braces and hyphens ignored)
>>> x = uuid.UUID('{00010203-0405-0607-0809-0a0b0c0d0e0f}')
# convert a UUID to a string of hex digits in standard form
>>> str(x)
'00010203-0405-0607-0809-0a0b0c0d0e0f'
# get the raw 16 bytes of the UUID
>>> x.bytes
'\x00\x01\x02\x03\x04\x05\x06\x07\x08\t\n\x0b\x0c\r\x0e\x0f'
# make a UUID from a 16-byte string
>>> uuid.UUID(bytes=x.bytes)
UUID('00010203-0405-0607-0809-0a0b0c0d0e0f')
\end{verbatim}

View File

@ -71,6 +71,11 @@ runtime features.}
\lineii{FutureWarning}{Base category for warnings about constructs
that will change semantically in the future.}
\lineii{PendingDeprecationWarning}{Base category for warnings about
features that will be deprecated in the future (ignored by default).}
\lineii{ImportWarning}{Base category for warnings triggered during the
process of importing a module (ignored by default).}
\end{tableii}
While these are technically built-in exceptions, they are documented
@ -143,6 +148,17 @@ arguments for all \programopt{-W} options without interpretation in
it is first imported (invalid options are ignored, after printing a
message to \code{sys.stderr}).
The warnings that are ignored by default may be enabled by passing
\programopt{-Wd} to the interpreter. This enables default handling
for all warnings, including those that are normally ignored by
default. This is particular useful for enabling ImportWarning when
debugging problems importing a developed package. ImportWarning can
also be enabled explicitly in Python code using:
\begin{verbatim}
warnings.simplefilter('default', ImportWarning)
\end{verbatim}
\subsection{Available Functions \label{warning-functions}}
@ -209,14 +225,26 @@ Insert an entry into the list of warnings filters. The entry is
inserted at the front by default; if \var{append} is true, it is
inserted at the end.
This checks the types of the arguments, compiles the message and
module regular expressions, and inserts them as a tuple in front
of the warnings filter. Entries inserted later override entries
inserted earlier, if both match a particular warning. Omitted
arguments default to a value that matches everything.
module regular expressions, and inserts them as a tuple in the
list of warnings filters. Entries closer to the front of the list
override entries later in the list, if both match a particular
warning. Omitted arguments default to a value that matches
everything.
\end{funcdesc}
\begin{funcdesc}{simplefilter}{action\optional{,
category\optional{,
lineno\optional{, append}}}}
Insert a simple entry into the list of warnings filters. The meaning
of the function parameters is as for \function{filterwarnings()}, but
regular expressions are not needed as the filter inserted always
matches any message in any module as long as the category and line
number match.
\end{funcdesc}
\begin{funcdesc}{resetwarnings}{}
Reset the warnings filter. This discards the effect of all previous
calls to \function{filterwarnings()}, including that of the
\programopt{-W} command line options.
\programopt{-W} command line options and calls to
\function{simplefilter()}.
\end{funcdesc}

View File

@ -65,10 +65,14 @@ class Dict(dict):
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 remember(obj):
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}

View File

@ -136,6 +136,18 @@ Library Modules} manual.
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}}

781
Doc/lib/libwsgiref.tex Executable file
View File

@ -0,0 +1,781 @@
\section{\module{wsgiref} --- WSGI Utilities and Reference
Implementation}
\declaremodule{}{wsgiref}
\moduleauthor{Phillip J. Eby}{pje@telecommunity.com}
\sectionauthor{Phillip J. Eby}{pje@telecommunity.com}
\modulesynopsis{WSGI Utilities and Reference Implementation}
\versionadded{2.5}
The Web Server Gateway Interface (WSGI) is a standard interface
between web server software and web applications written in Python.
Having a standard interface makes it easy to use an application
that supports WSGI with a number of different web servers.
Only authors of web servers and programming frameworks need to know
every detail and corner case of the WSGI design. You don't need to
understand every detail of WSGI just to install a WSGI application or
to write a web application using an existing framework.
\module{wsgiref} is a reference implementation of the WSGI specification
that can be used to add WSGI support to a web server or framework. It
provides utilities for manipulating WSGI environment variables and
response headers, base classes for implementing WSGI servers, a demo
HTTP server that serves WSGI applications, and a validation tool that
checks WSGI servers and applications for conformance to the
WSGI specification (\pep{333}).
% XXX If you're just trying to write a web application...
% XXX should create a URL on python.org to point people to.
\subsection{\module{wsgiref.util} -- WSGI environment utilities}
\declaremodule{}{wsgiref.util}
This module provides a variety of utility functions for working with
WSGI environments. A WSGI environment is a dictionary containing
HTTP request variables as described in \pep{333}. All of the functions
taking an \var{environ} parameter expect a WSGI-compliant dictionary to
be supplied; please see \pep{333} for a detailed specification.
\begin{funcdesc}{guess_scheme}{environ}
Return a guess for whether \code{wsgi.url_scheme} should be ``http'' or
``https'', by checking for a \code{HTTPS} environment variable in the
\var{environ} dictionary. The return value is a string.
This function is useful when creating a gateway that wraps CGI or a
CGI-like protocol such as FastCGI. Typically, servers providing such
protocols will include a \code{HTTPS} variable with a value of ``1''
``yes'', or ``on'' when a request is received via SSL. So, this
function returns ``https'' if such a value is found, and ``http''
otherwise.
\end{funcdesc}
\begin{funcdesc}{request_uri}{environ \optional{, include_query=1}}
Return the full request URI, optionally including the query string,
using the algorithm found in the ``URL Reconstruction'' section of
\pep{333}. If \var{include_query} is false, the query string is
not included in the resulting URI.
\end{funcdesc}
\begin{funcdesc}{application_uri}{environ}
Similar to \function{request_uri}, except that the \code{PATH_INFO} and
\code{QUERY_STRING} variables are ignored. The result is the base URI
of the application object addressed by the request.
\end{funcdesc}
\begin{funcdesc}{shift_path_info}{environ}
Shift a single name from \code{PATH_INFO} to \code{SCRIPT_NAME} and
return the name. The \var{environ} dictionary is \emph{modified}
in-place; use a copy if you need to keep the original \code{PATH_INFO}
or \code{SCRIPT_NAME} intact.
If there are no remaining path segments in \code{PATH_INFO}, \code{None}
is returned.
Typically, this routine is used to process each portion of a request
URI path, for example to treat the path as a series of dictionary keys.
This routine modifies the passed-in environment to make it suitable for
invoking another WSGI application that is located at the target URI.
For example, if there is a WSGI application at \code{/foo}, and the
request URI path is \code{/foo/bar/baz}, and the WSGI application at
\code{/foo} calls \function{shift_path_info}, it will receive the string
``bar'', and the environment will be updated to be suitable for passing
to a WSGI application at \code{/foo/bar}. That is, \code{SCRIPT_NAME}
will change from \code{/foo} to \code{/foo/bar}, and \code{PATH_INFO}
will change from \code{/bar/baz} to \code{/baz}.
When \code{PATH_INFO} is just a ``/'', this routine returns an empty
string and appends a trailing slash to \code{SCRIPT_NAME}, even though
empty path segments are normally ignored, and \code{SCRIPT_NAME} doesn't
normally end in a slash. This is intentional behavior, to ensure that
an application can tell the difference between URIs ending in \code{/x}
from ones ending in \code{/x/} when using this routine to do object
traversal.
\end{funcdesc}
\begin{funcdesc}{setup_testing_defaults}{environ}
Update \var{environ} with trivial defaults for testing purposes.
This routine adds various parameters required for WSGI, including
\code{HTTP_HOST}, \code{SERVER_NAME}, \code{SERVER_PORT},
\code{REQUEST_METHOD}, \code{SCRIPT_NAME}, \code{PATH_INFO}, and all of
the \pep{333}-defined \code{wsgi.*} variables. It only supplies default
values, and does not replace any existing settings for these variables.
This routine is intended to make it easier for unit tests of WSGI
servers and applications to set up dummy environments. It should NOT
be used by actual WSGI servers or applications, since the data is fake!
\end{funcdesc}
In addition to the environment functions above, the
\module{wsgiref.util} module also provides these miscellaneous
utilities:
\begin{funcdesc}{is_hop_by_hop}{header_name}
Return true if 'header_name' is an HTTP/1.1 ``Hop-by-Hop'' header, as
defined by \rfc{2616}.
\end{funcdesc}
\begin{classdesc}{FileWrapper}{filelike \optional{, blksize=8192}}
A wrapper to convert a file-like object to an iterator. The resulting
objects support both \method{__getitem__} and \method{__iter__}
iteration styles, for compatibility with Python 2.1 and Jython.
As the object is iterated over, the optional \var{blksize} parameter
will be repeatedly passed to the \var{filelike} object's \method{read()}
method to obtain strings to yield. When \method{read()} returns an
empty string, iteration is ended and is not resumable.
If \var{filelike} has a \method{close()} method, the returned object
will also have a \method{close()} method, and it will invoke the
\var{filelike} object's \method{close()} method when called.
\end{classdesc}
\subsection{\module{wsgiref.headers} -- WSGI response header tools}
\declaremodule{}{wsgiref.headers}
This module provides a single class, \class{Headers}, for convenient
manipulation of WSGI response headers using a mapping-like interface.
\begin{classdesc}{Headers}{headers}
Create a mapping-like object wrapping \var{headers}, which must be a
list of header name/value tuples as described in \pep{333}. Any changes
made to the new \class{Headers} object will directly update the
\var{headers} list it was created with.
\class{Headers} objects support typical mapping operations including
\method{__getitem__}, \method{get}, \method{__setitem__},
\method{setdefault}, \method{__delitem__}, \method{__contains__} and
\method{has_key}. For each of these methods, the key is the header name
(treated case-insensitively), and the value is the first value
associated with that header name. Setting a header deletes any existing
values for that header, then adds a new value at the end of the wrapped
header list. Headers' existing order is generally maintained, with new
headers added to the end of the wrapped list.
Unlike a dictionary, \class{Headers} objects do not raise an error when
you try to get or delete a key that isn't in the wrapped header list.
Getting a nonexistent header just returns \code{None}, and deleting
a nonexistent header does nothing.
\class{Headers} objects also support \method{keys()}, \method{values()},
and \method{items()} methods. The lists returned by \method{keys()}
and \method{items()} can include the same key more than once if there
is a multi-valued header. The \code{len()} of a \class{Headers} object
is the same as the length of its \method{items()}, which is the same
as the length of the wrapped header list. In fact, the \method{items()}
method just returns a copy of the wrapped header list.
Calling \code{str()} on a \class{Headers} object returns a formatted
string suitable for transmission as HTTP response headers. Each header
is placed on a line with its value, separated by a colon and a space.
Each line is terminated by a carriage return and line feed, and the
string is terminated with a blank line.
In addition to their mapping interface and formatting features,
\class{Headers} objects also have the following methods for querying
and adding multi-valued headers, and for adding headers with MIME
parameters:
\begin{methoddesc}{get_all}{name}
Return a list of all the values for the named header.
The returned list will be sorted in the order they appeared in the
original header list or were added to this instance, and may contain
duplicates. Any fields deleted and re-inserted are always appended to
the header list. If no fields exist with the given name, returns an
empty list.
\end{methoddesc}
\begin{methoddesc}{add_header}{name, value, **_params}
Add a (possibly multi-valued) header, with optional MIME parameters
specified via keyword arguments.
\var{name} is the header field to add. Keyword arguments can be used to
set MIME parameters for the header field. Each parameter must be a
string or \code{None}. Underscores in parameter names are converted to
dashes, since dashes are illegal in Python identifiers, but many MIME
parameter names include dashes. If the parameter value is a string, it
is added to the header value parameters in the form \code{name="value"}.
If it is \code{None}, only the parameter name is added. (This is used
for MIME parameters without a value.) Example usage:
\begin{verbatim}
h.add_header('content-disposition', 'attachment', filename='bud.gif')
\end{verbatim}
The above will add a header that looks like this:
\begin{verbatim}
Content-Disposition: attachment; filename="bud.gif"
\end{verbatim}
\end{methoddesc}
\end{classdesc}
\subsection{\module{wsgiref.simple_server} -- a simple WSGI HTTP server}
\declaremodule[wsgiref.simpleserver]{}{wsgiref.simple_server}
This module implements a simple HTTP server (based on
\module{BaseHTTPServer}) that serves WSGI applications. Each server
instance serves a single WSGI application on a given host and port. If
you want to serve multiple applications on a single host and port, you
should create a WSGI application that parses \code{PATH_INFO} to select
which application to invoke for each request. (E.g., using the
\function{shift_path_info()} function from \module{wsgiref.util}.)
\begin{funcdesc}{make_server}{host, port, app
\optional{, server_class=\class{WSGIServer} \optional{,
handler_class=\class{WSGIRequestHandler}}}}
Create a new WSGI server listening on \var{host} and \var{port},
accepting connections for \var{app}. The return value is an instance of
the supplied \var{server_class}, and will process requests using the
specified \var{handler_class}. \var{app} must be a WSGI application
object, as defined by \pep{333}.
Example usage:
\begin{verbatim}from wsgiref.simple_server import make_server, demo_app
httpd = make_server('', 8000, demo_app)
print "Serving HTTP on port 8000..."
# Respond to requests until process is killed
httpd.serve_forever()
# Alternative: serve one request, then exit
##httpd.handle_request()
\end{verbatim}
\end{funcdesc}
\begin{funcdesc}{demo_app}{environ, start_response}
This function is a small but complete WSGI application that
returns a text page containing the message ``Hello world!''
and a list of the key/value pairs provided in the
\var{environ} parameter. It's useful for verifying that a WSGI server
(such as \module{wsgiref.simple_server}) is able to run a simple WSGI
application correctly.
\end{funcdesc}
\begin{classdesc}{WSGIServer}{server_address, RequestHandlerClass}
Create a \class{WSGIServer} instance. \var{server_address} should be
a \code{(host,port)} tuple, and \var{RequestHandlerClass} should be
the subclass of \class{BaseHTTPServer.BaseHTTPRequestHandler} that will
be used to process requests.
You do not normally need to call this constructor, as the
\function{make_server()} function can handle all the details for you.
\class{WSGIServer} is a subclass
of \class{BaseHTTPServer.HTTPServer}, so all of its methods (such as
\method{serve_forever()} and \method{handle_request()}) are available.
\class{WSGIServer} also provides these WSGI-specific methods:
\begin{methoddesc}{set_app}{application}
Sets the callable \var{application} as the WSGI application that will
receive requests.
\end{methoddesc}
\begin{methoddesc}{get_app}{}
Returns the currently-set application callable.
\end{methoddesc}
Normally, however, you do not need to use these additional methods, as
\method{set_app()} is normally called by \function{make_server()}, and
the \method{get_app()} exists mainly for the benefit of request handler
instances.
\end{classdesc}
\begin{classdesc}{WSGIRequestHandler}{request, client_address, server}
Create an HTTP handler for the given \var{request} (i.e. a socket),
\var{client_address} (a \code{(\var{host},\var{port})} tuple), and
\var{server} (\class{WSGIServer} instance).
You do not need to create instances of this class directly; they are
automatically created as needed by \class{WSGIServer} objects. You
can, however, subclass this class and supply it as a \var{handler_class}
to the \function{make_server()} function. Some possibly relevant
methods for overriding in subclasses:
\begin{methoddesc}{get_environ}{}
Returns a dictionary containing the WSGI environment for a request. The
default implementation copies the contents of the \class{WSGIServer}
object's \member{base_environ} dictionary attribute and then adds
various headers derived from the HTTP request. Each call to this method
should return a new dictionary containing all of the relevant CGI
environment variables as specified in \pep{333}.
\end{methoddesc}
\begin{methoddesc}{get_stderr}{}
Return the object that should be used as the \code{wsgi.errors} stream.
The default implementation just returns \code{sys.stderr}.
\end{methoddesc}
\begin{methoddesc}{handle}{}
Process the HTTP request. The default implementation creates a handler
instance using a \module{wsgiref.handlers} class to implement the actual
WSGI application interface.
\end{methoddesc}
\end{classdesc}
\subsection{\module{wsgiref.validate} -- WSGI conformance checker}
\declaremodule{}{wsgiref.validate}
When creating new WSGI application objects, frameworks, servers, or
middleware, it can be useful to validate the new code's conformance
using \module{wsgiref.validate}. This module provides a function that
creates WSGI application objects that validate communications between
a WSGI server or gateway and a WSGI application object, to check both
sides for protocol conformance.
Note that this utility does not guarantee complete \pep{333} compliance;
an absence of errors from this module does not necessarily mean that
errors do not exist. However, if this module does produce an error,
then it is virtually certain that either the server or application is
not 100\% compliant.
This module is based on the \module{paste.lint} module from Ian
Bicking's ``Python Paste'' library.
\begin{funcdesc}{validator}{application}
Wrap \var{application} and return a new WSGI application object. The
returned application will forward all requests to the original
\var{application}, and will check that both the \var{application} and
the server invoking it are conforming to the WSGI specification and to
RFC 2616.
Any detected nonconformance results in an \exception{AssertionError}
being raised; note, however, that how these errors are handled is
server-dependent. For example, \module{wsgiref.simple_server} and other
servers based on \module{wsgiref.handlers} (that don't override the
error handling methods to do something else) will simply output a
message that an error has occurred, and dump the traceback to
\code{sys.stderr} or some other error stream.
This wrapper may also generate output using the \module{warnings} module
to indicate behaviors that are questionable but which may not actually
be prohibited by \pep{333}. Unless they are suppressed using Python
command-line options or the \module{warnings} API, any such warnings
will be written to \code{sys.stderr} (\emph{not} \code{wsgi.errors},
unless they happen to be the same object).
\end{funcdesc}
\subsection{\module{wsgiref.handlers} -- server/gateway base classes}
\declaremodule{}{wsgiref.handlers}
This module provides base handler classes for implementing WSGI servers
and gateways. These base classes handle most of the work of
communicating with a WSGI application, as long as they are given a
CGI-like environment, along with input, output, and error streams.
\begin{classdesc}{CGIHandler}{}
CGI-based invocation via \code{sys.stdin}, \code{sys.stdout},
\code{sys.stderr} and \code{os.environ}. This is useful when you have
a WSGI application and want to run it as a CGI script. Simply invoke
\code{CGIHandler().run(app)}, where \code{app} is the WSGI application
object you wish to invoke.
This class is a subclass of \class{BaseCGIHandler} that sets
\code{wsgi.run_once} to true, \code{wsgi.multithread} to false, and
\code{wsgi.multiprocess} to true, and always uses \module{sys} and
\module{os} to obtain the necessary CGI streams and environment.
\end{classdesc}
\begin{classdesc}{BaseCGIHandler}{stdin, stdout, stderr, environ
\optional{, multithread=True \optional{, multiprocess=False}}}
Similar to \class{CGIHandler}, but instead of using the \module{sys} and
\module{os} modules, the CGI environment and I/O streams are specified
explicitly. The \var{multithread} and \var{multiprocess} values are
used to set the \code{wsgi.multithread} and \code{wsgi.multiprocess}
flags for any applications run by the handler instance.
This class is a subclass of \class{SimpleHandler} intended for use with
software other than HTTP ``origin servers''. If you are writing a
gateway protocol implementation (such as CGI, FastCGI, SCGI, etc.) that
uses a \code{Status:} header to send an HTTP status, you probably want
to subclass this instead of \class{SimpleHandler}.
\end{classdesc}
\begin{classdesc}{SimpleHandler}{stdin, stdout, stderr, environ
\optional{,multithread=True \optional{, multiprocess=False}}}
Similar to \class{BaseCGIHandler}, but designed for use with HTTP origin
servers. If you are writing an HTTP server implementation, you will
probably want to subclass this instead of \class{BaseCGIHandler}
This class is a subclass of \class{BaseHandler}. It overrides the
\method{__init__()}, \method{get_stdin()}, \method{get_stderr()},
\method{add_cgi_vars()}, \method{_write()}, and \method{_flush()}
methods to support explicitly setting the environment and streams via
the constructor. The supplied environment and streams are stored in
the \member{stdin}, \member{stdout}, \member{stderr}, and
\member{environ} attributes.
\end{classdesc}
\begin{classdesc}{BaseHandler}{}
This is an abstract base class for running WSGI applications. Each
instance will handle a single HTTP request, although in principle you
could create a subclass that was reusable for multiple requests.
\class{BaseHandler} instances have only one method intended for external
use:
\begin{methoddesc}{run}{app}
Run the specified WSGI application, \var{app}.
\end{methoddesc}
All of the other \class{BaseHandler} methods are invoked by this method
in the process of running the application, and thus exist primarily to
allow customizing the process.
The following methods MUST be overridden in a subclass:
\begin{methoddesc}{_write}{data}
Buffer the string \var{data} for transmission to the client. It's okay
if this method actually transmits the data; \class{BaseHandler}
just separates write and flush operations for greater efficiency
when the underlying system actually has such a distinction.
\end{methoddesc}
\begin{methoddesc}{_flush}{}
Force buffered data to be transmitted to the client. It's okay if this
method is a no-op (i.e., if \method{_write()} actually sends the data).
\end{methoddesc}
\begin{methoddesc}{get_stdin}{}
Return an input stream object suitable for use as the \code{wsgi.input}
of the request currently being processed.
\end{methoddesc}
\begin{methoddesc}{get_stderr}{}
Return an output stream object suitable for use as the
\code{wsgi.errors} of the request currently being processed.
\end{methoddesc}
\begin{methoddesc}{add_cgi_vars}{}
Insert CGI variables for the current request into the \member{environ}
attribute.
\end{methoddesc}
Here are some other methods and attributes you may wish to override.
This list is only a summary, however, and does not include every method
that can be overridden. You should consult the docstrings and source
code for additional information before attempting to create a customized
\class{BaseHandler} subclass.
Attributes and methods for customizing the WSGI environment:
\begin{memberdesc}{wsgi_multithread}
The value to be used for the \code{wsgi.multithread} environment
variable. It defaults to true in \class{BaseHandler}, but may have
a different default (or be set by the constructor) in the other
subclasses.
\end{memberdesc}
\begin{memberdesc}{wsgi_multiprocess}
The value to be used for the \code{wsgi.multiprocess} environment
variable. It defaults to true in \class{BaseHandler}, but may have
a different default (or be set by the constructor) in the other
subclasses.
\end{memberdesc}
\begin{memberdesc}{wsgi_run_once}
The value to be used for the \code{wsgi.run_once} environment
variable. It defaults to false in \class{BaseHandler}, but
\class{CGIHandler} sets it to true by default.
\end{memberdesc}
\begin{memberdesc}{os_environ}
The default environment variables to be included in every request's
WSGI environment. By default, this is a copy of \code{os.environ} at
the time that \module{wsgiref.handlers} was imported, but subclasses can
either create their own at the class or instance level. Note that the
dictionary should be considered read-only, since the default value is
shared between multiple classes and instances.
\end{memberdesc}
\begin{memberdesc}{server_software}
If the \member{origin_server} attribute is set, this attribute's value
is used to set the default \code{SERVER_SOFTWARE} WSGI environment
variable, and also to set a default \code{Server:} header in HTTP
responses. It is ignored for handlers (such as \class{BaseCGIHandler}
and \class{CGIHandler}) that are not HTTP origin servers.
\end{memberdesc}
\begin{methoddesc}{get_scheme}{}
Return the URL scheme being used for the current request. The default
implementation uses the \function{guess_scheme()} function from
\module{wsgiref.util} to guess whether the scheme should be ``http'' or
``https'', based on the current request's \member{environ} variables.
\end{methoddesc}
\begin{methoddesc}{setup_environ}{}
Set the \member{environ} attribute to a fully-populated WSGI
environment. The default implementation uses all of the above methods
and attributes, plus the \method{get_stdin()}, \method{get_stderr()},
and \method{add_cgi_vars()} methods and the \member{wsgi_file_wrapper}
attribute. It also inserts a \code{SERVER_SOFTWARE} key if not present,
as long as the \member{origin_server} attribute is a true value and the
\member{server_software} attribute is set.
\end{methoddesc}
Methods and attributes for customizing exception handling:
\begin{methoddesc}{log_exception}{exc_info}
Log the \var{exc_info} tuple in the server log. \var{exc_info} is a
\code{(\var{type}, \var{value}, \var{traceback})} tuple. The default
implementation simply writes the traceback to the request's
\code{wsgi.errors} stream and flushes it. Subclasses can override this
method to change the format or retarget the output, mail the traceback
to an administrator, or whatever other action may be deemed suitable.
\end{methoddesc}
\begin{memberdesc}{traceback_limit}
The maximum number of frames to include in tracebacks output by the
default \method{log_exception()} method. If \code{None}, all frames
are included.
\end{memberdesc}
\begin{methoddesc}{error_output}{environ, start_response}
This method is a WSGI application to generate an error page for the
user. It is only invoked if an error occurs before headers are sent
to the client.
This method can access the current error information using
\code{sys.exc_info()}, and should pass that information to
\var{start_response} when calling it (as described in the ``Error
Handling'' section of \pep{333}).
The default implementation just uses the \member{error_status},
\member{error_headers}, and \member{error_body} attributes to generate
an output page. Subclasses can override this to produce more dynamic
error output.
Note, however, that it's not recommended from a security perspective to
spit out diagnostics to any old user; ideally, you should have to do
something special to enable diagnostic output, which is why the default
implementation doesn't include any.
\end{methoddesc}
\begin{memberdesc}{error_status}
The HTTP status used for error responses. This should be a status
string as defined in \pep{333}; it defaults to a 500 code and message.
\end{memberdesc}
\begin{memberdesc}{error_headers}
The HTTP headers used for error responses. This should be a list of
WSGI response headers (\code{(\var{name}, \var{value})} tuples), as
described in \pep{333}. The default list just sets the content type
to \code{text/plain}.
\end{memberdesc}
\begin{memberdesc}{error_body}
The error response body. This should be an HTTP response body string.
It defaults to the plain text, ``A server error occurred. Please
contact the administrator.''
\end{memberdesc}
Methods and attributes for \pep{333}'s ``Optional Platform-Specific File
Handling'' feature:
\begin{memberdesc}{wsgi_file_wrapper}
A \code{wsgi.file_wrapper} factory, or \code{None}. The default value
of this attribute is the \class{FileWrapper} class from
\module{wsgiref.util}.
\end{memberdesc}
\begin{methoddesc}{sendfile}{}
Override to implement platform-specific file transmission. This method
is called only if the application's return value is an instance of
the class specified by the \member{wsgi_file_wrapper} attribute. It
should return a true value if it was able to successfully transmit the
file, so that the default transmission code will not be executed.
The default implementation of this method just returns a false value.
\end{methoddesc}
Miscellaneous methods and attributes:
\begin{memberdesc}{origin_server}
This attribute should be set to a true value if the handler's
\method{_write()} and \method{_flush()} are being used to communicate
directly to the client, rather than via a CGI-like gateway protocol that
wants the HTTP status in a special \code{Status:} header.
This attribute's default value is true in \class{BaseHandler}, but
false in \class{BaseCGIHandler} and \class{CGIHandler}.
\end{memberdesc}
\begin{memberdesc}{http_version}
If \member{origin_server} is true, this string attribute is used to
set the HTTP version of the response set to the client. It defaults to
\code{"1.0"}.
\end{memberdesc}
\end{classdesc}

View File

@ -13,11 +13,12 @@ The ZIP file format is a common archive and compression standard.
This module provides tools to create, read, write, append, and list a
ZIP file. Any advanced use of this module will require an
understanding of the format, as defined in
\citetitle[http://www.pkware.com/appnote.html]{PKZIP Application
Note}.
\citetitle[http://www.pkware.com/business_and_developers/developer/appnote/]
{PKZIP Application Note}.
This module does not currently handle ZIP files which have appended
comments, or multi-disk ZIP files.
comments, or multi-disk ZIP files. It can handle ZIP files that use the
ZIP64 extensions (that is ZIP files that are more than 4 GByte in size).
The available attributes of this module are:
@ -25,6 +26,11 @@ The available attributes of this module are:
The error raised for bad ZIP files.
\end{excdesc}
\begin{excdesc}{LargeZipFile}
The error raised when a ZIP file would require ZIP64 functionality but that
has not been enabled.
\end{excdesc}
\begin{classdesc*}{ZipFile}
The class for reading and writing ZIP files. See
``\citetitle{ZipFile Objects}'' (section \ref{zipfile-objects}) for
@ -65,9 +71,9 @@ The available attributes of this module are:
\begin{seealso}
\seetitle[http://www.pkware.com/appnote.html]{PKZIP Application
Note}{Documentation on the ZIP file format by Phil
Katz, the creator of the format and algorithms used.}
\seetitle[http://www.pkware.com/business_and_developers/developer/appnote/]
{PKZIP Application Note}{Documentation on the ZIP file format by
Phil Katz, the creator of the format and algorithms used.}
\seetitle[http://www.info-zip.org/pub/infozip/]{Info-ZIP Home Page}{
Information about the Info-ZIP project's ZIP archive
@ -77,7 +83,7 @@ The available attributes of this module are:
\subsection{ZipFile Objects \label{zipfile-objects}}
\begin{classdesc}{ZipFile}{file\optional{, mode\optional{, compression}}}
\begin{classdesc}{ZipFile}{file\optional{, mode\optional{, compression\optional{, allowZip64}}}}
Open a ZIP file, where \var{file} can be either a path to a file
(a string) or a file-like object. The \var{mode} parameter
should be \code{'r'} to read an existing file, \code{'w'} to
@ -100,6 +106,12 @@ cat myzip.zip >> python.exe
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 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}{}
@ -132,8 +144,8 @@ cat myzip.zip >> python.exe
\end{methoddesc}
\begin{methoddesc}{testzip}{}
Read all the files in the archive and check their CRC's. Return the
name of the first bad file, or else return \code{None}.
Read all the files in the archive and check their CRC's and file
headers. Return the name of the first bad file, or else return \code{None}.
\end{methoddesc}
\begin{methoddesc}{write}{filename\optional{, arcname\optional{,
@ -243,9 +255,9 @@ Instances have the following attributes:
\begin{memberdesc}[ZipInfo]{extra}
Expansion field data. The
\citetitle[http://www.pkware.com/appnote.html]{PKZIP Application
Note} contains some comments on the internal structure of the data
contained in this string.
\citetitle[http://www.pkware.com/business_and_developers/developer/appnote/]
{PKZIP Application Note} contains some comments on the internal
structure of the data contained in this string.
\end{memberdesc}
\begin{memberdesc}[ZipInfo]{create_system}
@ -284,10 +296,6 @@ Instances have the following attributes:
Byte offset to the file header.
\end{memberdesc}
\begin{memberdesc}[ZipInfo]{file_offset}
Byte offset to the start of the file data.
\end{memberdesc}
\begin{memberdesc}[ZipInfo]{CRC}
CRC-32 of the uncompressed file.
\end{memberdesc}

View File

@ -50,9 +50,9 @@ The available attributes of this module are:
\begin{seealso}
\seetitle[http://www.pkware.com/appnote.html]{PKZIP Application
Note}{Documentation on the ZIP file format by Phil
Katz, the creator of the format and algorithms used.}
\seetitle[http://www.pkware.com/business_and_developers/developer/appnote/]
{PKZIP Application Note}{Documentation on the ZIP file format by
Phil Katz, the creator of the format and algorithms used.}
\seepep{0273}{Import Modules from Zip Archives}{Written by James C.
Ahlstrom, who also provided an implementation. Python 2.3

View File

@ -24,7 +24,7 @@ while True:
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()

View File

@ -18,10 +18,9 @@ implement the Tk widgets as Python classes. In addition, the internal
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 @@ of an application. Each instance has its own associated Tcl interpreter.
\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 @@ is called \code{.} (period) and children are delimited by more
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 @@ directly on Python data structures, without having to transfer data
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[]{PyQt}{
\seetitle[http://www.amazon.com/exec/obidos/ASIN/1932394621]
{wxPython in Action}{
The wxPython book, by Noel Rappin and Robin Dunn.
}
\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{}

View File

@ -22,10 +22,10 @@ Whenever a function or method expects a \var{file} argument, this
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, but not under \UNIX-Python
because of the way pathnames and FSRefs works. See Apple's documentation
for details.
A description of aliases and the

View File

@ -25,7 +25,7 @@ The way the interpreter has been linked. As extension modules may be
incompatible between linking models, packages could use this information to give
more decent error messages. The value is one of \code{'static'} for a
statically linked Python, \code{'framework'} for Python in a Mac OS X framework,
\code{'shared'} for Python in a standard unix shared library.
\code{'shared'} for Python in a standard \UNIX{} shared library.
Older Pythons could also have the value
\code{'cfm'} for Mac OS 9-compatible Python.
\end{datadesc}

View File

@ -6,7 +6,7 @@ Python on any other \UNIX platform, but there are a number of additional
features such as the IDE and the Package Manager that are worth pointing out.
Python on Mac OS 9 or earlier can be quite different from Python on
Unix or Windows, but is beyond the scope of this manual, as that platform
\UNIX{} or Windows, but is beyond the scope of this manual, as that platform
is no longer supported, starting with Python 2.4. See
\url{http://www.cwi.nl/\textasciitilde jack/macpython} for installers
for the latest 2.3 release for Mac OS 9 and related documentation.

View File

@ -56,7 +56,7 @@ by following the explicit or implicit \emph{line joining} rules.
A physical line is a sequence of characters terminated by an end-of-line
sequence. In source files, any of the standard platform line
termination sequences can be used - the \UNIX form using \ASCII{} LF
termination sequences can be used - the \UNIX{} form using \ASCII{} LF
(linefeed), the Windows form using the \ASCII{} sequence CR LF (return
followed by linefeed), or the Macintosh form using the \ASCII{} CR
(return) character. All of these forms can be used equally, regardless

View File

@ -1307,6 +1307,11 @@ defines mutable objects and implements a \method{__cmp__()} or
since the dictionary implementation requires that a key's hash value
is immutable (if the object's hash value changes, it will be in the
wrong hash bucket).
\versionchanged[\method{__hash__()} may now also return a long
integer object; the 32-bit integer is then derived from the hash
of that object]{2.5}
\withsubitem{(object method)}{\ttindex{__cmp__()}}
\end{methoddesc}
@ -1886,6 +1891,9 @@ method should be the equivalent to using \method{__floordiv__()} and
\method{__pow__()} should be defined to accept an optional third
argument if the ternary version of the built-in
\function{pow()}\bifuncindex{pow} function is to be supported.
If one of those methods does not support the operation with the
supplied arguments, it should return \code{NotImplemented}.
\end{methoddesc}
\begin{methoddesc}[numeric object]{__div__}{self, other}
@ -1918,13 +1926,28 @@ called to implement the binary arithmetic operations (\code{+},
\function{pow()}\bifuncindex{pow}, \code{**}, \code{<<},
\code{>>}, \code{\&}, \code{\^}, \code{|}) with reflected
(swapped) operands. These functions are only called if the left
operand does not support the corresponding operation. For instance,
to evaluate the expression \var{x}\code{-}\var{y}, where \var{y} is an
instance of a class that has an \method{__rsub__()} method,
\code{\var{y}.__rsub__(\var{x})} is called. Note that ternary
operand does not support the corresponding operation and the
operands are of different types.\footnote{
For operands of the same type, it is assumed that if the
non-reflected method (such as \method{__add__()}) fails the
operation is not supported, which is why the reflected method
is not called.}
For instance, to evaluate the expression \var{x}\code{-}\var{y},
where \var{y} is an instance of a class that has an
\method{__rsub__()} method, \code{\var{y}.__rsub__(\var{x})}
is called if \code{\var{x}.__sub__(\var{y})} returns
\var{NotImplemented}.
Note that ternary
\function{pow()}\bifuncindex{pow} will not try calling
\method{__rpow__()} (the coercion rules would become too
complicated).
\note{If the right operand's type is a subclass of the left operand's
type and that subclass provides the reflected method for the
operation, this method will be called before the left operand's
non-reflected method. This behavior allows subclasses to
override their ancestors' operations.}
\end{methoddesc}
\begin{methoddesc}[numeric object]{__iadd__}{self, other}

View File

@ -97,10 +97,20 @@ searched. The global statement must precede all uses of the name.
The built-in namespace associated with the execution of a code block
is actually found by looking up the name \code{__builtins__} in its
global namespace; this should be a dictionary or a module (in the
latter case the module's dictionary is used). Normally, the
\code{__builtins__} namespace is the dictionary of the built-in module
\module{__builtin__} (note: no `s'). If it isn't, restricted
execution\indexii{restricted}{execution} mode is in effect.
latter case the module's dictionary is used). By default, when in the
\module{__main__} module, \code{__builtins__} is the built-in module
\module{__builtin__} (note: no `s'); when in any other module,
\code{__builtins__} is an alias for the dictionary of the
\module{__builtin__} module itself. \code{__builtins__} can be set
to a user-created dictionary to create a weak form of restricted
execution\indexii{restricted}{execution}.
\begin{notice}
Users should not touch \code{__builtins__}; it is strictly an
implementation detail. Users wanting to override values in the
built-in namespace should \keyword{import} the \module{__builtin__}
(no `s') module and modify its attributes appropriately.
\end{notice}
The namespace for a module is automatically created the first time a
module is imported. The main module for a script is always called

View File

@ -907,7 +907,10 @@ The operators \code{<}, \code{>}, \code{==}, \code{>=}, \code{<=}, and
the values of two objects. The objects need not have the same type.
If both are numbers, they are converted to a common type. Otherwise,
objects of different types \emph{always} compare unequal, and are
ordered consistently but arbitrarily.
ordered consistently but arbitrarily. You can control comparison
behavior of objects of non-builtin types by defining a \code{__cmp__}
method or rich comparison methods like \code{__gt__}, described in
section~\ref{specialnames}.
(This unusual definition of comparison was used to simplify the
definition of operations like sorting and the \keyword{in} and
@ -952,7 +955,8 @@ otherwise defined.\footnote{Earlier versions of Python used
a dictionary for emptiness by comparing it to \code{\{\}}.}
\item
Most other types compare unequal unless they are the same object;
Most other objects of builtin types compare unequal unless they are
the same object;
the choice whether one object is considered smaller or larger than
another one is made arbitrarily but consistently within one
execution of a program.

View File

@ -34,7 +34,7 @@ in the namespace of \module{__main__}.
\index{interactive mode}
\refbimodindex{__main__}
Under {\UNIX}, a complete program can be passed to the interpreter in
Under \UNIX, a complete program can be passed to the interpreter in
three forms: with the \programopt{-c} \var{string} command line option, as a
file passed as the first command line argument, or as standard input.
If the file or standard input is a tty device, the interpreter enters

View File

@ -2931,14 +2931,13 @@ submodules with the same name from different packages.
The submodules often need to refer to each other. For example, the
\module{surround} module might use the \module{echo} module. In fact,
such references
are so common that the \keyword{import} statement first looks in the
containing package before looking in the standard module search path.
Thus, the surround module can simply use \code{import echo} or
\code{from echo import echofilter}. If the imported module is not
found in the current package (the package of which the current module
is a submodule), the \keyword{import} statement looks for a top-level
module with the given name.
such references are so common that the \keyword{import} statement
first looks in the containing package before looking in the standard
module search path. Thus, the \module{surround} module can simply use
\code{import echo} or \code{from echo import echofilter}. If the
imported module is not found in the current package (the package of
which the current module is a submodule), the \keyword{import}
statement looks for a top-level module with the given name.
When packages are structured into subpackages (as with the
\module{Sound} package in the example), there's no shortcut to refer
@ -2948,6 +2947,24 @@ must be used. For example, if the module
in the \module{Sound.Effects} package, it can use \code{from
Sound.Effects import echo}.
Starting with Python 2.5, in addition to the implicit relative imports
described above, you can write explicit relative imports with the
\code{from module import name} form of import statement. These explicit
relative imports use leading dots to indicate the current and parent
packages involved in the relative import. From the \module{surround}
module for example, you might use:
\begin{verbatim}
from . import echo
from .. import Formats
from ..Filters import equalizer
\end{verbatim}
Note that both explicit and implicit relative imports are based on the
name of the current module. Since the name of the main module is always
\code{"__main__"}, modules intended for use as the main module of a
Python application should always use absolute imports.
\subsection{Packages in Multiple Directories}
Packages support one more special attribute, \member{__path__}. This

View File

@ -216,7 +216,7 @@ A new module, \module{unicodedata}, provides an interface to Unicode
character properties. For example, \code{unicodedata.category(u'A')}
returns the 2-character string 'Lu', the 'L' denoting it's a letter,
and 'u' meaning that it's uppercase.
\code{u.bidirectional(u'\e x0660')} returns 'AN', meaning that U+0660 is
\code{unicodedata.bidirectional(u'\e u0660')} returns 'AN', meaning that U+0660 is
an Arabic number.
The \module{codecs} module contains functions to look up existing encodings
@ -571,7 +571,7 @@ def f(*args, **kw):
The \keyword{print} statement can now have its output directed to a
file-like object by following the \keyword{print} with
\verb|>> file|, similar to the redirection operator in Unix shells.
\verb|>> file|, similar to the redirection operator in \UNIX{} shells.
Previously you'd either have to use the \method{write()} method of the
file-like object, which lacks the convenience and simplicity of
\keyword{print}, or you could assign a new value to
@ -777,7 +777,7 @@ fact will break in 2.0.
Some work has been done to make integers and long integers a bit more
interchangeable. In 1.5.2, large-file support was added for Solaris,
to allow reading files larger than 2Gb; this made the \method{tell()}
to allow reading files larger than 2~GiB; this made the \method{tell()}
method of file objects return a long integer instead of a regular
integer. Some code would subtract two file offsets and attempt to use
the result to multiply a sequence or slice a string, but this raised a
@ -894,7 +894,7 @@ to be added, and a third argument for the value to be assigned to the
name. This third argument is, respectively, a Python object, a C
long, or a C string.
A wrapper API was added for Unix-style signal handlers.
A wrapper API was added for \UNIX-style signal handlers.
\function{PyOS_getsig()} gets a signal handler and
\function{PyOS_setsig()} will set a new handler.
@ -905,7 +905,7 @@ Before Python 2.0, installing modules was a tedious affair -- there
was no way to figure out automatically where Python is installed, or
what compiler options to use for extension modules. Software authors
had to go through an arduous ritual of editing Makefiles and
configuration files, which only really work on Unix and leave Windows
configuration files, which only really work on \UNIX{} and leave Windows
and MacOS unsupported. Python users faced wildly differing
installation instructions which varied between different extension
packages, which made administering a Python installation something of
@ -1222,7 +1222,7 @@ device on Linux, a twin to the existing \module{sunaudiodev} module.
(Contributed by Peter Bosch, with fixes by Jeremy Hylton.)
\item{\module{mmap}:} An interface to memory-mapped files on both
Windows and Unix. A file's contents can be mapped directly into
Windows and \UNIX. A file's contents can be mapped directly into
memory, at which point it behaves like a mutable string, so its
contents can be read and modified. They can even be passed to
functions that expect ordinary strings, such as the \module{re}
@ -1262,7 +1262,7 @@ distribution, and enhanced to support Unicode.
\item{\module{zipfile}:} A module for reading and writing ZIP-format
archives. These are archives produced by \program{PKZIP} on
DOS/Windows or \program{zip} on Unix, not to be confused with
DOS/Windows or \program{zip} on \UNIX, not to be confused with
\program{gzip}-format files (which are supported by the \module{gzip}
module)
(Contributed by James C. Ahlstrom.)

View File

@ -325,7 +325,7 @@ Rossum.}
When compiling Python, the user had to go in and edit the
\file{Modules/Setup} file in order to enable various additional
modules; the default set is relatively small and limited to modules
that compile on most Unix platforms. This means that on Unix
that compile on most \UNIX{} platforms. This means that on \Unix{}
platforms with many more features, most notably Linux, Python
installations often don't contain all useful modules they could.
@ -661,7 +661,7 @@ PyUnit.
\item The \module{difflib} module contains a class,
\class{SequenceMatcher}, which compares two sequences and computes the
changes required to transform one sequence into the other. For
example, this module can be used to write a tool similar to the Unix
example, this module can be used to write a tool similar to the \UNIX{}
\program{diff} program, and in fact the sample program
\file{Tools/scripts/ndiff.py} demonstrates how to write such a script.

View File

@ -1479,7 +1479,7 @@ now return enhanced tuples:
('amk', 500)
\end{verbatim}
\item The \module{gzip} module can now handle files exceeding 2~Gb.
\item The \module{gzip} module can now handle files exceeding 2~GiB.
\item The new \module{heapq} module contains an implementation of a
heap queue algorithm. A heap is an array-like data structure that
@ -1979,7 +1979,7 @@ documentation}{../lib/module-datetime.html}.
The \module{getopt} module provides simple parsing of command-line
arguments. The new \module{optparse} module (originally named Optik)
provides more elaborate command-line parsing that follows the Unix
provides more elaborate command-line parsing that follows the \UNIX{}
conventions, automatically creates the output for \longprogramopt{help},
and can perform different actions for different options.

View File

@ -162,7 +162,7 @@ for link in links:
Generator expressions always have to be written inside parentheses, as
in the above example. The parentheses signalling a function call also
count, so if you want to create a iterator that will be immediately
count, so if you want to create an iterator that will be immediately
passed to a function you could write:
\begin{verbatim}

View File

@ -3,10 +3,9 @@
% $Id$
% Fix XXX comments
% Count up the patches and bugs
\title{What's New in Python 2.5}
\release{0.2}
\release{0.9}
\author{A.M. Kuchling}
\authoraddress{\email{amk@amk.ca}}
@ -14,31 +13,57 @@
\maketitle
\tableofcontents
This article explains the new features in Python 2.5. No release date
for Python 2.5 has been set; it will probably be released in the
autumn of 2006. \pep{356} describes the planned release schedule.
This article explains the new features in Python 2.5. The final
release of Python 2.5 is scheduled for August 2006;
\pep{356} describes the planned release schedule.
Comments, suggestions, and error reports are welcome; please e-mail them
to the author or open a bug in the Python bug tracker.
The changes in Python 2.5 are an interesting mix of language and
library improvements. The library enhancements will be more important
to Python's user community, I think, because several widely-useful
packages were added. New modules include ElementTree for XML
processing (section~\ref{module-etree}), the SQLite database module
(section~\ref{module-sqlite}), and the \module{ctypes} module for
calling C functions (section~\ref{module-ctypes}).
% XXX Compare with previous release in 2 - 3 sentences here.
The language changes are of middling significance. Some pleasant new
features were added, but most of them aren't features that you'll use
every day. Conditional expressions were finally added to the language
using a novel syntax; see section~\ref{pep-308}. The new
'\keyword{with}' statement will make writing cleanup code easier
(section~\ref{pep-343}). Values can now be passed into generators
(section~\ref{pep-342}). Imports are now visible as either absolute
or relative (section~\ref{pep-328}). Some corner cases of exception
handling are handled better (section~\ref{pep-341}). All these
improvements are worthwhile, but they're improvements to one specific
language feature or another; none of them are broad modifications to
Python's semantics.
This article doesn't attempt to provide a complete specification of
the new features, but instead provides a convenient overview. For
full details, you should refer to the documentation for Python 2.5.
As well as the language and library additions, other improvements and
bugfixes were made throughout the source tree. A search through the
SVN change logs finds there were 334 patches applied and 443 bugs
fixed between Python 2.4 and 2.5. (Both figures are likely to be
underestimates.)
This article doesn't try to be a complete specification of the new
features; instead changes are briefly introduced using helpful
examples. For full details, you should always refer to the
documentation for Python 2.5.
% XXX add hyperlink when the documentation becomes available online.
If you want to understand the complete implementation and design
rationale, refer to the PEP for a particular new feature.
Comments, suggestions, and error reports for this document are
welcome; please e-mail them to the author or open a bug in the Python
bug tracker.
%======================================================================
\section{PEP 308: Conditional Expressions\label{pep-308}}
For a long time, people have been requesting a way to write
conditional expressions, expressions that return value A or value B
depending on whether a Boolean value is true or false. A conditional
expression lets you write a single assignment statement that has the
same effect as the following:
conditional expressions, which are expressions that return value A or
value B depending on whether a Boolean value is true or false. A
conditional expression lets you write a single assignment statement
that has the same effect as the following:
\begin{verbatim}
if condition:
@ -54,7 +79,7 @@ but there was no syntax that was preferred by a clear majority.
Candidates included C's \code{cond ? true_v : false_v},
\code{if cond then true_v else false_v}, and 16 other variations.
GvR eventually chose a surprising syntax:
Guido van~Rossum eventually chose a surprising syntax:
\begin{verbatim}
x = true_value if condition else false_value
@ -126,19 +151,16 @@ Wouters.}
\section{PEP 309: Partial Function Application\label{pep-309}}
The \module{functools} module is intended to contain tools for
functional-style programming. Currently it only contains a
\class{partial()} function, but new functions will probably be added
in future versions of Python.
functional-style programming.
For programs written in a functional style, it can be useful to
One useful tool in this module is the \function{partial()} function.
For programs written in a functional style, you'll sometimes want to
construct variants of existing functions that have some of the
parameters filled in. Consider a Python function \code{f(a, b, c)};
you could create a new function \code{g(b, c)} that was equivalent to
\code{f(1, b, c)}. This is called ``partial function application'',
and is provided by the \class{partial} class in the new
\module{functools} module.
\code{f(1, b, c)}. This is called ``partial function application''.
The constructor for \class{partial} takes the arguments
\function{partial} takes the arguments
\code{(\var{function}, \var{arg1}, \var{arg2}, ...
\var{kwarg1}=\var{value1}, \var{kwarg2}=\var{value2})}. The resulting
object is callable, so you can just call it to invoke \var{function}
@ -175,11 +197,40 @@ class Application:
\end{verbatim}
Another function in the \module{functools} module is the
\function{update_wrapper(\var{wrapper}, \var{wrapped})} function that
helps you write well-behaved decorators. \function{update_wrapper()}
copies the name, module, and docstring attribute to a wrapper function
so that tracebacks inside the wrapped function are easier to
understand. For example, you might write:
\begin{verbatim}
def my_decorator(f):
def wrapper(*args, **kwds):
print 'Calling decorated function'
return f(*args, **kwds)
functools.update_wrapper(wrapper, f)
return wrapper
\end{verbatim}
\function{wraps()} is a decorator that can be used inside your own
decorators to copy the wrapped function's information. An alternate
version of the previous example would be:
\begin{verbatim}
def my_decorator(f):
@functools.wraps(f)
def wrapper(*args, **kwds):
print 'Calling decorated function'
return f(*args, **kwds)
return wrapper
\end{verbatim}
\begin{seealso}
\seepep{309}{Partial Function Application}{PEP proposed and written by
Peter Harris; implemented by Hye-Shik Chang, with adaptations by
Raymond Hettinger.}
Peter Harris; implemented by Hye-Shik Chang and Nick Coghlan, with
adaptations by Raymond Hettinger.}
\end{seealso}
@ -361,7 +412,7 @@ specific exceptions. You couldn't combine both \keyword{except} blocks and a
combined version was complicated and it wasn't clear what the
semantics of the combined should be.
GvR spent some time working with Java, which does support the
Guido van~Rossum spent some time working with Java, which does support the
equivalent of combining \keyword{except} blocks and a
\keyword{finally} block, and this clarified what the statement should
mean. In Python 2.5, you can now write:
@ -554,7 +605,11 @@ once the generator has been exhausted.
\seepep{342}{Coroutines via Enhanced Generators}{PEP written by
Guido van~Rossum and Phillip J. Eby;
implemented by Phillip J. Eby. Includes examples of
some fancier uses of generators as coroutines.}
some fancier uses of generators as coroutines.
Earlier versions of these features were proposed in
\pep{288} by Raymond Hettinger and \pep{325} by Samuele Pedroni.
}
\seeurl{http://en.wikipedia.org/wiki/Coroutine}{The Wikipedia entry for
coroutines.}
@ -771,7 +826,7 @@ The new \module{contextlib} module provides some functions and a
decorator that are useful for writing objects for use with the
'\keyword{with}' statement.
The decorator is called \function{contextfactory}, and lets you write
The decorator is called \function{contextmanager}, and lets you write
a single generator function instead of defining a new class. The generator
should yield exactly one value. The code up to the \keyword{yield}
will be executed as the \method{__enter__()} method, and the value
@ -785,9 +840,9 @@ Our database example from the previous section could be written
using this decorator as:
\begin{verbatim}
from contextlib import contextfactory
from contextlib import contextmanager
@contextfactory
@contextmanager
def db_transaction (connection):
cursor = connection.cursor()
try:
@ -933,7 +988,7 @@ space for a \ctype{PyObject} representing the item. 2147483647*4 is
already more bytes than a 32-bit address space can contain.
It's possible to address that much memory on a 64-bit platform,
however. The pointers for a list that size would only require 16GiB
however. The pointers for a list that size would only require 16~GiB
of space, so it's not unreasonable that Python programmers might
construct lists that large. Therefore, the Python interpreter had to
be changed to use some type other than \ctype{int}, and this will be a
@ -1044,10 +1099,10 @@ print d[3], d[4] # Prints 0, 0
\item Both 8-bit and Unicode strings have new \method{partition(sep)}
and \method{rpartition(sep)} methods that simplify a common use case.
The \method{find(S)} method is often used to get an index which is
then used to slice the string and obtain the pieces that are before
and after the separator.
\method{partition(sep)} condenses this
pattern into a single method call that returns a 3-tuple containing
the substring before the separator, the separator itself, and the
@ -1072,6 +1127,17 @@ Some examples:
(Implemented by Fredrik Lundh following a suggestion by Raymond Hettinger.)
\item The \method{startswith()} and \method{endswith()} methods
of string types now accept tuples of strings to check for.
\begin{verbatim}
def is_image_file (filename):
return filename.endswith(('.gif', '.jpg', '.tiff'))
\end{verbatim}
(Implemented by Georg Brandl following a suggestion by Tom Lynn.)
% RFE #1491485
\item The \function{min()} and \function{max()} built-in functions
gained a \code{key} keyword parameter analogous to the \code{key}
argument for \method{sort()}. This parameter supplies a function that
@ -1095,8 +1161,17 @@ print max(L)
false values. \function{any()} returns \constant{True} if any value
returned by the iterator is true; otherwise it will return
\constant{False}. \function{all()} returns \constant{True} only if
all of the values returned by the iterator evaluate as being true.
(Suggested by GvR, and implemented by Raymond Hettinger.)
all of the values returned by the iterator evaluate as true.
(Suggested by Guido van~Rossum, and implemented by Raymond Hettinger.)
\item The result of a class's \method{__hash__()} method can now
be either a long integer or a regular integer. If a long integer is
returned, the hash of that value is taken. In earlier versions the
hash value was required to be a regular integer, but in 2.5 the
\function{id()} built-in was changed to always return non-negative
numbers, and users often seem to use \code{id(self)} in
\method{__hash__()} methods (though this is discouraged).
% Bug #1536021
\item ASCII is now the default encoding for modules. It's now
a syntax error if a module contains string literals with 8-bit
@ -1113,9 +1188,12 @@ a line like this near the top of the source file:
to include an \file{__init__.py} module in a package directory.
Debugging this mistake can be confusing, and usually requires running
Python with the \programopt{-v} switch to log all the paths searched.
In Python 2.5, a new \exception{ImportWarning} warning is raised when
In Python 2.5, a new \exception{ImportWarning} warning is triggered when
an import would have picked up a directory as a package but no
\file{__init__.py} was found. (Implemented by Thomas Wouters.)
\file{__init__.py} was found. This warning is silently ignored by default;
provide the \programopt{-Wd} option when running the Python executable
to display the warning message.
(Implemented by Thomas Wouters.)
\item The list of base classes in a class definition can now be empty.
As an example, this is now legal:
@ -1146,6 +1224,11 @@ produce string representations of themselves, but are also callable.
Newbies who try \code{quit()} or \code{exit()} will now exit the
interpreter as they expect. (Implemented by Georg Brandl.)
The Python executable now accepts the standard long options
\longprogramopt{help} and \longprogramopt{version}; on Windows,
it also accepts the \programopt{/?} option for displaying a help message.
(Implemented by Georg Brandl.)
%======================================================================
\subsection{Optimizations\label{opts}}
@ -1194,7 +1277,8 @@ Python's allocator functions instead of the system's
\item The code generator's peephole optimizer now performs
simple constant folding in expressions. If you write something like
\code{a = 2+3}, the code generator will do the arithmetic and produce
code corresponding to \code{a = 5}.
code corresponding to \code{a = 5}. (Proposed and implemented
by Raymond Hettinger.)
\item Function calls are now faster because code objects now keep
the most recently finished frame (a ``zombie frame'') in an internal
@ -1288,10 +1372,13 @@ defaultdict(<type 'list'>, {'c': ['cammin', 'che'], 'e': ['era'],
'r': ['ritrovai'], 'u': ['una'], 'v': ['vita', 'via']}
\end{verbatim}
The \class{deque} double-ended queue type supplied by the
(Contributed by Guido van~Rossum.)
\item The \class{deque} double-ended queue type supplied by the
\module{collections} module now has a \method{remove(\var{value})}
method that removes the first occurrence of \var{value} in the queue,
raising \exception{ValueError} if the value isn't found.
(Contributed by Raymond Hettinger.)
\item New module: The \module{contextlib} module contains helper functions for use
with the new '\keyword{with}' statement. See
@ -1320,6 +1407,17 @@ currently-set limit. The \class{reader} class now has a
\member{line_num} attribute that counts the number of physical lines
read from the source; records can span multiple physical lines, so
\member{line_num} is not the same as the number of records read.
The CSV parser is now stricter about 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 that
contained carriage return characters within fields, so the code 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 that preserves the
newline characters.
(Contributed by Skip Montanaro and Andrew McNamara.)
\item The \class{datetime} class in the \module{datetime}
@ -1335,11 +1433,27 @@ ts = datetime.strptime('10:13:15 2006-03-07',
'%H:%M:%S %Y-%m-%d')
\end{verbatim}
\item The \method{SequenceMatcher.get_matching_blocks()} method
in the \module{difflib} module now guarantees to return a minimal list
of blocks describing matching subsequences. Previously, the algorithm would
occasionally break a block of matching elements into two list entries.
(Enhancement by Tim Peters.)
\item The \module{doctest} module gained a \code{SKIP} option that
keeps an example from being executed at all. This is intended for
code snippets that are usage examples intended for the reader and
aren't actually test cases.
An \var{encoding} parameter was added to the \function{testfile()}
function and the \class{DocFileSuite} class to specify the file's
encoding. This makes it easier to use non-ASCII characters in
tests contained within a docstring. (Contributed by Bjorn Tillenius.)
% Patch 1080727
\item The \module{email} package has been updated to version 4.0.
% XXX need to provide some more detail here
(Contributed by Barry Warsaw.)
\item The \module{fileinput} module was made more flexible.
Unicode filenames are now supported, and a \var{mode} parameter that
defaults to \code{"r"} was added to the
@ -1358,6 +1472,7 @@ collector; when these counts reach a specified threshold, a garbage
collection sweep will be made. The existing \function{gc.collect()}
function now takes an optional \var{generation} argument of 0, 1, or 2
to specify which generation to collect.
(Contributed by Barry Warsaw.)
\item The \function{nsmallest()} and
\function{nlargest()} functions in the \module{heapq} module
@ -1388,6 +1503,29 @@ itertools.islice(iterable, s.start, s.stop, s.step)
(Contributed by Raymond Hettinger.)
\item The \function{format()} function in the \module{locale} module
has been modified and two new functions were added,
\function{format_string()} and \function{currency()}.
The \function{format()} function's \var{val} parameter could
previously be a string as long as no more than one \%char specifier
appeared; now the parameter must be exactly one \%char specifier with
no surrounding text. An optional \var{monetary} parameter was also
added which, if \code{True}, will use the locale's rules for
formatting currency in placing a separator between groups of three
digits.
To format strings with multiple \%char specifiers, use the new
\function{format_string()} function that works like \function{format()}
but also supports mixing \%char specifiers with
arbitrary text.
A new \function{currency()} function was also added that formats a
number according to the current locale's settings.
(Contributed by Georg Brandl.)
% Patch 1180296
\item The \module{mailbox} module underwent a massive rewrite to add
the capability to modify mailboxes in addition to reading them. A new
set of classes that include \class{mbox}, \class{MH}, and
@ -1496,6 +1634,9 @@ tuple slicing, method lookups, and numeric operations, instead of
performing many different operations and reducing the result to a
single number as \file{pystone.py} does.
\item The \module{pyexpat} module now uses version 2.0 of the Expat parser.
(Contributed by Trent Mick.)
\item The old \module{regex} and \module{regsub} modules, which have been
deprecated ever since Python 2.0, have finally been deleted.
Other deleted modules: \module{statcache}, \module{tzparse},
@ -1560,7 +1701,7 @@ year, number, name = s.unpack(data)
\end{verbatim}
You can also pack and unpack data to and from buffer objects directly
using the \method{pack_to(\var{buffer}, \var{offset}, \var{v1},
using the \method{pack_into(\var{buffer}, \var{offset}, \var{v1},
\var{v2}, ...)} and \method{unpack_from(\var{buffer}, \var{offset})}
methods. This lets you store data directly into an array or a
memory-mapped file.
@ -1582,22 +1723,76 @@ string of build information like this:
\code{"trunk:45355:45356M, Apr 13 2006, 07:42:19"}.
(Contributed by Barry Warsaw.)
\item Another new function, \function{sys._current_frames()}, returns
the current stack frames for all running threads as a dictionary
mapping thread identifiers to the topmost stack frame currently active
in that thread at the time the function is called. (Contributed by
Tim Peters.)
\item The \class{TarFile} class in the \module{tarfile} module now has
an \method{extractall()} method that extracts all members from the
archive into the current working directory. It's also possible to set
a different directory as the extraction target, and to unpack only a
subset of the archive's members.
subset of the archive's members.
A tarfile's compression can be autodetected by
using the mode \code{'r|*'}.
The compression used for a tarfile opened in stream mode can now be
autodetected using the mode \code{'r|*'}.
% patch 918101
(Contributed by Lars Gust\"abel.)
\item The \module{threading} module now lets you set the stack size
used when new threads are created. The
\function{stack_size(\optional{\var{size}})} function returns the
currently configured stack size, and supplying the optional \var{size}
parameter sets a new value. Not all platforms support changing the
stack size, but Windows, POSIX threading, and OS/2 all do.
(Contributed by Andrew MacIntyre.)
% Patch 1454481
\item The \module{unicodedata} module has been updated to use version 4.1.0
of the Unicode character database. Version 3.2.0 is required
by some specifications, so it's still available as
\member{unicodedata.ucd_3_2_0}.
\item New module: the \module{uuid} module generates
universally unique identifiers (UUIDs) according to \rfc{4122}. The
RFC defines several different UUID versions that are generated from a
starting string, from system properties, or purely randomly. This
module contains a \class{UUID} class and
functions named \function{uuid1()},
\function{uuid3()}, \function{uuid4()}, and
\function{uuid5()} to generate different versions of UUID. (Version 2 UUIDs
are not specified in \rfc{4122} and are not supported by this module.)
\begin{verbatim}
>>> import uuid
>>> # make a UUID based on the host ID and current time
>>> uuid.uuid1()
UUID('a8098c1a-f86e-11da-bd1a-00112444be1e')
>>> # make a UUID using an MD5 hash of a namespace UUID and a name
>>> uuid.uuid3(uuid.NAMESPACE_DNS, 'python.org')
UUID('6fa459ea-ee8a-3ca4-894e-db77e160355e')
>>> # make a random UUID
>>> uuid.uuid4()
UUID('16fd2706-8baf-433b-82eb-8c7fada847da')
>>> # make a UUID using a SHA-1 hash of a namespace UUID and a name
>>> uuid.uuid5(uuid.NAMESPACE_DNS, 'python.org')
UUID('886313e1-3b8a-5372-9b90-0c9aee199e5d')
\end{verbatim}
(Contributed by Ka-Ping Yee.)
\item The \module{weakref} module's \class{WeakKeyDictionary} and
\class{WeakValueDictionary} types gained new methods for iterating
over the weak references contained in the dictionary.
\method{iterkeyrefs()} and \method{keyrefs()} methods were
added to \class{WeakKeyDictionary}, and
\method{itervaluerefs()} and \method{valuerefs()} were added to
\class{WeakValueDictionary}. (Contributed by Fred L.~Drake, Jr.)
\item The \module{webbrowser} module received a number of
enhancements.
It's now usable as a script with \code{python -m webbrowser}, taking a
@ -1609,11 +1804,10 @@ to support this. The module's \function{open()} function supports an
additional feature, an \var{autoraise} parameter that signals whether
to raise the open window when possible. A number of additional
browsers were added to the supported list such as Firefox, Opera,
Konqueror, and elinks. (Contributed by Oleg Broytmann and George
Konqueror, and elinks. (Contributed by Oleg Broytmann and Georg
Brandl.)
% Patch #754022
\item The \module{xmlrpclib} module now supports returning
\class{datetime} objects for the XML-RPC date type. Supply
\code{use_datetime=True} to the \function{loads()} function
@ -1621,6 +1815,12 @@ Brandl.)
(Contributed by Skip Montanaro.)
% Patch 1120353
\item The \module{zipfile} module now supports the ZIP64 version of the
format, meaning that a .zip archive can now be larger than 4~GiB and
can contain individual files larger than 4~GiB. (Contributed by
Ronald Oussoren.)
% Patch 1446489
\item The \module{zlib} module's \class{Compress} and \class{Decompress}
objects now support a \method{copy()} method that makes a copy of the
object's internal state and returns a new
@ -1711,6 +1911,9 @@ of extension modules, now that \module{ctypes} is included with core Python.
\seeurl{http://starship.python.net/crew/theller/ctypes/}
{The ctypes web page, with a tutorial, reference, and FAQ.}
\seeurl{../lib/module-ctypes.html}{The documentation
for the \module{ctypes} module.}
\end{seealso}
@ -1822,7 +2025,6 @@ Please read the package's official documentation for more details.
\seeurl{http://effbot.org/zone/element-index.htm}
{Official documentation for ElementTree.}
\end{seealso}
@ -1873,6 +2075,13 @@ current digest state, \method{digest()} and \method{hexdigest()}
return the digest value as a binary string or a string of hex digits,
and \method{copy()} returns a new hashing object with the same digest state.
\begin{seealso}
\seeurl{../lib/module-hashlib.html}{The documentation
for the \module{hashlib} module.}
\end{seealso}
%======================================================================
\subsection{The sqlite3 package\label{module-sqlite}}
@ -1983,12 +2192,53 @@ For more information about the SQL dialect supported by SQLite, see
{The SQLite web page; the documentation describes the syntax and the
available data types for the supported SQL dialect.}
\seeurl{../lib/module-sqlite3.html}{The documentation
for the \module{sqlite3} module.}
\seepep{249}{Database API Specification 2.0}{PEP written by
Marc-Andr\'e Lemburg.}
\end{seealso}
%======================================================================
\subsection{The wsgiref package\label{module-wsgiref}}
% XXX should this be in a PEP 333 section instead?
The Web Server Gateway Interface (WSGI) v1.0 defines a standard
interface between web servers and Python web applications and is
described in \pep{333}. The \module{wsgiref} package is a reference
implementation of the WSGI specification.
The package includes a basic HTTP server that will run a WSGI
application; this server is useful for debugging but isn't intended for
production use. Setting up a server takes only a few lines of code:
\begin{verbatim}
from wsgiref import simple_server
wsgi_app = ...
host = ''
port = 8000
httpd = simple_server.make_server(host, port, wsgi_app)
httpd.serve_forever()
\end{verbatim}
% XXX discuss structure of WSGI applications?
% XXX provide an example using Django or some other framework?
\begin{seealso}
\seeurl{http://www.wsgi.org}{A central web site for WSGI-related resources.}
\seepep{333}{Python Web Server Gateway Interface v1.0}{PEP written by
Phillip J. Eby.}
\end{seealso}
% ======================================================================
\section{Build and C API Changes\label{build-api}}
@ -1996,13 +2246,25 @@ Changes to Python's build process and to the C API include:
\begin{itemize}
\item The Python source tree was converted from CVS to Subversion,
in a complex migration procedure that was supervised and flawlessly
carried out by Martin von~L\"owis. The procedure was developed as
\pep{347}.
\item Coverity, a company that markets a source code analysis tool
called Prevent, provided the results of their examination of the Python
source code. The analysis found about 60 bugs that
were quickly fixed. Many of the bugs were refcounting problems, often
occurring in error-handling code. See
\url{http://scan.coverity.com} for the statistics.
\item The largest change to the C API came from \pep{353},
which modifies the interpreter to use a \ctype{Py_ssize_t} type
definition instead of \ctype{int}. See the earlier
section~\ref{pep-353} for a discussion of this change.
\item The design of the bytecode compiler has changed a great deal, to
no longer generate bytecode by traversing the parse tree. Instead
\item The design of the bytecode compiler has changed a great deal,
no longer generating bytecode by traversing the parse tree. Instead
the parse tree is converted to an abstract syntax tree (or AST), and it is
the abstract syntax tree that's traversed to produce the bytecode.
@ -2022,12 +2284,13 @@ assignment = ast.body[0]
for_loop = ast.body[1]
\end{verbatim}
No documentation has been written for the AST code yet. To start
learning about it, read the definition of the various AST nodes in
\file{Parser/Python.asdl}. A Python script reads this file and
generates a set of C structure definitions in
\file{Include/Python-ast.h}. The \cfunction{PyParser_ASTFromString()}
and \cfunction{PyParser_ASTFromFile()}, defined in
No official documentation has been written for the AST code yet, but
\pep{339} discusses the design. To start learning about the code, read the
definition of the various AST nodes in \file{Parser/Python.asdl}. A
Python script reads this file and generates a set of C structure
definitions in \file{Include/Python-ast.h}. The
\cfunction{PyParser_ASTFromString()} and
\cfunction{PyParser_ASTFromFile()}, defined in
\file{Include/pythonrun.h}, take Python source as input and return the
root of an AST representing the contents. This AST can then be turned
into a code object by \cfunction{PyAST_Compile()}. For more
@ -2042,6 +2305,32 @@ Grant Edwards, John Ehresman, Kurt Kaiser, Neal Norwitz, Tim Peters,
Armin Rigo, and Neil Schemenauer, plus the participants in a number of
AST sprints at conferences such as PyCon.
\item Evan Jones's patch to obmalloc, first described in a talk
at PyCon DC 2005, was applied. Python 2.4 allocated small objects in
256K-sized arenas, but never freed arenas. With this patch, Python
will free arenas when they're empty. The net effect is that on some
platforms, when you allocate many objects, Python's memory usage may
actually drop when you delete them and the memory may be returned to
the operating system. (Implemented by Evan Jones, and reworked by Tim
Peters.)
Note that this change means extension modules must be more careful
when allocating memory. Python's API has many different
functions for allocating memory that are grouped into families. For
example, \cfunction{PyMem_Malloc()}, \cfunction{PyMem_Realloc()}, and
\cfunction{PyMem_Free()} are one family that allocates raw memory,
while \cfunction{PyObject_Malloc()}, \cfunction{PyObject_Realloc()},
and \cfunction{PyObject_Free()} are another family that's supposed to
be used for creating Python objects.
Previously these different families all reduced to the platform's
\cfunction{malloc()} and \cfunction{free()} functions. This meant
it didn't matter if you got things wrong and allocated memory with the
\cfunction{PyMem} function but freed it with the \cfunction{PyObject}
function. With 2.5's changes to obmalloc, these families now do different
things and mismatches will probably result in a segfault. You should
carefully test your C extension modules with Python 2.5.
\item The built-in set types now have an official C API. Call
\cfunction{PySet_New()} and \cfunction{PyFrozenSet_New()} to create a
new set, \cfunction{PySet_Add()} and \cfunction{PySet_Discard()} to
@ -2072,13 +2361,25 @@ Lundh at the NeedForSpeed sprint.)
\var{dict})} can now accept a tuple of base classes as its \var{base}
argument. (Contributed by Georg Brandl.)
\item The \cfunction{PyErr_Warn()} function for issuing warnings
is now deprecated in favour of \cfunction{PyErr_WarnEx(category,
message, stacklevel)} which lets you specify the number of stack
frames separating this function and the caller. A \var{stacklevel} of
1 is the function calling \cfunction{PyErr_WarnEx()}, 2 is the
function above that, and so forth. (Added by Neal Norwitz.)
\item The CPython interpreter is still written in C, but
the code can now be compiled with a {\Cpp} compiler without errors.
(Implemented by Anthony Baxter, Martin von~L\"owis, Skip Montanaro.)
\item The \cfunction{PyRange_New()} function was removed. It was
never documented, never used in the core code, and had dangerously lax
error checking.
error checking. In the unlikely case that your extensions were using
it, you can replace it by something like the following:
\begin{verbatim}
range = PyObject_CallFunction((PyObject*) &PyRange_Type, "lll",
start, stop, step);
\end{verbatim}
\end{itemize}
@ -2104,54 +2405,6 @@ be searched for.
\end{itemize}
%======================================================================
\section{Other Changes and Fixes \label{section-other}}
As usual, there were a bunch of other improvements and bugfixes
scattered throughout the source tree. A search through the SVN change
logs finds there were XXX patches applied and YYY bugs fixed between
Python 2.4 and 2.5. Both figures are likely to be underestimates.
Some of the more notable changes are:
\begin{itemize}
\item Evan Jones's patch to obmalloc, first described in a talk
at PyCon DC 2005, was applied. Python 2.4 allocated small objects in
256K-sized arenas, but never freed arenas. With this patch, Python
will free arenas when they're empty. The net effect is that on some
platforms, when you allocate many objects, Python's memory usage may
actually drop when you delete them, and the memory may be returned to
the operating system. (Implemented by Evan Jones, and reworked by Tim
Peters.)
Note that this change means extension modules need to be more careful
with how they allocate memory. Python's API has many different
functions for allocating memory that are grouped into families. For
example, \cfunction{PyMem_Malloc()}, \cfunction{PyMem_Realloc()}, and
\cfunction{PyMem_Free()} are one family that allocates raw memory,
while \cfunction{PyObject_Malloc()}, \cfunction{PyObject_Realloc()},
and \cfunction{PyObject_Free()} are another family that's supposed to
be used for creating Python objects.
Previously these different families all reduced to the platform's
\cfunction{malloc()} and \cfunction{free()} functions. This meant
it didn't matter if you got things wrong and allocated memory with the
\cfunction{PyMem} function but freed it with the \cfunction{PyObject}
function. With the obmalloc change, these families now do different
things, and mismatches will probably result in a segfault. You should
carefully test your C extension modules with Python 2.5.
\item Coverity, a company that markets a source code analysis tool
called Prevent, provided the results of their examination of the Python
source code. The analysis found about 60 bugs that
were quickly fixed. Many of the bugs were refcounting problems, often
occurring in error-handling code. See
\url{http://scan.coverity.com} for the statistics.
\end{itemize}
%======================================================================
\section{Porting to Python 2.5\label{porting}}
@ -2170,6 +2423,16 @@ was always a frame object. Because of the \pep{342} changes
described in section~\ref{pep-342}, it's now possible
for \member{gi_frame} to be \code{None}.
\item Library: the \module{csv} module is now stricter about multi-line quoted
fields. If your files contain newlines embedded within fields, the
input should be split into lines in a manner which preserves the
newline characters.
\item Library: the \module{locale} module's
\function{format()} function's would previously
accept any string as long as no more than one \%char specifier
appeared. In Python 2.5, the argument must be exactly one \%char
specifier with no surrounding text.
\item Library: The \module{pickle} and \module{cPickle} modules no
longer accept a return value of \code{None} from the
@ -2206,7 +2469,10 @@ freed with the corresponding family's \cfunction{*_Free()} function.
The author would like to thank the following people for offering
suggestions, corrections and assistance with various drafts of this
article: Phillip J. Eby, Kent Johnson, Martin von~L\"owis, Fredrik Lundh,
Gustavo Niemeyer, James Pryor, Mike Rovner, Scott Weikart, Thomas Wouters.
article: Georg Brandl, Nick Coghlan, Phillip J. Eby, Lars Gust\"abel,
Raymond Hettinger, Ralf W. Grosse-Kunstleve, Kent Johnson, Iain Lowe,
Martin von~L\"owis, Fredrik Lundh, Andrew McNamara, Skip Montanaro,
Gustavo Niemeyer, Paul Prescod, James Pryor, Mike Rovner, Scott
Weikart, Barry Warsaw, Thomas Wouters.
\end{document}

View File

@ -35,7 +35,7 @@
#endif
#include <string.h>
#ifndef DONT_HAVE_ERRNO_H
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
#include <stdlib.h>

View File

@ -41,8 +41,6 @@ typedef struct _frame {
/* As of 2.3 f_lineno is only valid when tracing is active (i.e. when
f_trace is set) -- at other times use PyCode_Addr2Line instead. */
int f_lineno; /* Current line number */
int f_restricted; /* Flag set if restricted operations
in this scope */
int f_iblock; /* index in f_blockstack */
PyTryBlock f_blockstack[CO_MAXBLOCKS]; /* for try and loop blocks */
PyObject *f_localsplus[1]; /* locals+stack, dynamically sized */
@ -54,6 +52,8 @@ typedef struct _frame {
PyAPI_DATA(PyTypeObject) PyFrame_Type;
#define PyFrame_Check(op) ((op)->ob_type == &PyFrame_Type)
#define PyFrame_IsRestricted(f) \
((f)->f_builtins != (f)->f_tstate->interp->builtins)
PyAPI_FUNC(PyFrameObject *) PyFrame_New(PyThreadState *, PyCodeObject *,
PyObject *, PyObject *);

View File

@ -218,10 +218,14 @@ PyAPI_FUNC(PyObject *) PyErr_NewException(char *name, PyObject *base,
PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
/* Issue a warning or exception */
PyAPI_FUNC(int) PyErr_Warn(PyObject *, char *);
PyAPI_FUNC(int) PyErr_WarnEx(PyObject *category, const char *msg,
Py_ssize_t stack_level);
PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *,
const char *, int,
const char *, PyObject *);
/* PyErr_Warn is only for backwards compatability and will be removed.
Use PyErr_WarnEx instead. */
#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
/* In sigcheck.c or signalmodule.c */
PyAPI_FUNC(int) PyErr_CheckSignals(void);

View File

@ -16,8 +16,8 @@ struct PyExpat_CAPI
the end, if needed */
const XML_LChar * (*ErrorString)(enum XML_Error code);
enum XML_Error (*GetErrorCode)(XML_Parser parser);
int (*GetErrorColumnNumber)(XML_Parser parser);
int (*GetErrorLineNumber)(XML_Parser parser);
XML_Size (*GetErrorColumnNumber)(XML_Parser parser);
XML_Size (*GetErrorLineNumber)(XML_Parser parser);
enum XML_Status (*Parse)(
XML_Parser parser, const char *s, int len, int isFinal);
XML_Parser (*ParserCreate_MM)(

View File

@ -240,10 +240,10 @@ typedef Py_intptr_t Py_ssize_t;
* to your pyconfig.h. Python code beyond this should check HAVE_STAT and
* HAVE_FSTAT instead.
* Also
* #define DONT_HAVE_SYS_STAT_H
* if <sys/stat.h> doesn't exist on your platform, and
* #define HAVE_SYS_STAT_H
* if <sys/stat.h> exists on your platform, and
* #define HAVE_STAT_H
* if <stat.h> does (don't look at me -- ths mess is inherited).
* if <stat.h> does.
*/
#ifndef DONT_HAVE_STAT
#define HAVE_STAT
@ -258,7 +258,7 @@ typedef Py_intptr_t Py_ssize_t;
#include "unixstuff.h"
#endif
#ifndef DONT_HAVE_SYS_STAT_H
#ifdef HAVE_SYS_STAT_H
#if defined(PYOS_OS2) && defined(PYCC_GCC)
#include <sys/types.h>
#endif

View File

@ -171,6 +171,11 @@ PyAPI_FUNC(void) PyGILState_Release(PyGILState_STATE);
*/
PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
/* The implementation of sys._current_frames() Returns a dict mapping
thread id to that thread's current frame.
*/
PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
/* Routines for advanced debuggers, requested by David Beazley.
Don't use unless you know what you are doing! */
PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);

View File

@ -25,6 +25,9 @@ PyAPI_FUNC(int) PyThread_acquire_lock(PyThread_type_lock, int);
#define NOWAIT_LOCK 0
PyAPI_FUNC(void) PyThread_release_lock(PyThread_type_lock);
PyAPI_FUNC(size_t) PyThread_get_stacksize(void);
PyAPI_FUNC(int) PyThread_set_stacksize(size_t);
#ifndef NO_EXIT_PROG
PyAPI_FUNC(void) PyThread_exit_prog(int);
PyAPI_FUNC(void) PyThread__PyThread_exit_prog(int);

View File

@ -35,14 +35,14 @@ typedef struct _setobject PySetObject;
struct _setobject {
PyObject_HEAD
int fill; /* # Active + # Dummy */
int used; /* # Active */
Py_ssize_t fill; /* # Active + # Dummy */
Py_ssize_t used; /* # Active */
/* The table contains mask + 1 slots, and that's a power of 2.
* We store the mask instead of the size because the mask is more
* frequently needed.
*/
int mask;
Py_ssize_t mask;
/* table points to smalltable for small tables, else to
* additional malloc'ed memory. table is never NULL! This rule

Some files were not shown because too many files have changed in this diff Show More