[Python-checkins] r58615 - in python/branches/ctypes-branch: Doc/ACKS.txt Doc/Makefile Doc/c-api/abstract.rst Doc/c-api/index.rst Doc/contents.rst Doc/distutils/apiref.rst Doc/distutils/builtdist.rst Doc/documenting/markup.rst Doc/extending/newtypes.rst Doc/glossary.rst Doc/howto/functional.rst Doc/howto/index.rst Doc/howto/pythonmac.rst Doc/howto/regex.rst Doc/includes/email-unpack.py Doc/library/_ast.rst Doc/library/autogil.rst Doc/library/codecs.rst Doc/library/collections.rst Doc/library/compiler.rst Doc/library/contextlib.rst Doc/library/cookielib.rst Doc/library/csv.rst Doc/library/ctypes.rst Doc/library/difflib.rst Doc/library/dis.rst Doc/library/exceptions.rst Doc/library/filecmp.rst Doc/library/functions.rst Doc/library/glob.rst Doc/library/heapq.rst Doc/library/inspect.rst Doc/library/itertools.rst Doc/library/logging.rst Doc/library/mailbox.rst Doc/library/mmap.rst Doc/library/os.path.rst Doc/library/os.rst Doc/library/parser.rst Doc/library/pickle.rst Doc/library/pickletools.rst Doc/library/pty.rst Doc/library/pyclbr.rst Doc/library/re.rst Doc/library/sqlite3.rst Doc/library/ssl.rst Doc/library/stdtypes.rst Doc/library/tokenize.rst Doc/library/types.rst Doc/library/urllib.rst Doc/library/weakref.rst Doc/library/wsgiref.rst Doc/library/xml.etree.elementtree.rst Doc/library/xmlrpclib.rst Doc/reference/compound_stmts.rst Doc/reference/datamodel.rst Doc/tutorial/classes.rst Doc/tutorial/interactive.rst Doc/tutorial/modules.rst Doc/using Doc/whatsnew/2.6.rst Lib/bsddb/dbshelve.py Lib/bsddb/dbtables.py Lib/bsddb/test/test_1413192.py Lib/bsddb/test/test_dbshelve.py Lib/bsddb/test/test_dbtables.py Lib/collections.py Lib/ctypes/__init__.py Lib/decimal.py Lib/httplib.py Lib/idlelib/EditorWindow.py Lib/idlelib/NEWS.txt Lib/idlelib/configDialog.py Lib/idlelib/run.py Lib/smtpd.py Lib/test/crashers/file_threads.py Lib/test/crashers/multithreaded_close.py Lib/test/test_collections.py Lib/test/test_decimal.py Lib/test/test_deque.py Lib/test/test_httplib.py Lib/test/test_itertools.py Lib/test/test_list.py Lib/test/test_mmap.py Lib/test/test_support.py Lib/test/test_zlib.py Makefile.pre.in Misc/NEWS Misc/developers.txt Modules/_bsddb.c Modules/_collectionsmodule.c Modules/_ctypes/cfield.c Modules/_ctypes/libffi/src/alpha/ffi.c Modules/_ctypes/libffi/src/ia64/ffi.c Modules/_ctypes/libffi/src/mips/ffi.c Modules/_ctypes/libffi/src/pa/ffi.c Modules/_ctypes/libffi/src/powerpc/ffi.c Modules/_ctypes/libffi/src/s390/ffi.c Modules/_ctypes/libffi/src/sparc/ffi.c Modules/main.c Modules/mmapmodule.c Objects/dictobject.c Objects/listobject.c PC/pyconfig.h Parser/pgen.c Parser/tokenizer.c Python/marshal.c setup.py

thomas.heller python-checkins at python.org
Tue Oct 23 20:47:54 CEST 2007


Author: thomas.heller
Date: Tue Oct 23 20:47:50 2007
New Revision: 58615

Added:
   python/branches/ctypes-branch/Doc/using/
      - copied from r58609, python/trunk/Doc/using/
   python/branches/ctypes-branch/Lib/test/crashers/multithreaded_close.py
      - copied unchanged from r58609, python/trunk/Lib/test/crashers/multithreaded_close.py
Removed:
   python/branches/ctypes-branch/Doc/howto/pythonmac.rst
   python/branches/ctypes-branch/Lib/test/crashers/file_threads.py
Modified:
   python/branches/ctypes-branch/   (props changed)
   python/branches/ctypes-branch/Doc/ACKS.txt
   python/branches/ctypes-branch/Doc/Makefile
   python/branches/ctypes-branch/Doc/c-api/abstract.rst
   python/branches/ctypes-branch/Doc/c-api/index.rst
   python/branches/ctypes-branch/Doc/contents.rst
   python/branches/ctypes-branch/Doc/distutils/apiref.rst
   python/branches/ctypes-branch/Doc/distutils/builtdist.rst
   python/branches/ctypes-branch/Doc/documenting/markup.rst
   python/branches/ctypes-branch/Doc/extending/newtypes.rst
   python/branches/ctypes-branch/Doc/glossary.rst
   python/branches/ctypes-branch/Doc/howto/functional.rst
   python/branches/ctypes-branch/Doc/howto/index.rst
   python/branches/ctypes-branch/Doc/howto/regex.rst
   python/branches/ctypes-branch/Doc/includes/email-unpack.py
   python/branches/ctypes-branch/Doc/library/_ast.rst
   python/branches/ctypes-branch/Doc/library/autogil.rst
   python/branches/ctypes-branch/Doc/library/codecs.rst
   python/branches/ctypes-branch/Doc/library/collections.rst
   python/branches/ctypes-branch/Doc/library/compiler.rst
   python/branches/ctypes-branch/Doc/library/contextlib.rst
   python/branches/ctypes-branch/Doc/library/cookielib.rst
   python/branches/ctypes-branch/Doc/library/csv.rst
   python/branches/ctypes-branch/Doc/library/ctypes.rst
   python/branches/ctypes-branch/Doc/library/difflib.rst
   python/branches/ctypes-branch/Doc/library/dis.rst
   python/branches/ctypes-branch/Doc/library/exceptions.rst
   python/branches/ctypes-branch/Doc/library/filecmp.rst
   python/branches/ctypes-branch/Doc/library/functions.rst
   python/branches/ctypes-branch/Doc/library/glob.rst
   python/branches/ctypes-branch/Doc/library/heapq.rst
   python/branches/ctypes-branch/Doc/library/inspect.rst
   python/branches/ctypes-branch/Doc/library/itertools.rst
   python/branches/ctypes-branch/Doc/library/logging.rst
   python/branches/ctypes-branch/Doc/library/mailbox.rst
   python/branches/ctypes-branch/Doc/library/mmap.rst
   python/branches/ctypes-branch/Doc/library/os.path.rst
   python/branches/ctypes-branch/Doc/library/os.rst
   python/branches/ctypes-branch/Doc/library/parser.rst
   python/branches/ctypes-branch/Doc/library/pickle.rst
   python/branches/ctypes-branch/Doc/library/pickletools.rst
   python/branches/ctypes-branch/Doc/library/pty.rst
   python/branches/ctypes-branch/Doc/library/pyclbr.rst
   python/branches/ctypes-branch/Doc/library/re.rst
   python/branches/ctypes-branch/Doc/library/sqlite3.rst
   python/branches/ctypes-branch/Doc/library/ssl.rst
   python/branches/ctypes-branch/Doc/library/stdtypes.rst
   python/branches/ctypes-branch/Doc/library/tokenize.rst
   python/branches/ctypes-branch/Doc/library/types.rst
   python/branches/ctypes-branch/Doc/library/urllib.rst
   python/branches/ctypes-branch/Doc/library/weakref.rst
   python/branches/ctypes-branch/Doc/library/wsgiref.rst
   python/branches/ctypes-branch/Doc/library/xml.etree.elementtree.rst
   python/branches/ctypes-branch/Doc/library/xmlrpclib.rst
   python/branches/ctypes-branch/Doc/reference/compound_stmts.rst
   python/branches/ctypes-branch/Doc/reference/datamodel.rst
   python/branches/ctypes-branch/Doc/tutorial/classes.rst
   python/branches/ctypes-branch/Doc/tutorial/interactive.rst
   python/branches/ctypes-branch/Doc/tutorial/modules.rst
   python/branches/ctypes-branch/Doc/whatsnew/2.6.rst
   python/branches/ctypes-branch/Lib/bsddb/dbshelve.py
   python/branches/ctypes-branch/Lib/bsddb/dbtables.py
   python/branches/ctypes-branch/Lib/bsddb/test/test_1413192.py
   python/branches/ctypes-branch/Lib/bsddb/test/test_dbshelve.py
   python/branches/ctypes-branch/Lib/bsddb/test/test_dbtables.py
   python/branches/ctypes-branch/Lib/collections.py
   python/branches/ctypes-branch/Lib/ctypes/__init__.py
   python/branches/ctypes-branch/Lib/decimal.py
   python/branches/ctypes-branch/Lib/httplib.py
   python/branches/ctypes-branch/Lib/idlelib/EditorWindow.py
   python/branches/ctypes-branch/Lib/idlelib/NEWS.txt
   python/branches/ctypes-branch/Lib/idlelib/configDialog.py
   python/branches/ctypes-branch/Lib/idlelib/run.py
   python/branches/ctypes-branch/Lib/smtpd.py
   python/branches/ctypes-branch/Lib/test/test_collections.py
   python/branches/ctypes-branch/Lib/test/test_decimal.py
   python/branches/ctypes-branch/Lib/test/test_deque.py
   python/branches/ctypes-branch/Lib/test/test_httplib.py
   python/branches/ctypes-branch/Lib/test/test_itertools.py
   python/branches/ctypes-branch/Lib/test/test_list.py
   python/branches/ctypes-branch/Lib/test/test_mmap.py
   python/branches/ctypes-branch/Lib/test/test_support.py
   python/branches/ctypes-branch/Lib/test/test_zlib.py
   python/branches/ctypes-branch/Makefile.pre.in
   python/branches/ctypes-branch/Misc/NEWS
   python/branches/ctypes-branch/Misc/developers.txt
   python/branches/ctypes-branch/Modules/_bsddb.c
   python/branches/ctypes-branch/Modules/_collectionsmodule.c
   python/branches/ctypes-branch/Modules/_ctypes/cfield.c
   python/branches/ctypes-branch/Modules/_ctypes/libffi/src/alpha/ffi.c
   python/branches/ctypes-branch/Modules/_ctypes/libffi/src/ia64/ffi.c
   python/branches/ctypes-branch/Modules/_ctypes/libffi/src/mips/ffi.c
   python/branches/ctypes-branch/Modules/_ctypes/libffi/src/pa/ffi.c
   python/branches/ctypes-branch/Modules/_ctypes/libffi/src/powerpc/ffi.c
   python/branches/ctypes-branch/Modules/_ctypes/libffi/src/s390/ffi.c
   python/branches/ctypes-branch/Modules/_ctypes/libffi/src/sparc/ffi.c
   python/branches/ctypes-branch/Modules/main.c
   python/branches/ctypes-branch/Modules/mmapmodule.c
   python/branches/ctypes-branch/Objects/dictobject.c
   python/branches/ctypes-branch/Objects/listobject.c
   python/branches/ctypes-branch/PC/pyconfig.h
   python/branches/ctypes-branch/Parser/pgen.c
   python/branches/ctypes-branch/Parser/tokenizer.c
   python/branches/ctypes-branch/Python/marshal.c
   python/branches/ctypes-branch/setup.py
Log:
Merged revisions 58393-58614 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r58394 | gregory.p.smith | 2007-10-09 20:26:02 +0200 (Di, 09 Okt 2007) | 2 lines
  
  remove another sleepycat reference
........
  r58396 | kurt.kaiser | 2007-10-09 21:31:30 +0200 (Di, 09 Okt 2007) | 3 lines
  
  Allow interrupt only when executing user code in subprocess
  Patch 1225 Tal Einat modified from IDLE-Spoon.
........
  r58399 | brett.cannon | 2007-10-10 02:07:50 +0200 (Mi, 10 Okt 2007) | 5 lines
  
  Remove file-level typedefs that were inconsistently used throughout the file.
  Just move over to the public API names.
  
  Closes issue1238.
........
  r58401 | raymond.hettinger | 2007-10-10 02:26:46 +0200 (Mi, 10 Okt 2007) | 1 line
  
  Accept Jim Jewett's api suggestion to use None instead of -1 to indicate unbounded deques.
........
  r58403 | kurt.kaiser | 2007-10-10 02:55:40 +0200 (Mi, 10 Okt 2007) | 2 lines
  
  Allow cursor color change w/o restart. Patch 1725576 Tal Einat.
........
  r58404 | kurt.kaiser | 2007-10-10 03:06:47 +0200 (Mi, 10 Okt 2007) | 2 lines
  
  show paste if > 80 columns.  Patch 1659326 Tal Einat.
........
  r58415 | thomas.heller | 2007-10-11 21:51:32 +0200 (Do, 11 Okt 2007) | 5 lines
  
  On OS X, use os.uname() instead of gestalt.sysv(...) to get the
  operating system version.  This allows to use ctypes when Python
  was configured with --disable-toolbox-glue.
........
  r58419 | neal.norwitz | 2007-10-12 05:01:01 +0200 (Fr, 12 Okt 2007) | 1 line
  
  Get rid of warning about not being able to create an existing directory.
........
  r58420 | neal.norwitz | 2007-10-12 05:01:30 +0200 (Fr, 12 Okt 2007) | 1 line
  
  Get rid of warnings on a bunch of platforms by using a proper prototype.
........
  r58421 | neal.norwitz | 2007-10-12 05:01:54 +0200 (Fr, 12 Okt 2007) | 4 lines
  
  Get rid of compiler warning about retval being used (returned) without
  being initialized.  (gcc warning and Coverity 202)
........
  r58422 | neal.norwitz | 2007-10-12 05:03:23 +0200 (Fr, 12 Okt 2007) | 1 line
  
  Fix Coverity 168:  Close the file before returning (exiting).
........
  r58423 | neal.norwitz | 2007-10-12 05:04:18 +0200 (Fr, 12 Okt 2007) | 4 lines
  
  Fix Coverity 180:  Don't overallocate.  We don't need structs, but pointers.
  Also fix a memory leak.
........
  r58424 | neal.norwitz | 2007-10-12 05:05:19 +0200 (Fr, 12 Okt 2007) | 5 lines
  
  Fix Coverity 185-186:  If the passed in FILE is NULL, uninitialized memory
  would be accessed.
  
  Will backport.
........
  r58425 | neal.norwitz | 2007-10-12 05:52:34 +0200 (Fr, 12 Okt 2007) | 1 line
  
  Get this module to compile with bsddb versions prior to 4.3
........
  r58430 | martin.v.loewis | 2007-10-12 10:56:52 +0200 (Fr, 12 Okt 2007) | 3 lines
  
  Bug #1216: Restore support for Visual Studio 2002.
  Will backport to 2.5.
........
  r58433 | raymond.hettinger | 2007-10-12 19:53:11 +0200 (Fr, 12 Okt 2007) | 1 line
  
  Fix test of count.__repr__() to ignore the 'L' if the count is a long
........
  r58434 | gregory.p.smith | 2007-10-12 20:44:06 +0200 (Fr, 12 Okt 2007) | 4 lines
  
  Fixes http://bugs.python.org/issue1233 - bsddb.dbshelve.DBShelf.append
  was useless due to inverted logic.  Also adds a test case for RECNO dbs
  to test_dbshelve.
........
  r58445 | georg.brandl | 2007-10-13 15:20:03 +0200 (Sa, 13 Okt 2007) | 2 lines
  
  Fix email example.
........
  r58450 | gregory.p.smith | 2007-10-14 01:02:05 +0200 (So, 14 Okt 2007) | 2 lines
  
  Fix an uncollectable reference leak in bsddb.db.DBShelf.append
........
  r58453 | neal.norwitz | 2007-10-14 02:18:40 +0200 (So, 14 Okt 2007) | 8 lines
  
  Let the O/S supply a port if none of the default ports can be used.
  This should make the tests more robust at the expense of allowing
  tests to be sloppier by not requiring them to cleanup after themselves.
  (It will legitamitely help when running two test suites simultaneously
  or if another process is already using one of the predefined ports.)
  
  Also simplifies (slightLy) the exception handling elsewhere.
........
  r58459 | neal.norwitz | 2007-10-14 20:30:21 +0200 (So, 14 Okt 2007) | 2 lines
  
  Don't raise a string exception, they don't work anymore.
........
  r58460 | neal.norwitz | 2007-10-14 20:40:37 +0200 (So, 14 Okt 2007) | 1 line
  
  Use unittest for assertions
........
  r58468 | armin.rigo | 2007-10-15 09:48:35 +0200 (Mo, 15 Okt 2007) | 2 lines
  
  test_bigbits was not testing what it seemed to.
........
  r58471 | guido.van.rossum | 2007-10-15 17:54:11 +0200 (Mo, 15 Okt 2007) | 3 lines
  
  Change a PyErr_Print() into a PyErr_Clear(),
  per discussion in issue 1031213.
........
  r58500 | raymond.hettinger | 2007-10-16 21:18:30 +0200 (Di, 16 Okt 2007) | 1 line
  
  Improve error messages
........
  r58506 | raymond.hettinger | 2007-10-16 23:28:32 +0200 (Di, 16 Okt 2007) | 1 line
  
  More docs, error messages, and tests
........
  r58507 | andrew.kuchling | 2007-10-17 00:58:03 +0200 (Mi, 17 Okt 2007) | 1 line
  
  Add items
........
  r58508 | brett.cannon | 2007-10-17 01:24:06 +0200 (Mi, 17 Okt 2007) | 3 lines
  
  Remove ``:const:`` notation on None in parameter list.  Since the markup is not
  rendered for parameters it just showed up as ``:const:`None` `` in the output.
........
  r58509 | brett.cannon | 2007-10-17 01:26:45 +0200 (Mi, 17 Okt 2007) | 3 lines
  
  Re-order some functions whose parameters differ between PyObject and const char
  * so that they are next to each other.
........
  r58522 | armin.rigo | 2007-10-17 20:46:37 +0200 (Mi, 17 Okt 2007) | 5 lines
  
  Fix the overflow checking of list_repeat.
  Introduce overflow checking into list_inplace_repeat.
  
  Backport candidate, possibly.
........
  r58530 | facundo.batista | 2007-10-18 05:16:03 +0200 (Do, 18 Okt 2007) | 7 lines
  
  
  Issue #1580738.  When HTTPConnection reads the whole stream with read(),
  it closes itself.  When the stream is read in several calls to read(n),
  it should behave in the same way if HTTPConnection knows where the end
  of the stream is (through self.length).  Added a test case for this
  behaviour. 
........
  r58531 | facundo.batista | 2007-10-18 05:44:48 +0200 (Do, 18 Okt 2007) | 3 lines
  
  
  Issue 1289, just a typo.
........
  r58532 | gregory.p.smith | 2007-10-18 09:56:54 +0200 (Do, 18 Okt 2007) | 4 lines
  
  cleanup test_dbtables to use mkdtemp.  cleanup dbtables to pass txn as a
  keyword argument whenever possible to avoid bugs and confusion.  (dbtables.py
  line 447 self.db.get using txn as a non-keyword was an actual bug due to this)
........
  r58533 | gregory.p.smith | 2007-10-18 10:34:20 +0200 (Do, 18 Okt 2007) | 4 lines
  
  Fix a weird bug in dbtables: if it chose a random rowid string that contained
  NULL bytes it would cause the database all sorts of problems in the future
  leading to very strange random failures and corrupt dbtables.bsdTableDb dbs.
........
  r58534 | gregory.p.smith | 2007-10-18 18:32:02 +0200 (Do, 18 Okt 2007) | 3 lines
  
  A cleaner fix than the one committed last night.  Generate random rowids that
  do not contain null bytes.
........
  r58537 | gregory.p.smith | 2007-10-18 19:17:57 +0200 (Do, 18 Okt 2007) | 2 lines
  
  mention bsddb fixes.
........
  r58538 | raymond.hettinger | 2007-10-18 23:13:06 +0200 (Do, 18 Okt 2007) | 1 line
  
  Remove useless warning
........
  r58539 | gregory.p.smith | 2007-10-19 09:31:20 +0200 (Fr, 19 Okt 2007) | 2 lines
  
  squelch the warning that this test is supposed to trigger.
........
  r58542 | georg.brandl | 2007-10-19 14:32:39 +0200 (Fr, 19 Okt 2007) | 2 lines
  
  Clarify wording for apply().
........
  r58544 | mark.summerfield | 2007-10-19 14:48:17 +0200 (Fr, 19 Okt 2007) | 3 lines
  
  Added a cross-ref to each other.
........
  r58545 | georg.brandl | 2007-10-19 19:38:49 +0200 (Fr, 19 Okt 2007) | 2 lines
  
  #1284: "S" means "seen", not unread.
........
  r58548 | thomas.heller | 2007-10-19 20:11:41 +0200 (Fr, 19 Okt 2007) | 4 lines
  
  Fix ctypes on 32-bit systems when Python is configured --with-system-ffi.
  See also https://bugs.launchpad.net/bugs/72505.
  
  Ported from release25-maint branch.
........
  r58550 | facundo.batista | 2007-10-19 21:25:57 +0200 (Fr, 19 Okt 2007) | 8 lines
  
  
  The constructor from tuple was way too permissive: it allowed bad
  coefficient numbers, floats in the sign, and other details that 
  generated directly the wrong number in the best case, or triggered
  misfunctionality in the alorithms.
  
  Test cases added for these issues. Thanks Mark Dickinson.
........
  r58559 | georg.brandl | 2007-10-20 15:22:53 +0200 (Sa, 20 Okt 2007) | 2 lines
  
  Fix code being interpreted as a target.
........
  r58561 | georg.brandl | 2007-10-20 15:36:24 +0200 (Sa, 20 Okt 2007) | 2 lines
  
  Document new "cmdoption" directive.
........
  r58562 | georg.brandl | 2007-10-20 17:21:22 +0200 (Sa, 20 Okt 2007) | 2 lines
  
  Make a path more Unix-standardy.
........
  r58564 | georg.brandl | 2007-10-20 19:51:39 +0200 (Sa, 20 Okt 2007) | 2 lines
  
  Document new directive "envvar".
........
  r58567 | georg.brandl | 2007-10-20 20:08:14 +0200 (Sa, 20 Okt 2007) | 6 lines
  
  * Add new toplevel chapter, "Using Python." (how to install,
    configure and setup python on different platforms -- at least
    in theory.)
  * Move the Python on Mac docs in that chapter.
  * Add a new chapter about the command line invocation, by stargaming.
........
  r58568 | georg.brandl | 2007-10-20 20:33:20 +0200 (Sa, 20 Okt 2007) | 2 lines
  
  Change title, for now.
........
  r58569 | georg.brandl | 2007-10-20 20:39:25 +0200 (Sa, 20 Okt 2007) | 2 lines
  
  Add entry to ACKS.
........
  r58570 | georg.brandl | 2007-10-20 21:05:45 +0200 (Sa, 20 Okt 2007) | 2 lines
  
  Clarify -E docs.
........
  r58571 | georg.brandl | 2007-10-20 21:08:36 +0200 (Sa, 20 Okt 2007) | 2 lines
  
  Even more clarification.
........
  r58572 | andrew.kuchling | 2007-10-20 21:25:37 +0200 (Sa, 20 Okt 2007) | 1 line
  
  Fix protocol name
........
  r58573 | andrew.kuchling | 2007-10-20 21:35:18 +0200 (Sa, 20 Okt 2007) | 1 line
  
  Various items
........
  r58574 | andrew.kuchling | 2007-10-20 21:39:35 +0200 (Sa, 20 Okt 2007) | 1 line
  
  Use correct header line
........
  r58576 | armin.rigo | 2007-10-21 11:14:15 +0200 (So, 21 Okt 2007) | 3 lines
  
  Add a crasher for the long-standing issue with closing a file
  while another thread uses it.
........
  r58577 | georg.brandl | 2007-10-21 12:01:56 +0200 (So, 21 Okt 2007) | 2 lines
  
  Remove duplicate crasher.
........
  r58578 | georg.brandl | 2007-10-21 12:24:20 +0200 (So, 21 Okt 2007) | 2 lines
  
  Unify "byte code" to "bytecode". Also sprinkle :term: markup for it.
........
  r58579 | georg.brandl | 2007-10-21 12:32:54 +0200 (So, 21 Okt 2007) | 2 lines
  
  Add markup to new function descriptions.
........
  r58580 | georg.brandl | 2007-10-21 12:45:46 +0200 (So, 21 Okt 2007) | 2 lines
  
  Add :term:s for descriptors.
........
  r58581 | georg.brandl | 2007-10-21 12:46:24 +0200 (So, 21 Okt 2007) | 2 lines
  
  Unify "file-descriptor" to "file descriptor".
........
  r58582 | georg.brandl | 2007-10-21 12:52:38 +0200 (So, 21 Okt 2007) | 2 lines
  
  Add :term: for generators.
........
  r58583 | georg.brandl | 2007-10-21 14:10:28 +0200 (So, 21 Okt 2007) | 2 lines
  
  Add :term:s for iterator.
........
  r58584 | georg.brandl | 2007-10-21 14:15:05 +0200 (So, 21 Okt 2007) | 2 lines
  
  Add :term:s for "new-style class".
........
  r58588 | neal.norwitz | 2007-10-22 06:47:54 +0200 (Mo, 22 Okt 2007) | 1 line
  
  Add Chris Monson so he can edit PEPs.
........
  r58594 | guido.van.rossum | 2007-10-22 18:27:19 +0200 (Mo, 22 Okt 2007) | 4 lines
  
  Issue #1307, patch by Derek Shockey.
  When "MAIL" is received without args, an exception happens instead of
  sending a 501 syntax error response.
........
  r58598 | travis.oliphant | 2007-10-23 04:40:56 +0200 (Di, 23 Okt 2007) | 1 line
  
  Add phuang patch from Issue 708374 which adds offset parameter to mmap module.
........
  r58601 | neal.norwitz | 2007-10-23 07:44:27 +0200 (Di, 23 Okt 2007) | 2 lines
  
  Bug #1313, fix typo (wrong variable name) in example.
........
  r58609 | georg.brandl | 2007-10-23 20:21:35 +0200 (Di, 23 Okt 2007) | 2 lines
  
  Update Pygments version from externals.
........


Modified: python/branches/ctypes-branch/Doc/ACKS.txt
==============================================================================
--- python/branches/ctypes-branch/Doc/ACKS.txt	(original)
+++ python/branches/ctypes-branch/Doc/ACKS.txt	Tue Oct 23 20:47:50 2007
@@ -103,6 +103,7 @@
 * Detlef Lannert
 * Piers Lauder
 * Glyph Lefkowitz
+* Robert Lehmann
 * Marc-André Lemburg
 * Ulf A. Lindgren
 * Everett Lipman

Modified: python/branches/ctypes-branch/Doc/Makefile
==============================================================================
--- python/branches/ctypes-branch/Doc/Makefile	(original)
+++ python/branches/ctypes-branch/Doc/Makefile	Tue Oct 23 20:47:50 2007
@@ -29,7 +29,7 @@
 	fi
 	@if [ ! -d tools/pygments ]; then \
 	  echo "Checking out Pygments..."; \
-	  svn checkout $(SVNROOT)/external/Pygments-0.8.1/pygments tools/pygments; \
+	  svn checkout $(SVNROOT)/external/Pygments-0.9/pygments tools/pygments; \
 	fi
 
 update: checkout

Modified: python/branches/ctypes-branch/Doc/c-api/abstract.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/c-api/abstract.rst	(original)
+++ python/branches/ctypes-branch/Doc/c-api/abstract.rst	Tue Oct 23 20:47:50 2007
@@ -31,21 +31,14 @@
    instead of the :func:`repr`.
 
 
-.. cfunction:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
+.. cfunction:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name)
 
    Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise.  This
    is equivalent to the Python expression ``hasattr(o, attr_name)``.  This function
    always succeeds.
 
 
-.. cfunction:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name)
-
-   Retrieve an attribute named *attr_name* from object *o*. Returns the attribute
-   value on success, or *NULL* on failure. This is the equivalent of the Python
-   expression ``o.attr_name``.
-
-
-.. cfunction:: int PyObject_HasAttr(PyObject *o, PyObject *attr_name)
+.. cfunction:: int PyObject_HasAttrString(PyObject *o, const char *attr_name)
 
    Returns ``1`` if *o* has the attribute *attr_name*, and ``0`` otherwise.  This
    is equivalent to the Python expression ``hasattr(o, attr_name)``.  This function
@@ -59,27 +52,34 @@
    expression ``o.attr_name``.
 
 
-.. cfunction:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)
+.. cfunction:: PyObject* PyObject_GetAttrString(PyObject *o, const char *attr_name)
+
+   Retrieve an attribute named *attr_name* from object *o*. Returns the attribute
+   value on success, or *NULL* on failure. This is the equivalent of the Python
+   expression ``o.attr_name``.
+
+
+.. cfunction:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v)
 
    Set the value of the attribute named *attr_name*, for object *o*, to the value
    *v*. Returns ``-1`` on failure.  This is the equivalent of the Python statement
    ``o.attr_name = v``.
 
 
-.. cfunction:: int PyObject_SetAttr(PyObject *o, PyObject *attr_name, PyObject *v)
+.. cfunction:: int PyObject_SetAttrString(PyObject *o, const char *attr_name, PyObject *v)
 
    Set the value of the attribute named *attr_name*, for object *o*, to the value
    *v*. Returns ``-1`` on failure.  This is the equivalent of the Python statement
    ``o.attr_name = v``.
 
 
-.. cfunction:: int PyObject_DelAttrString(PyObject *o, const char *attr_name)
+.. cfunction:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name)
 
    Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure.
-   This is the equivalent of the Python statement: ``del o.attr_name``.
+   This is the equivalent of the Python statement ``del o.attr_name``.
 
 
-.. cfunction:: int PyObject_DelAttr(PyObject *o, PyObject *attr_name)
+.. cfunction:: int PyObject_DelAttrString(PyObject *o, const char *attr_name)
 
    Delete attribute named *attr_name*, for object *o*. Returns ``-1`` on failure.
    This is the equivalent of the Python statement ``del o.attr_name``.
@@ -351,7 +351,7 @@
 
 .. cfunction:: int PyObject_AsFileDescriptor(PyObject *o)
 
-   Derives a file-descriptor from a Python object.  If the object is an integer or
+   Derives a file descriptor from a Python object.  If the object is an integer or
    long integer, its value is returned.  If not, the object's :meth:`fileno` method
    is called if it exists; the method must return an integer or long integer, which
    is returned as the file descriptor value.  Returns ``-1`` on failure.

Modified: python/branches/ctypes-branch/Doc/c-api/index.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/c-api/index.rst	(original)
+++ python/branches/ctypes-branch/Doc/c-api/index.rst	Tue Oct 23 20:47:50 2007
@@ -12,12 +12,6 @@
 which describes the general principles of extension writing but does not
 document the API functions in detail.
 
-.. warning::
-
-   The current version of this document is somewhat incomplete. However, most of
-   the important functions, types and structures are described.
-
-
 .. toctree::
    :maxdepth: 2
 

Modified: python/branches/ctypes-branch/Doc/contents.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/contents.rst	(original)
+++ python/branches/ctypes-branch/Doc/contents.rst	Tue Oct 23 20:47:50 2007
@@ -6,6 +6,7 @@
 
    whatsnew/2.6.rst
    tutorial/index.rst
+   using/index.rst
    reference/index.rst
    library/index.rst
    extending/index.rst

Modified: python/branches/ctypes-branch/Doc/distutils/apiref.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/distutils/apiref.rst	(original)
+++ python/branches/ctypes-branch/Doc/distutils/apiref.rst	Tue Oct 23 20:47:50 2007
@@ -1199,7 +1199,7 @@
 
    If *force* is true, all files are recompiled regardless of timestamps.
 
-   The source filename encoded in each bytecode file defaults to the filenames
+   The source filename encoded in each :term:`bytecode` file defaults to the filenames
    listed in *py_files*; you can modify these with *prefix* and *basedir*.
    *prefix* is a string that will be stripped off of each source filename, and
    *base_dir* is a directory name that will be prepended (after *prefix* is

Modified: python/branches/ctypes-branch/Doc/distutils/builtdist.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/distutils/builtdist.rst	(original)
+++ python/branches/ctypes-branch/Doc/distutils/builtdist.rst	Tue Oct 23 20:47:50 2007
@@ -311,7 +311,7 @@
 have to create a separate installer for every Python version you want to
 support.
 
-The installer will try to compile pure modules into bytecode after installation
+The installer will try to compile pure modules into :term:`bytecode` after installation
 on the target system in normal and optimizing mode.  If you don't want this to
 happen for some reason, you can run the :command:`bdist_wininst` command with
 the :option:`--no-target-compile` and/or the :option:`--no-target-optimize`

Modified: python/branches/ctypes-branch/Doc/documenting/markup.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/documenting/markup.rst	(original)
+++ python/branches/ctypes-branch/Doc/documenting/markup.rst	Tue Oct 23 20:47:50 2007
@@ -210,7 +210,20 @@
 
 .. describe:: opcode
 
-   Describes a Python bytecode instruction.
+   Describes a Python :term:`bytecode` instruction.
+
+.. describe:: cmdoption
+
+   Describes a command line option or switch.  Option argument names should be
+   enclosed in angle brackets.  Example::
+
+      .. cmdoption:: -m <module>
+
+         Run a module as a script.
+
+.. describe:: envvar
+
+   Describes an environment variable that Python uses or defines.
 
 
 There is also a generic version of these directives:

Modified: python/branches/ctypes-branch/Doc/extending/newtypes.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/extending/newtypes.rst	(original)
+++ python/branches/ctypes-branch/Doc/extending/newtypes.rst	Tue Oct 23 20:47:50 2007
@@ -1149,7 +1149,7 @@
 attributes, when the values are computed, or how relevant data is stored.
 
 When :cfunc:`PyType_Ready` is called, it uses three tables referenced by the
-type object to create *descriptors* which are placed in the dictionary of the
+type object to create :term:`descriptor`\s which are placed in the dictionary of the
 type object.  Each descriptor controls access to one attribute of the instance
 object.  Each of the tables is optional; if all three are *NULL*, instances of
 the type will only have attributes that are inherited from their base type, and
@@ -1193,7 +1193,7 @@
        char *doc;
    } PyMemberDef;
 
-For each entry in the table, a descriptor will be constructed and added to the
+For each entry in the table, a :term:`descriptor` will be constructed and added to the
 type which will be able to extract a value from the instance structure.  The
 :attr:`type` field should contain one of the type codes defined in the
 :file:`structmember.h` header; the value will be used to determine how to

Modified: python/branches/ctypes-branch/Doc/glossary.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/glossary.rst	(original)
+++ python/branches/ctypes-branch/Doc/glossary.rst	Tue Oct 23 20:47:50 2007
@@ -20,13 +20,13 @@
       Benevolent Dictator For Life, a.k.a. `Guido van Rossum
       <http://www.python.org/~guido/>`_, Python's creator.
     
-   byte code
-      The internal representation of a Python program in the interpreter. The
-      byte code is also cached in ``.pyc`` and ``.pyo`` files so that executing
-      the same file is faster the second time (recompilation from source to byte
-      code can be avoided).  This "intermediate language" is said to run on a
-      "virtual machine" that calls the subroutines corresponding to each
-      bytecode.
+   bytecode
+      Python source code is compiled into bytecode, the internal representation
+      of a Python program in the interpreter.  The bytecode is also cached in
+      ``.pyc`` and ``.pyo`` files so that executing the same file is faster the
+      second time (recompilation from source to bytecode can be avoided).  This
+      "intermediate language" is said to run on a "virtual machine" that calls
+      the subroutines corresponding to each bytecode.
     
    classic class
       Any class which does not inherit from :class:`object`.  See
@@ -59,14 +59,16 @@
     
    descriptor
       Any *new-style* object that defines the methods :meth:`__get__`,
-      :meth:`__set__`, or :meth:`__delete__`. When a class attribute is a
+      :meth:`__set__`, or :meth:`__delete__`.  When a class attribute is a
       descriptor, its special binding behavior is triggered upon attribute
-      lookup.  Normally, writing *a.b* looks up the object *b* in the class
-      dictionary for *a*, but if *b* is a descriptor, the defined method gets
-      called. Understanding descriptors is a key to a deep understanding of
-      Python because they are the basis for many features including functions,
-      methods, properties, class methods, static methods, and reference to super
-      classes.
+      lookup.  Normally, using *a.b* to get, set or delete an attribute looks up
+      the object named *b* in the class dictionary for *a*, but if *b* is a
+      descriptor, the respective descriptor method gets called.  Understanding
+      descriptors is a key to a deep understanding of Python because they are
+      the basis for many features including functions, methods, properties,
+      class methods, static methods, and reference to super classes.
+
+      For more information about descriptors' methods, see :ref:`descriptors`.
     
    dictionary
       An associative array, where arbitrary keys are mapped to values.  The use
@@ -223,6 +225,8 @@
       with an iterator will just return the same exhausted iterator object used
       in the previous iteration pass, making it appear like an empty container.
     
+      More information can be found in :ref:`typeiter`.
+
    LBYL
       Look before you leap.  This coding style explicitly tests for
       pre-conditions before making calls or lookups.  This style contrasts with
@@ -251,6 +255,8 @@
       powerful, elegant solutions.  They have been used for logging attribute
       access, adding thread-safety, tracking object creation, implementing
       singletons, and many other tasks.
+
+      More information can be found in :ref:`metaclasses`.
     
    mutable
       Mutable objects can change their value but keep their :func:`id`.  See
@@ -282,6 +288,8 @@
       use Python's newer, versatile features like :attr:`__slots__`,
       descriptors, properties, :meth:`__getattribute__`, class methods, and
       static methods.
+
+      More information can be found in :ref:`newstyle`.
     
    Python 3000
       Nickname for the next major Python version, 3.0 (coined long ago when the

Modified: python/branches/ctypes-branch/Doc/howto/functional.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/howto/functional.rst	(original)
+++ python/branches/ctypes-branch/Doc/howto/functional.rst	Tue Oct 23 20:47:50 2007
@@ -13,8 +13,8 @@
 In this document, we'll take a tour of Python's features suitable for
 implementing programs in a functional style.  After an introduction to the
 concepts of functional programming, we'll look at language features such as
-iterators and generators and relevant library modules such as :mod:`itertools`
-and :mod:`functools`.
+:term:`iterator`\s and :term:`generator`\s and relevant library modules such as
+:mod:`itertools` and :mod:`functools`.
 
 
 Introduction
@@ -448,8 +448,8 @@
             yield i
 
 Any function containing a ``yield`` keyword is a generator function; this is
-detected by Python's bytecode compiler which compiles the function specially as
-a result.
+detected by Python's :term:`bytecode` compiler which compiles the function
+specially as a result.
 
 When you call a generator function, it doesn't return a single value; instead it
 returns a generator object that supports the iterator protocol.  On executing

Modified: python/branches/ctypes-branch/Doc/howto/index.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/howto/index.rst	(original)
+++ python/branches/ctypes-branch/Doc/howto/index.rst	Tue Oct 23 20:47:50 2007
@@ -14,7 +14,6 @@
    :maxdepth: 1
 
    advocacy.rst
-   pythonmac.rst
    curses.rst
    doanddont.rst
    functional.rst

Deleted: /python/branches/ctypes-branch/Doc/howto/pythonmac.rst
==============================================================================
--- /python/branches/ctypes-branch/Doc/howto/pythonmac.rst	Tue Oct 23 20:47:50 2007
+++ (empty file)
@@ -1,202 +0,0 @@
-
-.. _using-on-mac:
-
-***************************
-Using Python on a Macintosh
-***************************
-
-:Author: Bob Savage <bobsavage at mac.com>
-
-
-Python on a Macintosh running Mac OS X is in principle very similar to Python on
-any other Unix platform, but there are a number of additional features such as
-the IDE and the Package Manager that are worth pointing out.
-
-The Mac-specific modules are documented in :ref:`mac-specific-services`.
-
-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 is no longer
-supported, starting with Python 2.4. See http://www.cwi.nl/~jack/macpython for
-installers for the latest 2.3 release for Mac OS 9 and related documentation.
-
-
-.. _getting-osx:
-
-Getting and Installing MacPython
-================================
-
-Mac OS X 10.4 comes with Python 2.3 pre-installed by Apple. However, you are
-encouraged to install the most recent version of Python from the Python website
-(http://www.python.org). A "universal binary" build of Python 2.5, which runs
-natively on the Mac's new Intel and legacy PPC CPU's, is available there.
-
-What you get after installing is a number of things:
-
-* A :file:`MacPython 2.5` folder in your :file:`Applications` folder. In here
-  you find IDLE, the development environment that is a standard part of official
-  Python distributions; PythonLauncher, which handles double-clicking Python
-  scripts from the Finder; and the "Build Applet" tool, which allows you to
-  package Python scripts as standalone applications on your system.
-
-* A framework :file:`/Library/Frameworks/Python.framework`, which includes the
-  Python executable and libraries. The installer adds this location to your shell
-  path. To uninstall MacPython, you can simply remove these three things. A
-  symlink to the Python executable is placed in /usr/local/bin/.
-
-The Apple-provided build of Python is installed in
-:file:`/System/Library/Frameworks/Python.framework` and :file:`/usr/bin/python`,
-respectively. You should never modify or delete these, as they are
-Apple-controlled and are used by Apple- or third-party software.
-
-IDLE includes a help menu that allows you to access Python documentation. If you
-are completely new to Python you should start reading the tutorial introduction
-in that document.
-
-If you are familiar with Python on other Unix platforms you should read the
-section on running Python scripts from the Unix shell.
-
-
-How to run a Python script
---------------------------
-
-Your best way to get started with Python on Mac OS X is through the IDLE
-integrated development environment, see section :ref:`ide` and use the Help menu
-when the IDE is running.
-
-If you want to run Python scripts from the Terminal window command line or from
-the Finder you first need an editor to create your script. Mac OS X comes with a
-number of standard Unix command line editors, :program:`vim` and
-:program:`emacs` among them. If you want a more Mac-like editor,
-:program:`BBEdit` or :program:`TextWrangler` from Bare Bones Software (see
-http://www.barebones.com/products/bbedit/index.shtml) are good choices, as is
-:program:`TextMate` (see http://macromates.com/). Other editors include
-:program:`Gvim` (http://macvim.org) and :program:`Aquamacs`
-(http://aquamacs.org).
-
-To run your script from the Terminal window you must make sure that
-:file:`/usr/local/bin` is in your shell search path.
-
-To run your script from the Finder you have two options:
-
-* Drag it to :program:`PythonLauncher`
-
-* Select :program:`PythonLauncher` as the default application to open your
-  script (or any .py script) through the finder Info window and double-click it.
-  :program:`PythonLauncher` has various preferences to control how your script is
-  launched. Option-dragging allows you to change these for one invocation, or use
-  its Preferences menu to change things globally.
-
-
-.. _osx-gui-scripts:
-
-Running scripts with a GUI
---------------------------
-
-With older versions of Python, there is one Mac OS X quirk that you need to be
-aware of: programs that talk to the Aqua window manager (in other words,
-anything that has a GUI) need to be run in a special way. Use :program:`pythonw`
-instead of :program:`python` to start such scripts.
-
-With Python 2.5, you can use either :program:`python` or :program:`pythonw`.
-
-
-Configuration
--------------
-
-Python on OS X honors all standard Unix environment variables such as
-:envvar:`PYTHONPATH`, but setting these variables for programs started from the
-Finder is non-standard as the Finder does not read your :file:`.profile` or
-:file:`.cshrc` at startup. You need to create a file :file:`~
-/.MacOSX/environment.plist`. See Apple's Technical Document QA1067 for details.
-
-For more information on installation Python packages in MacPython, see section
-:ref:`mac-package-manager`.
-
-
-.. _ide:
-
-The IDE
-=======
-
-MacPython ships with the standard IDLE development environment. A good
-introduction to using IDLE can be found at http://hkn.eecs.berkeley.edu/
-dyoo/python/idle_intro/index.html.
-
-
-.. _mac-package-manager:
-
-Installing Additional Python Packages
-=====================================
-
-There are several methods to install additional Python packages:
-
-* http://pythonmac.org/packages/ contains selected compiled packages for Python
-  2.5, 2.4, and 2.3.
-
-* Packages can be installed via the standard Python distutils mode (``python
-  setup.py install``).
-
-* Many packages can also be installed via the :program:`setuptools` extension.
-
-
-GUI Programming on the Mac
-==========================
-
-There are several options for building GUI applications on the Mac with Python.
-
-*PyObjC* is a Python binding to Apple's Objective-C/Cocoa framework, which is
-the foundation of most modern Mac development. Information on PyObjC is
-available from http://pyobjc.sourceforge.net.
-
-The standard Python GUI toolkit is :mod:`Tkinter`, based on the cross-platform
-Tk toolkit (http://www.tcl.tk). An Aqua-native version of Tk is bundled with OS
-X by Apple, and the latest version can be downloaded and installed from
-http://www.activestate.com; it can also be built from source.
-
-*wxPython* is another popular cross-platform GUI toolkit that runs natively on
-Mac OS X. Packages and documentation are available from http://www.wxpython.org.
-
-*PyQt* is another popular cross-platform GUI toolkit that runs natively on Mac
-OS X. More information can be found at
-http://www.riverbankcomputing.co.uk/pyqt/.
-
-
-Distributing Python Applications on the Mac
-===========================================
-
-The "Build Applet" tool that is placed in the MacPython 2.5 folder is fine for
-packaging small Python scripts on your own machine to run as a standard Mac
-application. This tool, however, is not robust enough to distribute Python
-applications to other users.
-
-The standard tool for deploying standalone Python applications on the Mac is
-:program:`py2app`. More information on installing and using py2app can be found
-at http://undefined.org/python/#py2app.
-
-
-Application Scripting
-=====================
-
-Python can also be used to script other Mac applications via Apple's Open
-Scripting Architecture (OSA); see http://appscript.sourceforge.net. Appscript is
-a high-level, user-friendly Apple event bridge that allows you to control
-scriptable Mac OS X applications using ordinary Python scripts. Appscript makes
-Python a serious alternative to Apple's own *AppleScript* language for
-automating your Mac. A related package, *PyOSA*, is an OSA language component
-for the Python scripting language, allowing Python code to be executed by any
-OSA-enabled application (Script Editor, Mail, iTunes, etc.). PyOSA makes Python
-a full peer to AppleScript.
-
-
-Other Resources
-===============
-
-The MacPython mailing list is an excellent support resource for Python users and
-developers on the Mac:
-
-http://www.python.org/community/sigs/current/pythonmac-sig/
-
-Another useful resource is the MacPython wiki:
-
-http://wiki.python.org/moin/MacPython
-

Modified: python/branches/ctypes-branch/Doc/howto/regex.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/howto/regex.rst	(original)
+++ python/branches/ctypes-branch/Doc/howto/regex.rst	Tue Oct 23 20:47:50 2007
@@ -354,7 +354,7 @@
 |                  | returns them as a list.                       |
 +------------------+-----------------------------------------------+
 | ``finditer()``   | Find all substrings where the RE matches, and |
-|                  | returns them as an iterator.                  |
+|                  | returns them as an :term:`iterator`.          |
 +------------------+-----------------------------------------------+
 
 :meth:`match` and :meth:`search` return ``None`` if no match can be found.  If
@@ -460,7 +460,7 @@
 
 :meth:`findall` has to create the entire list before it can be returned as the
 result.  The :meth:`finditer` method returns a sequence of :class:`MatchObject`
-instances as an iterator. [#]_ ::
+instances as an :term:`iterator`. [#]_ ::
 
    >>> iterator = p.finditer('12 drummers drumming, 11 ... 10 ...')
    >>> iterator

Modified: python/branches/ctypes-branch/Doc/includes/email-unpack.py
==============================================================================
--- python/branches/ctypes-branch/Doc/includes/email-unpack.py	(original)
+++ python/branches/ctypes-branch/Doc/includes/email-unpack.py	Tue Oct 23 20:47:50 2007
@@ -53,7 +53,7 @@
         # email message can't be used to overwrite important files
         filename = part.get_filename()
         if not filename:
-            ext = mimetypes.guess_extension(part.get_type())
+            ext = mimetypes.guess_extension(part.get_content_type())
             if not ext:
                 # Use a generic bag-of-bits extension
                 ext = '.bin'

Modified: python/branches/ctypes-branch/Doc/library/_ast.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/_ast.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/_ast.rst	Tue Oct 23 20:47:50 2007
@@ -14,7 +14,7 @@
 The ``_ast`` module helps Python applications to process trees of the Python
 abstract syntax grammar. The Python compiler currently provides read-only access
 to such trees, meaning that applications can only create a tree for a given
-piece of Python source code; generating byte code from a (potentially modified)
+piece of Python source code; generating :term:`bytecode` from a (potentially modified)
 tree is not supported. The abstract syntax itself might change with each Python
 release; this module helps to find out programmatically what the current grammar
 looks like.

Modified: python/branches/ctypes-branch/Doc/library/autogil.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/autogil.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/autogil.rst	Tue Oct 23 20:47:50 2007
@@ -9,8 +9,8 @@
 
 
 The :mod:`autoGIL` module provides a function :func:`installAutoGIL` that
-automatically locks and unlocks Python's Global Interpreter Lock when running an
-event loop.
+automatically locks and unlocks Python's :term:`Global Interpreter Lock` when
+running an event loop.
 
 
 .. exception:: AutoGILError

Modified: python/branches/ctypes-branch/Doc/library/codecs.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/codecs.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/codecs.rst	Tue Oct 23 20:47:50 2007
@@ -242,8 +242,8 @@
 .. function:: iterencode(iterable, encoding[, errors])
 
    Uses an incremental encoder to iteratively encode the input provided by
-   *iterable*. This function is a generator. *errors* (as well as any other keyword
-   argument) is passed through to the incremental encoder.
+   *iterable*. This function is a :term:`generator`.  *errors* (as well as any
+   other keyword argument) is passed through to the incremental encoder.
 
    .. versionadded:: 2.5
 
@@ -251,8 +251,8 @@
 .. function:: iterdecode(iterable, encoding[, errors])
 
    Uses an incremental decoder to iteratively decode the input provided by
-   *iterable*. This function is a generator. *errors* (as well as any other keyword
-   argument) is passed through to the incremental decoder.
+   *iterable*. This function is a :term:`generator`.  *errors* (as well as any
+   other keyword argument) is passed through to the incremental decoder.
 
    .. versionadded:: 2.5
 

Modified: python/branches/ctypes-branch/Doc/library/collections.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/collections.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/collections.rst	Tue Oct 23 20:47:50 2007
@@ -51,7 +51,7 @@
 
    .. versionadded:: 2.4
 
-   If *maxlen* is not specified or is *-1*, deques may grow to an
+   If *maxlen* is not specified or is *None*, deques may grow to an
    arbitrary length.  Otherwise, the deque is bounded to the specified maximum
    length.  Once a bounded length deque is full, when new items are added, a
    corresponding number of items are discarded from the opposite end.  Bounded
@@ -365,9 +365,13 @@
 
    The *fieldnames* are a single string with each fieldname separated by whitespace
    and/or commas (for example 'x y' or 'x, y').  Alternatively, the *fieldnames*
-   can be specified as a list of strings (such as ['x', 'y']).  Any valid
-   Python identifier may be used for a fieldname except for names starting and 
-   ending with double underscores.
+   can be specified as a list of strings (such as ['x', 'y']).
+
+   Any valid Python identifier may be used for a fieldname except for names
+   starting and ending with double underscores.  Valid identifiers consist of
+   letters, digits, and underscores but do not start with a digit and cannot be
+   a :mod:`keyword` such as *class*, *for*, *return*, *global*, *pass*, *print*,
+   or *raise*.
 
    If *verbose* is true, will print the class definition.
 

Modified: python/branches/ctypes-branch/Doc/library/compiler.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/compiler.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/compiler.rst	Tue Oct 23 20:47:50 2007
@@ -10,8 +10,8 @@
 
 The Python compiler package is a tool for analyzing Python source code and
 generating Python bytecode.  The compiler contains libraries to generate an
-abstract syntax tree from Python source code and to generate Python bytecode
-from the tree.
+abstract syntax tree from Python source code and to generate Python
+:term:`bytecode` from the tree.
 
 The :mod:`compiler` package is a Python source to bytecode translator written in
 Python.  It uses the built-in parser and standard :mod:`parser` module to
@@ -640,5 +640,5 @@
 call the :meth:`emit` method to emit a new bytecode.  The basic code generator
 is specialized for modules, classes, and functions.  An assembler converts that
 emitted instructions to the low-level bytecode format.  It handles things like
-generator of constant lists of code objects and calculation of jump offsets.
+generation of constant lists of code objects and calculation of jump offsets.
 

Modified: python/branches/ctypes-branch/Doc/library/contextlib.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/contextlib.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/contextlib.rst	Tue Oct 23 20:47:50 2007
@@ -39,9 +39,9 @@
       foo
       </h1>
 
-   The function being decorated must return a generator-iterator when called. This
-   iterator must yield exactly one value, which will be bound to the targets in the
-   :keyword:`with` statement's :keyword:`as` clause, if any.
+   The function being decorated must return a :term:`generator`-iterator when
+   called. This iterator must yield exactly one value, which will be bound to
+   the targets in the :keyword:`with` statement's :keyword:`as` clause, if any.
 
    At the point where the generator yields, the block nested in the :keyword:`with`
    statement is executed.  The generator is then resumed after the block is exited.

Modified: python/branches/ctypes-branch/Doc/library/cookielib.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/cookielib.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/cookielib.rst	Tue Oct 23 20:47:50 2007
@@ -144,7 +144,7 @@
 CookieJar and FileCookieJar Objects
 -----------------------------------
 
-:class:`CookieJar` objects support the iterator protocol for iterating over
+:class:`CookieJar` objects support the :term:`iterator` protocol for iterating over
 contained :class:`Cookie` objects.
 
 :class:`CookieJar` has the following methods:

Modified: python/branches/ctypes-branch/Doc/library/csv.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/csv.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/csv.rst	Tue Oct 23 20:47:50 2007
@@ -62,7 +62,7 @@
 .. function:: reader(csvfile[, dialect='excel'][, fmtparam])
 
    Return a reader object which will iterate over lines in the given *csvfile*.
-   *csvfile* can be any object which supports the iterator protocol and returns a
+   *csvfile* can be any object which supports the :term:`iterator` protocol and returns a
    string each time its :meth:`next` method is called --- file objects and list
    objects are both suitable.   If *csvfile* is a file object, it must be opened
    with the 'b' flag on platforms where that makes a difference.  An optional
@@ -143,7 +143,7 @@
 The :mod:`csv` module defines the following classes:
 
 
-.. class:: DictReader(csvfile[, fieldnames=:const:None,[, restkey=:const:None[, restval=None[, dialect='excel'[, *args, **kwds]]]]])
+.. class:: DictReader(csvfile[, fieldnames=None[, restkey=None[, restval=None[, dialect='excel'[, *args, **kwds]]]]])
 
    Create an object which operates like a regular reader but maps the information
    read into a dict whose keys are given by the optional  *fieldnames* parameter.
@@ -442,9 +442,9 @@
 write functions or classes that handle the encoding and decoding for you as long
 as you avoid encodings like UTF-16 that use NULs.  UTF-8 is recommended.
 
-:func:`unicode_csv_reader` below is a generator that wraps :class:`csv.reader`
+:func:`unicode_csv_reader` below is a :term:`generator` that wraps :class:`csv.reader`
 to handle Unicode CSV data (a list of Unicode strings).  :func:`utf_8_encoder`
-is a generator that encodes the Unicode strings as UTF-8, one string (or row) at
+is a :term:`generator` that encodes the Unicode strings as UTF-8, one string (or row) at
 a time.  The encoded strings are parsed by the CSV reader, and
 :func:`unicode_csv_reader` decodes the UTF-8-encoded cells back into Unicode::
 

Modified: python/branches/ctypes-branch/Doc/library/ctypes.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/ctypes.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/ctypes.rst	Tue Oct 23 20:47:50 2007
@@ -586,8 +586,8 @@
    >>> r = RECT(POINT(1, 2), POINT(3, 4))
    >>> r = RECT((1, 2), (3, 4))
 
-Fields descriptors can be retrieved from the *class*, they are useful for
-debugging because they can provide useful information::
+Field :term:`descriptor`\s can be retrieved from the *class*, they are useful
+for debugging because they can provide useful information::
 
    >>> print POINT.x
    <Field type=c_long, ofs=0, size=4>
@@ -1197,10 +1197,10 @@
    >>>
 
 Why is it printing ``False``?  ctypes instances are objects containing a memory
-block plus some descriptors accessing the contents of the memory.  Storing a
-Python object in the memory block does not store the object itself, instead the
-``contents`` of the object is stored. Accessing the contents again constructs a
-new Python each time!
+block plus some :term:`descriptor`\s accessing the contents of the memory.
+Storing a Python object in the memory block does not store the object itself,
+instead the ``contents`` of the object is stored.  Accessing the contents again
+constructs a new Python object each time!
 
 
 .. _ctypes-variable-sized-data-types:
@@ -1368,8 +1368,8 @@
    :class:`WinDLL` and :class:`OleDLL` use the standard calling convention on this
    platform.
 
-The Python GIL is released before calling any function exported by these
-libraries, and reacquired afterwards.
+The Python :term:`global interpreter lock` is released before calling any
+function exported by these libraries, and reacquired afterwards.
 
 
 .. class:: PyDLL(name, mode=DEFAULT_MODE, handle=None)
@@ -1950,7 +1950,7 @@
    in case the memory block contains pointers.
 
 Common methods of ctypes data types, these are all class methods (to be exact,
-they are methods of the metaclass):
+they are methods of the :term:`metaclass`):
 
 
 .. method:: _CData.from_address(address)
@@ -2267,7 +2267,7 @@
 
 Concrete structure and union types must be created by subclassing one of these
 types, and at least define a :attr:`_fields_` class variable. ``ctypes`` will
-create descriptors which allow reading and writing the fields by direct
+create :term:`descriptor`\s which allow reading and writing the fields by direct
 attribute accesses.  These are the
 
 

Modified: python/branches/ctypes-branch/Doc/library/difflib.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/difflib.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/difflib.rst	Tue Oct 23 20:47:50 2007
@@ -12,6 +12,10 @@
 
 .. versionadded:: 2.1
 
+This module provides classes and functions for comparing sequences. It
+can be used for example, for comparing files, and can produce difference
+information in various formats, including HTML and context and unified
+diffs. For comparing directories and files, see also, the :mod:`filecmp` module.
 
 .. class:: SequenceMatcher
 
@@ -122,8 +126,8 @@
 
 .. function:: context_diff(a, b[, fromfile][, tofile][, fromfiledate][, tofiledate][, n][, lineterm])
 
-   Compare *a* and *b* (lists of strings); return a delta (a generator generating
-   the delta lines) in context diff format.
+   Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
+   generating the delta lines) in context diff format.
 
    Context diffs are a compact way of showing just the lines that have changed plus
    a few lines of context.  The changes are shown in a before/after style.  The
@@ -177,8 +181,8 @@
 
 .. function:: ndiff(a, b[, linejunk][, charjunk])
 
-   Compare *a* and *b* (lists of strings); return a :class:`Differ`\ -style delta
-   (a generator generating the delta lines).
+   Compare *a* and *b* (lists of strings); return a :class:`Differ`\ -style
+   delta (a :term:`generator` generating the delta lines).
 
    Optional keyword parameters *linejunk* and *charjunk* are for filter functions
    (or ``None``):
@@ -238,8 +242,8 @@
 
 .. function:: unified_diff(a, b[, fromfile][, tofile][, fromfiledate][, tofiledate][, n][, lineterm])
 
-   Compare *a* and *b* (lists of strings); return a delta (a generator generating
-   the delta lines) in unified diff format.
+   Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
+   generating the delta lines) in unified diff format.
 
    Unified diffs are a compact way of showing just the lines that have changed plus
    a few lines of context.  The changes are shown in a inline style (instead of
@@ -438,7 +442,7 @@
 
 .. method:: SequenceMatcher.get_grouped_opcodes([n])
 
-   Return a generator of groups with up to *n* lines of context.
+   Return a :term:`generator` of groups with up to *n* lines of context.
 
    Starting with the groups returned by :meth:`get_opcodes`, this method splits out
    smaller change clusters and eliminates intervening ranges which have no changes.

Modified: python/branches/ctypes-branch/Doc/library/dis.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/dis.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/dis.rst	Tue Oct 23 20:47:50 2007
@@ -1,14 +1,14 @@
 
-:mod:`dis` --- Disassembler for Python byte code
-================================================
+:mod:`dis` --- Disassembler for Python bytecode
+===============================================
 
 .. module:: dis
-   :synopsis: Disassembler for Python byte code.
+   :synopsis: Disassembler for Python bytecode.
 
 
-The :mod:`dis` module supports the analysis of Python byte code by disassembling
+The :mod:`dis` module supports the analysis of Python :term:`bytecode` by disassembling
 it.  Since there is no Python assembler, this module defines the Python assembly
-language.  The Python byte code which this module takes as an input is defined
+language.  The Python bytecode which this module takes as an input is defined
 in the file  :file:`Include/opcode.h` and used by the compiler and the
 interpreter.
 
@@ -35,7 +35,7 @@
    Disassemble the *bytesource* object. *bytesource* can denote either a module, a
    class, a method, a function, or a code object.   For a module, it disassembles
    all functions.  For a class, it disassembles all methods.  For a single code
-   sequence, it prints one line per byte code instruction.  If no object is
+   sequence, it prints one line per bytecode instruction.  If no object is
    provided, it disassembles the last traceback.
 
 
@@ -70,12 +70,12 @@
 
 .. data:: opname
 
-   Sequence of operation names, indexable using the byte code.
+   Sequence of operation names, indexable using the bytecode.
 
 
 .. data:: opmap
 
-   Dictionary mapping byte codes to operation names.
+   Dictionary mapping bytecodes to operation names.
 
 
 .. data:: cmp_op
@@ -85,45 +85,45 @@
 
 .. data:: hasconst
 
-   Sequence of byte codes that have a constant parameter.
+   Sequence of bytecodes that have a constant parameter.
 
 
 .. data:: hasfree
 
-   Sequence of byte codes that access a free variable.
+   Sequence of bytecodes that access a free variable.
 
 
 .. data:: hasname
 
-   Sequence of byte codes that access an attribute by name.
+   Sequence of bytecodes that access an attribute by name.
 
 
 .. data:: hasjrel
 
-   Sequence of byte codes that have a relative jump target.
+   Sequence of bytecodes that have a relative jump target.
 
 
 .. data:: hasjabs
 
-   Sequence of byte codes that have an absolute jump target.
+   Sequence of bytecodes that have an absolute jump target.
 
 
 .. data:: haslocal
 
-   Sequence of byte codes that access a local variable.
+   Sequence of bytecodes that access a local variable.
 
 
 .. data:: hascompare
 
-   Sequence of byte codes of Boolean operations.
+   Sequence of bytecodes of Boolean operations.
 
 
 .. _bytecodes:
 
-Python Byte Code Instructions
------------------------------
+Python Bytecode Instructions
+----------------------------
 
-The Python compiler currently generates the following byte code instructions.
+The Python compiler currently generates the following bytecode instructions.
 
 
 .. opcode:: STOP_CODE ()
@@ -482,7 +482,7 @@
 
 .. opcode:: YIELD_VALUE ()
 
-   Pops ``TOS`` and yields it from a generator.
+   Pops ``TOS`` and yields it from a :term:`generator`.
 
 
 .. opcode:: IMPORT_STAR ()
@@ -523,9 +523,9 @@
    context manager's :meth:`__exit__` bound method.  Below that are 1--3 values
    indicating how/why the finally clause was entered:
 
-   * SECOND = None
-   * (SECOND, THIRD) = (WHY_{RETURN,CONTINUE}), retval
-   * SECOND = WHY_\*; no retval below it
+   * SECOND = ``None``
+   * (SECOND, THIRD) = (``WHY_{RETURN,CONTINUE}``), retval
+   * SECOND = ``WHY_*``; no retval below it
    * (SECOND, THIRD, FOURTH) = exc_info()
 
    In the last case, ``TOS(SECOND, THIRD, FOURTH)`` is called, otherwise
@@ -535,6 +535,8 @@
    returns a 'true' value, this information is "zapped", to prevent ``END_FINALLY``
    from re-raising the exception.  (But non-local gotos should still be resumed.)
 
+   .. XXX explain the WHY stuff!
+
 
 All of the following opcodes expect arguments.  An argument is two bytes, with
 the more significant byte last.
@@ -650,32 +652,32 @@
 
 .. opcode:: JUMP_FORWARD (delta)
 
-   Increments byte code counter by *delta*.
+   Increments bytecode counter by *delta*.
 
 
 .. opcode:: JUMP_IF_TRUE (delta)
 
-   If TOS is true, increment the byte code counter by *delta*.  TOS is left on the
+   If TOS is true, increment the bytecode counter by *delta*.  TOS is left on the
    stack.
 
 
 .. opcode:: JUMP_IF_FALSE (delta)
 
-   If TOS is false, increment the byte code counter by *delta*.  TOS is not
+   If TOS is false, increment the bytecode counter by *delta*.  TOS is not
    changed.
 
 
 .. opcode:: JUMP_ABSOLUTE (target)
 
-   Set byte code counter to *target*.
+   Set bytecode counter to *target*.
 
 
 .. opcode:: FOR_ITER (delta)
 
-   ``TOS`` is an iterator.  Call its :meth:`next` method.  If this yields a new
-   value, push it on the stack (leaving the iterator below it).  If the iterator
-   indicates it is exhausted  ``TOS`` is popped, and the byte code counter is
-   incremented by *delta*.
+   ``TOS`` is an :term:`iterator`.  Call its :meth:`next` method.  If this
+   yields a new value, push it on the stack (leaving the iterator below it).  If
+   the iterator indicates it is exhausted ``TOS`` is popped, and the bytecode
+   counter is incremented by *delta*.
 
 .. % \begin{opcodedesc}{FOR_LOOP}{delta}
 .. % This opcode is obsolete.

Modified: python/branches/ctypes-branch/Doc/library/exceptions.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/exceptions.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/exceptions.rst	Tue Oct 23 20:47:50 2007
@@ -152,9 +152,9 @@
 
 .. exception:: GeneratorExit
 
-   Raise when a generator's :meth:`close` method is called. It directly inherits
-   from :exc:`Exception` instead of :exc:`StandardError` since it is technically
-   not an error.
+   Raise when a :term:`generator`\'s :meth:`close` method is called.  It
+   directly inherits from :exc:`Exception` instead of :exc:`StandardError` since
+   it is technically not an error.
 
    .. versionadded:: 2.5
 
@@ -285,9 +285,10 @@
 
 .. exception:: StopIteration
 
-   Raised by an iterator's :meth:`next` method to signal that there are no further
-   values. This is derived from :exc:`Exception` rather than :exc:`StandardError`,
-   since this is not considered an error in its normal application.
+   Raised by an :term:`iterator`\'s :meth:`next` method to signal that there are
+   no further values.  This is derived from :exc:`Exception` rather than
+   :exc:`StandardError`, since this is not considered an error in its normal
+   application.
 
    .. versionadded:: 2.2
 

Modified: python/branches/ctypes-branch/Doc/library/filecmp.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/filecmp.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/filecmp.rst	Tue Oct 23 20:47:50 2007
@@ -8,7 +8,8 @@
 
 
 The :mod:`filecmp` module defines functions to compare files and directories,
-with various optional time/correctness trade-offs.
+with various optional time/correctness trade-offs. For comparing files,
+see also the :mod:`difflib` module.
 
 The :mod:`filecmp` module defines the following functions:
 

Modified: python/branches/ctypes-branch/Doc/library/functions.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/functions.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/functions.rst	Tue Oct 23 20:47:50 2007
@@ -43,7 +43,7 @@
    top-level package (the name up till the first dot) is returned, *not* the
    module named by *name*.  However, when a non-empty *fromlist* argument is
    given, the module named by *name* is returned.  This is done for
-   compatibility with the bytecode generated for the different kinds of import
+   compatibility with the :term:`bytecode` generated for the different kinds of import
    statement; when using ``import spam.ham.eggs``, the top-level package
    :mod:`spam` must be placed in the importing namespace, but when using ``from
    spam.ham import eggs``, the ``spam.ham`` subpackage must be used to find the
@@ -322,7 +322,7 @@
 
 .. function:: enumerate(iterable)
 
-   Return an enumerate object. *iterable* must be a sequence, an iterator, or some
+   Return an enumerate object. *iterable* must be a sequence, an :term:`iterator`, or some
    other object which supports iteration.  The :meth:`next` method of the iterator
    returned by :func:`enumerate` returns a tuple containing a count (from zero) and
    the corresponding value obtained from iterating over *iterable*.
@@ -350,7 +350,7 @@
 
    The *expression* argument is parsed and evaluated as a Python expression
    (technically speaking, a condition list) using the *globals* and *locals*
-   dictionaries as global and local name space.  If the *globals* dictionary is
+   dictionaries as global and local namespace.  If the *globals* dictionary is
    present and lacks '__builtins__', the current globals are copied into *globals*
    before *expression* is parsed.  This means that *expression* normally has full
    access to the standard :mod:`__builtin__` module and restricted environments are
@@ -420,7 +420,7 @@
 
    Construct a list from those elements of *iterable* for which *function* returns
    true.  *iterable* may be either a sequence, a container which supports
-   iteration, or an iterator,  If *iterable* is a string or a tuple, the result
+   iteration, or an iterator.  If *iterable* is a string or a tuple, the result
    also has that type; otherwise it is always a list.  If *function* is ``None``,
    the identity function is assumed, that is, all elements of *iterable* that are
    false are removed.
@@ -590,7 +590,7 @@
 
 .. function:: iter(o[, sentinel])
 
-   Return an iterator object.  The first argument is interpreted very differently
+   Return an :term:`iterator` object.  The first argument is interpreted very differently
    depending on the presence of the second argument. Without a second argument, *o*
    must be a collection object which supports the iteration protocol (the
    :meth:`__iter__` method), or it must support the sequence protocol (the
@@ -808,8 +808,8 @@
 
 .. function:: property([fget[, fset[, fdel[, doc]]]])
 
-   Return a property attribute for new-style classes (classes that derive from
-   :class:`object`).
+   Return a property attribute for :term:`new-style class`\es (classes that
+   derive from :class:`object`).
 
    *fget* is a function for getting an attribute value, likewise *fset* is a
    function for setting, and *fdel* a function for del'ing, an attribute.  Typical
@@ -973,9 +973,9 @@
 
 .. function:: reversed(seq)
 
-   Return a reverse iterator.  *seq* must be an object which supports the sequence
-   protocol (the :meth:`__len__` method and the :meth:`__getitem__` method with
-   integer arguments starting at ``0``).
+   Return a reverse :term:`iterator`.  *seq* must be an object which supports
+   the sequence protocol (the :meth:`__len__` method and the :meth:`__getitem__`
+   method with integer arguments starting at ``0``).
 
    .. versionadded:: 2.4
 
@@ -1112,8 +1112,8 @@
    Return the superclass of *type*.  If the second argument is omitted the super
    object returned is unbound.  If the second argument is an object,
    ``isinstance(obj, type)`` must be true.  If the second argument is a type,
-   ``issubclass(type2, type)`` must be true. :func:`super` only works for new-style
-   classes.
+   ``issubclass(type2, type)`` must be true. :func:`super` only works for
+   :term:`new-style class`\es.
 
    A typical use for calling a cooperative superclass method is::
 
@@ -1292,12 +1292,11 @@
    present, it must be a dictionary whose keys are strings.  It specifies keyword
    arguments to be added to the end of the argument list. Calling :func:`apply` is
    different from just calling ``function(args)``, since in that case there is
-   always exactly one argument.  The use of :func:`apply` is equivalent to
-   ``function(*args, **keywords)``. Use of :func:`apply` is not necessary since the
-   "extended call syntax," as used in the last example, is completely equivalent.
+   always exactly one argument.  The use of :func:`apply` is exactly equivalent to
+   ``function(*args, **keywords)``.
 
    .. deprecated:: 2.3
-      Use the extended call syntax instead, as described above.
+      Use the extended call syntax with ``*args`` and ``**keywords`` instead.
 
 
 .. function:: buffer(object[, offset[, size]])

Modified: python/branches/ctypes-branch/Doc/library/glob.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/glob.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/glob.rst	Tue Oct 23 20:47:50 2007
@@ -28,8 +28,8 @@
 
 .. function:: iglob(pathname)
 
-   Return an iterator which yields the same values as :func:`glob` without actually
-   storing them all simultaneously.
+   Return an :term:`iterator` which yields the same values as :func:`glob`
+   without actually storing them all simultaneously.
 
    .. versionadded:: 2.5
 

Modified: python/branches/ctypes-branch/Doc/library/heapq.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/heapq.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/heapq.rst	Tue Oct 23 20:47:50 2007
@@ -92,8 +92,8 @@
 .. function:: merge(*iterables)
 
    Merge multiple sorted inputs into a single sorted output (for example, merge
-   timestamped entries from multiple log files).  Returns an iterator over over the
-   sorted values.
+   timestamped entries from multiple log files).  Returns an :term:`iterator`
+   over over the sorted values.
 
    Similar to ``sorted(itertools.chain(*iterables))`` but returns an iterable, does
    not pull the data into memory all at once, and assumes that each of the input

Modified: python/branches/ctypes-branch/Doc/library/inspect.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/inspect.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/inspect.rst	Tue Oct 23 20:47:50 2007
@@ -69,7 +69,7 @@
 +-----------+-----------------+---------------------------+-------+
 |           | func_code       | code object containing    |       |
 |           |                 | compiled function         |       |
-|           |                 | bytecode                  |       |
+|           |                 | :term:`bytecode`          |       |
 +-----------+-----------------+---------------------------+-------+
 |           | func_defaults   | tuple of any default      |       |
 |           |                 | values for arguments      |       |
@@ -265,30 +265,31 @@
 
 .. function:: ismethoddescriptor(object)
 
-   Return true if the object is a method descriptor, but not if ismethod() or
-   isclass() or isfunction() are true.
+   Return true if the object is a method descriptor, but not if :func:`ismethod`
+   or :func:`isclass` or :func:`isfunction` are true.
 
-   This is new as of Python 2.2, and, for example, is true of int.__add__. An
-   object passing this test has a __get__ attribute but not a __set__ attribute,
-   but beyond that the set of attributes varies.  __name__ is usually sensible, and
-   __doc__ often is.
-
-   Methods implemented via descriptors that also pass one of the other tests return
-   false from the ismethoddescriptor() test, simply because the other tests promise
-   more -- you can, e.g., count on having the im_func attribute (etc) when an
-   object passes ismethod().
+   This is new as of Python 2.2, and, for example, is true of
+   ``int.__add__``. An object passing this test has a :attr:`__get__` attribute
+   but not a :attr:`__set__` attribute, but beyond that the set of attributes
+   varies.  :attr:`__name__` is usually sensible, and :attr:`__doc__` often is.
+
+   Methods implemented via descriptors that also pass one of the other tests
+   return false from the :func:`ismethoddescriptor` test, simply because the
+   other tests promise more -- you can, e.g., count on having the
+   :attr:`im_func` attribute (etc) when an object passes :func:`ismethod`.
 
 
 .. function:: isdatadescriptor(object)
 
    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), 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.
+   Data descriptors have both a :attr:`__get__` and a :attr:`__set__` attribute.
+   Examples are 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 :attr:`__name__` and :attr:`__doc__` attributes
+   (properties, getsets, and members have both of these attributes), but this is
+   not guaranteed.
 
    .. versionadded:: 2.3
 
@@ -309,8 +310,8 @@
    Return true if the object is a member descriptor.
 
    Member descriptors are attributes defined in extension modules via
-   ``PyMemberDef`` structures.  For Python implementations without such types, this
-   method will always return ``False``.
+   ``PyMemberDef`` structures.  For Python implementations without such types,
+   this method will always return ``False``.
 
    .. versionadded:: 2.5
 

Modified: python/branches/ctypes-branch/Doc/library/itertools.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/itertools.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/itertools.rst	Tue Oct 23 20:47:50 2007
@@ -10,7 +10,7 @@
 
 .. versionadded:: 2.3
 
-This module implements a number of iterator building blocks inspired by
+This module implements a number of :term:`iterator` building blocks inspired by
 constructs from the Haskell and SML programming languages.  Each has been recast
 in a form suitable for Python.
 
@@ -460,8 +460,8 @@
 rather than bringing the whole iterable into memory all at once. Code volume is
 kept small by linking the tools together in a functional style which helps
 eliminate temporary variables.  High speed is retained by preferring
-"vectorized" building blocks over the use of for-loops and generators which
-incur interpreter overhead. ::
+"vectorized" building blocks over the use of for-loops and :term:`generator`\s
+which incur interpreter overhead. ::
 
    def take(n, seq):
        return list(islice(seq, n))

Modified: python/branches/ctypes-branch/Doc/library/logging.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/logging.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/logging.rst	Tue Oct 23 20:47:50 2007
@@ -22,7 +22,7 @@
 
 Logging is performed by calling methods on instances of the :class:`Logger`
 class (hereafter called :dfn:`loggers`). Each instance has a name, and they are
-conceptually arranged in a name space hierarchy using dots (periods) as
+conceptually arranged in a namespace hierarchy using dots (periods) as
 separators. For example, a logger named "scan" is the parent of loggers
 "scan.text", "scan.html" and "scan.pdf". Logger names can be anything you want,
 and indicate the area of an application in which a logged message originates.
@@ -438,7 +438,7 @@
 
       FORMAT = "%(asctime)-15s %(clientip)s %(user)-8s %(message)s"
       logging.basicConfig(format=FORMAT)
-      dict = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' }
+      d = { 'clientip' : '192.168.0.1', 'user' : 'fbloggs' }
       logger = logging.getLogger("tcpserver")
       logger.warning("Protocol problem: %s", "connection reset", extra=d)
 

Modified: python/branches/ctypes-branch/Doc/library/mailbox.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/mailbox.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/mailbox.rst	Tue Oct 23 20:47:50 2007
@@ -806,7 +806,7 @@
 
       A message is typically moved from :file:`new` to :file:`cur` after its mailbox
       has been accessed, whether or not the message is has been read. A message
-      ``msg`` has been read if ``"S" not in msg.get_flags()`` is ``True``.
+      ``msg`` has been read if ``"S" in msg.get_flags()`` is ``True``.
 
 
 .. method:: MaildirMessage.set_subdir(subdir)

Modified: python/branches/ctypes-branch/Doc/library/mmap.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/mmap.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/mmap.rst	Tue Oct 23 20:47:50 2007
@@ -40,7 +40,7 @@
    length.
 
 
-.. function:: mmap(fileno, length[, tagname[, access]])
+.. function:: mmap(fileno, length[, tagname[, access[, offset]]])
 
    **(Windows version)** Maps *length* bytes from the file specified by the file
    handle *fileno*, and returns a mmap object.  If *length* is larger than the
@@ -56,8 +56,12 @@
    the mapping is created without a name.  Avoiding the use of the tag parameter
    will assist in keeping your code portable between Unix and Windows.
 
+   *offset* may be specified as a non-negative integer offset. mmap references will 
+   be relative to the offset from the beginning of the file. *offset* defaults to 0.
+   *offset* must be a multiple of the ALLOCATIONGRANULARITY.
 
-.. function:: mmap(fileno, length[, flags[, prot[, access]]])
+
+.. function:: mmap(fileno, length[, flags[, prot[, access[, offset]]]])
    :noindex:
 
    **(Unix version)** Maps *length* bytes from the file specified by the file
@@ -79,6 +83,10 @@
    parameter.  It is an error to specify both *flags*, *prot* and *access*.  See
    the description of *access* above for information on how to use this parameter.
 
+   *offset* may be specified as a non-negative integer offset. mmap references will 
+   be relative to the offset from the beginning of the file. *offset* defaults to 0.
+   *offset* must be a multiple of the PAGESIZE or ALLOCATIONGRANULARITY.
+
 Memory-mapped file objects support the following methods:
 
 
@@ -171,3 +179,4 @@
    created with :const:`ACCESS_READ`, then writing to it will throw a
    :exc:`TypeError` exception.
 
+

Modified: python/branches/ctypes-branch/Doc/library/os.path.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/os.path.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/os.path.rst	Tue Oct 23 20:47:50 2007
@@ -303,8 +303,8 @@
 
    .. note::
 
-      The newer :func:`os.walk` generator supplies similar functionality and can be
-      easier to use.
+      The newer :func:`os.walk` :term:`generator` supplies similar functionality
+      and can be easier to use.
 
 
 .. data:: supports_unicode_filenames

Modified: python/branches/ctypes-branch/Doc/library/os.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/os.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/os.rst	Tue Oct 23 20:47:50 2007
@@ -651,7 +651,7 @@
 .. function:: ttyname(fd)
 
    Return a string which specifies the terminal device associated with
-   file-descriptor *fd*.  If *fd* is not associated with a terminal device, an
+   file descriptor *fd*.  If *fd* is not associated with a terminal device, an
    exception is raised. Availability:Macintosh, Unix.
 
 

Modified: python/branches/ctypes-branch/Doc/library/parser.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/parser.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/parser.rst	Tue Oct 23 20:47:50 2007
@@ -319,7 +319,7 @@
 .. index:: builtin: compile
 
 The parser modules allows operations to be performed on the parse tree of Python
-source code before the bytecode is generated, and provides for inspection of the
+source code before the :term:`bytecode` is generated, and provides for inspection of the
 parse tree for information gathering purposes. Two examples are presented.  The
 simple example demonstrates emulation of the :func:`compile` built-in function
 and the complex example shows the use of a parse tree for information discovery.

Modified: python/branches/ctypes-branch/Doc/library/pickle.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/pickle.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/pickle.rst	Tue Oct 23 20:47:50 2007
@@ -122,7 +122,7 @@
   earlier versions of Python.
 
 * Protocol version 2 was introduced in Python 2.3.  It provides much more
-  efficient pickling of new-style classes.
+  efficient pickling of :term:`new-style class`\es.
 
 Refer to :pep:`307` for more information.
 
@@ -430,8 +430,8 @@
 protocol 2.  Implementing this method is needed if the type establishes some
 internal invariants when the instance is created, or if the memory allocation is
 affected by the values passed to the :meth:`__new__` method for the type (as it
-is for tuples and strings).  Instances of a new-style type :class:`C` are
-created using ::
+is for tuples and strings).  Instances of a :term:`new-style class` :class:`C`
+are created using ::
 
    obj = C.__new__(C, *args)
 
@@ -459,8 +459,8 @@
 
 .. warning::
 
-   For new-style classes, if :meth:`__getstate__` returns a false value, the
-   :meth:`__setstate__` method will not be called.
+   For :term:`new-style class`\es, if :meth:`__getstate__` returns a false
+   value, the :meth:`__setstate__` method will not be called.
 
 
 Pickling and unpickling extension types

Modified: python/branches/ctypes-branch/Doc/library/pickletools.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/pickletools.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/pickletools.rst	Tue Oct 23 20:47:50 2007
@@ -29,9 +29,9 @@
 
 .. function:: genops(pickle)
 
-   Provides an iterator over all of the opcodes in a pickle, returning a sequence
-   of ``(opcode, arg, pos)`` triples. *opcode* is an instance of an
-   :class:`OpcodeInfo` class; *arg*  is the decoded value, as a Python object, of
-   the opcode's argument;  *pos* is the position at which this opcode is located.
+   Provides an :term:`iterator` over all of the opcodes in a pickle, returning a
+   sequence of ``(opcode, arg, pos)`` triples.  *opcode* is an instance of an
+   :class:`OpcodeInfo` class; *arg* is the decoded value, as a Python object, of
+   the opcode's argument; *pos* is the position at which this opcode is located.
    *pickle* can be a string or a file-like object.
 

Modified: python/branches/ctypes-branch/Doc/library/pty.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/pty.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/pty.rst	Tue Oct 23 20:47:50 2007
@@ -43,6 +43,6 @@
    reading from the controlling terminal.
 
    The functions *master_read* and *stdin_read* should be functions which read from
-   a file-descriptor. The defaults try to read 1024 bytes each time they are
+   a file descriptor. The defaults try to read 1024 bytes each time they are
    called.
 

Modified: python/branches/ctypes-branch/Doc/library/pyclbr.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/pyclbr.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/pyclbr.rst	Tue Oct 23 20:47:50 2007
@@ -19,10 +19,10 @@
 .. function:: readmodule(module[, path])
 
    Read a module and return a dictionary mapping class names to class descriptor
-   objects.  The parameter *module* should be the name of a module as a string; it
-   may be the name of a module within a package.  The *path* parameter should be a
-   sequence, and is used to augment the value of ``sys.path``, which is used to
-   locate module source code.
+   objects.  The parameter *module* should be the name of a module as a string;
+   it may be the name of a module within a package.  The *path* parameter should
+   be a sequence, and is used to augment the value of ``sys.path``, which is
+   used to locate module source code.
 
    .. % The 'inpackage' parameter appears to be for internal use only....
 

Modified: python/branches/ctypes-branch/Doc/library/re.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/re.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/re.rst	Tue Oct 23 20:47:50 2007
@@ -568,7 +568,7 @@
 
 .. function:: finditer(pattern, string[, flags])
 
-   Return an iterator yielding :class:`MatchObject` instances over all
+   Return an :term:`iterator` yielding :class:`MatchObject` instances over all
    non-overlapping matches for the RE *pattern* in *string*.  Empty matches are
    included in the result unless they touch the beginning of another match.
 

Modified: python/branches/ctypes-branch/Doc/library/sqlite3.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/sqlite3.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/sqlite3.rst	Tue Oct 23 20:47:50 2007
@@ -71,10 +71,10 @@
             ):
        c.execute('insert into stocks values (?,?,?,?,?)', t)
 
-To retrieve data after executing a SELECT statement, you can either  treat the
-cursor as an iterator, call the cursor's :meth:`fetchone` method to retrieve a
-single matching row,  or call :meth:`fetchall` to get a list of the matching
-rows.
+To retrieve data after executing a SELECT statement, you can either treat the
+cursor as an :term:`iterator`, call the cursor's :meth:`fetchone` method to
+retrieve a single matching row, or call :meth:`fetchall` to get a list of the
+matching rows.
 
 This example uses the iterator form::
 
@@ -410,13 +410,13 @@
 
 .. method:: Cursor.executemany(sql, seq_of_parameters)
 
-   Executes a SQL command against all parameter sequences or mappings found in the
-   sequence *sql*. The :mod:`sqlite3` module also allows using an iterator yielding
-   parameters instead of a sequence.
+   Executes a SQL command against all parameter sequences or mappings found in
+   the sequence *sql*.  The :mod:`sqlite3` module also allows using an
+   :term:`iterator` yielding parameters instead of a sequence.
 
    .. literalinclude:: ../includes/sqlite3/executemany_1.py
 
-   Here's a shorter example using a generator:
+   Here's a shorter example using a :term:`generator`:
 
    .. literalinclude:: ../includes/sqlite3/executemany_2.py
 
@@ -549,7 +549,7 @@
 
 .. note::
 
-   The type/class to adapt must be a new-style class, i. e. it must have
+   The type/class to adapt must be a :term:`new-style class`, i. e. it must have
    :class:`object` as one of its bases.
 
 .. literalinclude:: ../includes/sqlite3/adapter_point_2.py

Modified: python/branches/ctypes-branch/Doc/library/ssl.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/ssl.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/ssl.rst	Tue Oct 23 20:47:50 2007
@@ -226,7 +226,7 @@
 
 .. data:: PROTOCOL_TLSv1
 
-   Selects SSL version 2 as the channel encryption protocol.  This is
+   Selects TLS version 1 as the channel encryption protocol.  This is
    the most modern version, and probably the best choice for maximum
    protection, if both sides can speak it.
 

Modified: python/branches/ctypes-branch/Doc/library/stdtypes.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/stdtypes.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/stdtypes.rst	Tue Oct 23 20:47:50 2007
@@ -479,10 +479,10 @@
 constraint was added in Python 2.3; in Python 2.2, various iterators are broken
 according to this rule.)
 
-Python's generators provide a convenient way to implement the iterator protocol.
-If a container object's :meth:`__iter__` method is implemented as a generator,
-it will automatically return an iterator object (technically, a generator
-object) supplying the :meth:`__iter__` and :meth:`next` methods.
+Python's :term:`generator`\s provide a convenient way to implement the iterator
+protocol.  If a container object's :meth:`__iter__` method is implemented as a
+generator, it will automatically return an iterator object (technically, a
+generator object) supplying the :meth:`__iter__` and :meth:`next` methods.
 
 
 .. _typesseq:
@@ -1899,8 +1899,7 @@
 .. method:: file.fileno()
 
    .. index::
-      single: file descriptor
-      single: descriptor, file
+      pair: file; descriptor
       module: fcntl
 
    Return the integer "file descriptor" that is used by the underlying
@@ -2160,7 +2159,7 @@
 
 .. method:: contextmanager.__exit__(exc_type, exc_val, exc_tb)
 
-   Exit the runtime context and return a Boolean flag indicating if any expection
+   Exit the runtime context and return a Boolean flag indicating if any exception
    that occurred should be suppressed. If an exception occurred while executing the
    body of the :keyword:`with` statement, the arguments contain the exception type,
    value and traceback information. Otherwise, all three arguments are ``None``.
@@ -2184,7 +2183,7 @@
 their implementation of the context management protocol. See the
 :mod:`contextlib` module for some examples.
 
-Python's generators and the ``contextlib.contextfactory`` decorator provide a
+Python's :term:`generator`\s and the ``contextlib.contextfactory`` decorator provide a
 convenient way to implement these protocols.  If a generator function is
 decorated with the ``contextlib.contextfactory`` decorator, it will return a
 context manager implementing the necessary :meth:`__enter__` and

Modified: python/branches/ctypes-branch/Doc/library/tokenize.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/tokenize.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/tokenize.rst	Tue Oct 23 20:47:50 2007
@@ -13,7 +13,7 @@
 well, making it useful for implementing "pretty-printers," including colorizers
 for on-screen displays.
 
-The primary entry point is a generator:
+The primary entry point is a :term:`generator`:
 
 
 .. function:: generate_tokens(readline)

Modified: python/branches/ctypes-branch/Doc/library/types.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/types.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/types.rst	Tue Oct 23 20:47:50 2007
@@ -128,8 +128,8 @@
 
 .. data:: GeneratorType
 
-   The type of generator-iterator objects, produced by calling a generator
-   function.
+   The type of :term:`generator`-iterator objects, produced by calling a
+   generator function.
 
    .. versionadded:: 2.2
 

Modified: python/branches/ctypes-branch/Doc/library/urllib.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/urllib.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/urllib.rst	Tue Oct 23 20:47:50 2007
@@ -29,7 +29,7 @@
    :exc:`IOError` exception is raised.  If all went well, a file-like object is
    returned.  This supports the following methods: :meth:`read`, :meth:`readline`,
    :meth:`readlines`, :meth:`fileno`, :meth:`close`, :meth:`info` and
-   :meth:`geturl`.  It also has proper support for the iterator protocol. One
+   :meth:`geturl`.  It also has proper support for the :term:`iterator` protocol. One
    caveat: the :meth:`read` method, if the size argument is omitted or negative,
    may not read until the end of the data stream; there is no good way to determine
    that the entire stream from a socket has been read in the general case.

Modified: python/branches/ctypes-branch/Doc/library/weakref.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/weakref.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/weakref.rst	Tue Oct 23 20:47:50 2007
@@ -50,9 +50,9 @@
 
 Not all objects can be weakly referenced; those objects which can include class
 instances, functions written in Python (but not in C), methods (both bound and
-unbound), sets, frozensets, file objects, generators, type objects, DBcursor
-objects from the :mod:`bsddb` module, sockets, arrays, deques, and regular
-expression pattern objects.
+unbound), sets, frozensets, file objects, :term:`generator`\s, type objects,
+:class:`DBcursor` objects from the :mod:`bsddb` module, sockets, arrays, deques,
+and regular expression pattern objects.
 
 .. versionchanged:: 2.4
    Added support for files, sockets, arrays, and patterns.
@@ -150,7 +150,7 @@
 
 .. method:: WeakKeyDictionary.iterkeyrefs()
 
-   Return an iterator that yields the weak references to the keys.
+   Return an :term:`iterator` that yields the weak references to the keys.
 
    .. versionadded:: 2.5
 
@@ -182,7 +182,7 @@
 
 .. method:: WeakValueDictionary.itervaluerefs()
 
-   Return an iterator that yields the weak references to the values.
+   Return an :term:`iterator` that yields the weak references to the values.
 
    .. versionadded:: 2.5
 

Modified: python/branches/ctypes-branch/Doc/library/wsgiref.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/wsgiref.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/wsgiref.rst	Tue Oct 23 20:47:50 2007
@@ -126,7 +126,7 @@
 
 .. class:: FileWrapper(filelike [, blksize=8192])
 
-   A wrapper to convert a file-like object to an iterator.  The resulting objects
+   A wrapper to convert a file-like object to an :term:`iterator`.  The resulting objects
    support both :meth:`__getitem__` and :meth:`__iter__` iteration styles, for
    compatibility with Python 2.1 and Jython. As the object is iterated over, the
    optional *blksize* parameter will be repeatedly passed to the *filelike*

Modified: python/branches/ctypes-branch/Doc/library/xml.etree.elementtree.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/xml.etree.elementtree.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/xml.etree.elementtree.rst	Tue Oct 23 20:47:50 2007
@@ -89,7 +89,7 @@
    Parses an XML section into an element tree incrementally, and reports what's
    going on to the user. *source* is a filename or file object containing XML data.
    *events* is a list of events to report back.  If omitted, only "end" events are
-   reported. Returns an iterator providing ``(event, elem)`` pairs.
+   reported. Returns an :term:`iterator` providing ``(event, elem)`` pairs.
 
 
 .. function:: parse(source[, parser])
@@ -318,7 +318,7 @@
 .. method:: ElementTree.findall(path)
 
    Finds all toplevel elements with the given tag. Same as getroot().findall(path).
-   *path* is the element to look for. Returns a list or iterator containing all
+   *path* is the element to look for. Returns a list or :term:`iterator` containing all
    matching elements, in document order.
 
 

Modified: python/branches/ctypes-branch/Doc/library/xmlrpclib.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/library/xmlrpclib.rst	(original)
+++ python/branches/ctypes-branch/Doc/library/xmlrpclib.rst	Tue Oct 23 20:47:50 2007
@@ -113,8 +113,9 @@
       The *use_datetime* flag was added.
 
    .. versionchanged:: 2.6
-      Instances of new-style classes can be passed in if they have an *__dict__*
-      attribute and don't have a base class that is marshalled in a special way.
+      Instances of :term:`new-style class`\es can be passed in if they have an
+      *__dict__* attribute and don't have a base class that is marshalled in a
+      special way.
 
 
 .. seealso::
@@ -325,7 +326,8 @@
    return ``None``, and only store the call name and parameters in the
    :class:`MultiCall` object. Calling the object itself causes all stored calls to
    be transmitted as a single ``system.multicall`` request. The result of this call
-   is a generator; iterating over this generator yields the individual results.
+   is a :term:`generator`; iterating over this generator yields the individual
+   results.
 
 A usage example of this class is ::
 

Modified: python/branches/ctypes-branch/Doc/reference/compound_stmts.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/reference/compound_stmts.rst	(original)
+++ python/branches/ctypes-branch/Doc/reference/compound_stmts.rst	Tue Oct 23 20:47:50 2007
@@ -534,8 +534,9 @@
 class and instance variables are accessible through the notation
 "``self.name``", and an instance variable hides a class variable with the same
 name when accessed in this way.  Class variables with immutable values can be
-used as defaults for instance variables. For new-style classes, descriptors can
-be used to create instance variables with different implementation details.
+used as defaults for instance variables. For :term:`new-style class`\es,
+descriptors can be used to create instance variables with different
+implementation details.
 
 .. rubric:: Footnotes
 

Modified: python/branches/ctypes-branch/Doc/reference/datamodel.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/reference/datamodel.rst	(original)
+++ python/branches/ctypes-branch/Doc/reference/datamodel.rst	Tue Oct 23 20:47:50 2007
@@ -884,7 +884,7 @@
          single: bytecode
          object: code
 
-      Code objects represent *byte-compiled* executable Python code, or *bytecode*.
+      Code objects represent *byte-compiled* executable Python code, or :term:`bytecode`.
       The difference between a code object and a function object is that the function
       object contains an explicit reference to the function's globals (the module in
       which it was defined), while a code object contains no context; also the default
@@ -905,7 +905,7 @@
       used by the bytecode; :attr:`co_names` is a tuple containing the names used by
       the bytecode; :attr:`co_filename` is the filename from which the code was
       compiled; :attr:`co_firstlineno` is the first line number of the function;
-      :attr:`co_lnotab` is a string encoding the mapping from byte code offsets to
+      :attr:`co_lnotab` is a string encoding the mapping from bytecode offsets to
       line numbers (for details see the source code of the interpreter);
       :attr:`co_stacksize` is the required stack size (including local variables);
       :attr:`co_flags` is an integer encoding a number of flags for the interpreter.
@@ -1082,6 +1082,7 @@
 .. % Types
 .. % =========================================================================
 
+.. _newstyle:
 
 New-style and classic classes
 =============================

Modified: python/branches/ctypes-branch/Doc/tutorial/classes.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/tutorial/classes.rst	(original)
+++ python/branches/ctypes-branch/Doc/tutorial/classes.rst	Tue Oct 23 20:47:50 2007
@@ -495,8 +495,8 @@
 :class:`Base2`.  The depth-first rule makes no differences between direct and
 inherited attributes of :class:`Base1`.)
 
-For new-style classes, the method resolution order changes dynamically to
-support cooperative calls to :func:`super`.  This approach is known in some
+For :term:`new-style class`\es, the method resolution order changes dynamically
+to support cooperative calls to :func:`super`.  This approach is known in some
 other multiple-inheritance languages as call-next-method and is more powerful
 than the super call found in single-inheritance languages.
 
@@ -711,12 +711,12 @@
 Generators
 ==========
 
-Generators are a simple and powerful tool for creating iterators.  They are
-written like regular functions but use the :keyword:`yield` statement whenever
-they want to return data.  Each time :meth:`next` is called, the generator
-resumes where it left-off (it remembers all the data values and which statement
-was last executed).  An example shows that generators can be trivially easy to
-create::
+:term:`Generator`\s are a simple and powerful tool for creating iterators.  They
+are written like regular functions but use the :keyword:`yield` statement
+whenever they want to return data.  Each time :meth:`next` is called, the
+generator resumes where it left-off (it remembers all the data values and which
+statement was last executed).  An example shows that generators can be trivially
+easy to create::
 
    def reverse(data):
        for index in range(len(data)-1, -1, -1):

Modified: python/branches/ctypes-branch/Doc/tutorial/interactive.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/tutorial/interactive.rst	(original)
+++ python/branches/ctypes-branch/Doc/tutorial/interactive.rst	Tue Oct 23 20:47:50 2007
@@ -123,7 +123,7 @@
    # bound to the Esc key by default (you can change it - see readline docs).
    #
    # Store the file in ~/.pystartup, and set an environment variable to point
-   # to it:  "export PYTHONSTARTUP=/max/home/itamar/.pystartup" in bash.
+   # to it:  "export PYTHONSTARTUP=/home/user/.pystartup" in bash.
    #
    # Note that PYTHONSTARTUP does *not* expand "~", so you have to put in the
    # full path to your home directory.

Modified: python/branches/ctypes-branch/Doc/tutorial/modules.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/tutorial/modules.rst	(original)
+++ python/branches/ctypes-branch/Doc/tutorial/modules.rst	Tue Oct 23 20:47:50 2007
@@ -186,8 +186,8 @@
 * When the Python interpreter is invoked with the :option:`-O` flag, optimized
   code is generated and stored in :file:`.pyo` files.  The optimizer currently
   doesn't help much; it only removes :keyword:`assert` statements.  When
-  :option:`-O` is used, *all* bytecode is optimized; ``.pyc`` files are ignored
-  and ``.py`` files are compiled to optimized bytecode.
+  :option:`-O` is used, *all* :term:`bytecode` is optimized; ``.pyc`` files are
+  ignored and ``.py`` files are compiled to optimized bytecode.
 
 * Passing two :option:`-O` flags to the Python interpreter (:option:`-OO`) will
   cause the bytecode compiler to perform optimizations that could in some rare

Modified: python/branches/ctypes-branch/Doc/whatsnew/2.6.rst
==============================================================================
--- python/branches/ctypes-branch/Doc/whatsnew/2.6.rst	(original)
+++ python/branches/ctypes-branch/Doc/whatsnew/2.6.rst	Tue Oct 23 20:47:50 2007
@@ -67,7 +67,6 @@
 .. % Large, PEP-level features and changes should be described here.
 .. % Should there be a new section here for 3k migration?
 .. % Or perhaps a more general section describing module changes/deprecation?
-.. % sets module deprecated
 .. % ======================================================================
 
 Python 3.0
@@ -515,6 +514,12 @@
 by module name. Consult the :file:`Misc/NEWS` file in the source tree for a more
 complete list of changes, or look through the CVS logs for all the details.
 
+* The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol
+  available, instead of restricting itself to protocol 1.
+  (Contributed by W. Barnes.)
+
+  .. % Patch 1551443
+
 * A new data type in the :mod:`collections` module: :class:`named_tuple(typename,
   fieldnames)` is a factory function that creates subclasses of the standard tuple
   whose fields are accessible by name as well as index.  For example::
@@ -531,17 +536,48 @@
      1 1
      >>> print var[2], var.type          # Equivalent
      int int
+     >>> var.__asdict__()
+     {'size': 4, 'type': 'int', 'id': 1, 'name': 'frequency'}
      >>> v2 = var.__replace__('name', 'amplitude')
      >>> v2
      variable(id=1, name='amplitude', type='int', size=4)
 
   (Contributed by Raymond Hettinger.)
 
+* Another change to the :mod:`collections` module is that the 
+  :class:`deque` type now supports an optional `maxlen` parameter;
+  if supplied, the deque's size will be restricted to no more 
+  than ``maxlen`` items.  Adding more items to a full deque causes
+  old items to be discarded.
+
+  ::
+
+    >>> from collections import deque
+    >>> dq=deque(maxlen=3)
+    >>> dq
+    deque([], maxlen=3)
+    >>> dq.append(1) ; dq.append(2) ; dq.append(3)
+    >>> dq
+    deque([1, 2, 3], maxlen=3)
+    >>> dq.append(4)
+    >>> dq
+    deque([2, 3, 4], maxlen=3)
+
+  (Contributed by Raymond Hettinger.)
+
 * The :mod:`ctypes` module now supports a :class:`c_bool` datatype 
   that represents the C99 ``bool`` type.  (Contributed by David Remahl.)
 
   .. % Patch 1649190
 
+  The :mod:`ctypes` string, buffer and array types also have improved
+  support for extended slicing syntax,
+  where various combinations of ``(start, stop, step)`` are supplied.
+  (Implemented by Thomas Wouters.)
+
+  .. % Revision 57769
+
+
 * A new method in the :mod:`curses` module: for a window, :meth:`chgat` changes
   the display characters for a  certain number of characters on a single line.
   ::
@@ -626,6 +662,12 @@
        
   .. % Patch 1273829
 
+* The ``os.environ`` object's :meth:`clear` method will now unset the 
+  environment variables using :func:`os.unsetenv` in addition to clearing
+  the object's keys.  (Contributed by Martin Horcicka.)
+
+  .. % Patch #1181 
+
 * In the :mod:`os.path` module, the :func:`splitext` function
   has been changed to not split on leading period characters.
   This produces better results when operating on Unix's dot-files.
@@ -663,6 +705,9 @@
 
 * The :mod:`rgbimg` module has been removed.
 
+* The :mod:`sets` module has been deprecated; it's better to 
+  use the built-in :class:`set` and :class:`frozenset` types.
+
 * The :mod:`smtplib` module now supports SMTP over SSL thanks to the
   addition of the :class:`SMTP_SSL` class. This class supports an
   interface identical to the existing :class:`SMTP` class.   Both 
@@ -778,7 +823,7 @@
   (Added by Facundo Batista.) 
 
 * The XML-RPC classes :class:`SimpleXMLRPCServer` and :class:`DocXMLRPCServer`
-  classes can now be preventing from immediately opening and binding to
+  classes can now be prevented from immediately opening and binding to
   their socket by passing True as the ``bind_and_activate``
   constructor parameter.  This can be used to modify the instance's
   :attr:`allow_reuse_address` attribute before calling the 
@@ -788,8 +833,36 @@
 
   .. % Patch 1599845
 
+  :class:`SimpleXMLRPCServer` also has a :attr:`_send_traceback_header`
+  attribute; if true, the exception and formatted traceback are returned 
+  as HTTP headers "X-Exception" and "X-Traceback".  This feature is 
+  for debugging purposes only and should not be used on production servers
+  because the tracebacks could possibly reveal passwords or other sensitive
+  information.  (Contributed by Alan McIntyre as part of his 
+  project for Google's Summer of Code 2007.)
+
 .. % ======================================================================
-.. % whole new modules get described in \subsections here
+.. % whole new modules get described in subsections here
+
+Improved SSL Support
+--------------------------------------------------
+
+Bill Janssen made extensive improvements to Python 2.6's support for
+SSL.
+
+XXX use ssl.sslsocket - subclass of socket.socket.
+
+XXX Can specify if certificate is required, and obtain certificate info
+by calling getpeercert method.
+
+XXX sslwrap() behaves like socket.ssl
+
+XXX Certain features require the OpenSSL package to be installed, notably
+  the 'openssl' binary.
+
+.. seealso::
+
+   SSL module documentation.
 
 .. % ======================================================================
 
@@ -799,7 +872,13 @@
 
 Changes to Python's build process and to the C API include:
 
-* Detailed changes will be listed here.
+* The BerkeleyDB module now has a C API object, available as 
+  ``bsddb.db.api``.   This object can be used by other C extensions
+  that wish to use the :mod:`bsddb` module for their own purposes.
+  (Contributed by Duncan Grisby.)
+
+  .. % Patch 1551895
+
 
 .. % ======================================================================
 
@@ -835,8 +914,12 @@
 This section lists previously described changes that may require changes to your
 code:
 
-* The :mod:`socket` module exception :exc:`socket.error` now inherits from 
-  :exc:`IOError`.
+* The :mod:`socket` module exception :exc:`socket.error` now inherits
+  from :exc:`IOError`.  Previously it wasn't a subclass of
+  :exc:`StandardError` but now it is, through :exc:`IOError`.
+  (Implemented by Gregory P. Smith.)
+
+  .. % http://bugs.python.org/issue1706815
 
 .. % ======================================================================
 

Modified: python/branches/ctypes-branch/Lib/bsddb/dbshelve.py
==============================================================================
--- python/branches/ctypes-branch/Lib/bsddb/dbshelve.py	(original)
+++ python/branches/ctypes-branch/Lib/bsddb/dbshelve.py	Tue Oct 23 20:47:50 2007
@@ -84,12 +84,16 @@
 
 #---------------------------------------------------------------------------
 
+class DBShelveError(db.DBError): pass
+
+
 class DBShelf(DictMixin):
     """A shelf to hold pickled objects, built upon a bsddb DB object.  It
     automatically pickles/unpickles data objects going to/from the DB.
     """
     def __init__(self, dbenv=None):
         self.db = db.DB(dbenv)
+        self._closed = True
         if HIGHEST_PROTOCOL:
             self.protocol = HIGHEST_PROTOCOL
         else:
@@ -135,6 +139,23 @@
             return self.db.keys()
 
 
+    def open(self, *args, **kwargs):
+        self.db.open(*args, **kwargs)
+        self._closed = False
+
+
+    def close(self, *args, **kwargs):
+        self.db.close(*args, **kwargs)
+        self._closed = True
+
+
+    def __repr__(self):
+        if self._closed:
+            return '<DBShelf @ 0x%x - closed>' % (id(self))
+        else:
+            return repr(dict(self.iteritems()))
+
+
     def items(self, txn=None):
         if txn != None:
             items = self.db.items(txn)
@@ -162,10 +183,9 @@
         return self.db.append(data, txn)
 
     def append(self, value, txn=None):
-        if self.get_type() != db.DB_RECNO:
-            self.append = self.__append
-            return self.append(value, txn=txn)
-        raise db.DBError, "append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO"
+        if self.get_type() == db.DB_RECNO:
+            return self.__append(value, txn=txn)
+        raise DBShelveError, "append() only supported when dbshelve opened with filetype=dbshelve.db.DB_RECNO"
 
 
     def associate(self, secondaryDB, callback, flags=0):

Modified: python/branches/ctypes-branch/Lib/bsddb/dbtables.py
==============================================================================
--- python/branches/ctypes-branch/Lib/bsddb/dbtables.py	(original)
+++ python/branches/ctypes-branch/Lib/bsddb/dbtables.py	Tue Oct 23 20:47:50 2007
@@ -20,8 +20,8 @@
 import re
 import sys
 import copy
-import xdrlib
 import random
+import struct
 from types import ListType, StringType
 import cPickle as pickle
 
@@ -255,7 +255,7 @@
                                                  flags=DB_RMW))
             tablelist.append(table)
             # delete 1st, in case we opened with DB_DUP
-            self.db.delete(_table_names_key, txn)
+            self.db.delete(_table_names_key, txn=txn)
             self.db.put(_table_names_key, pickle.dumps(tablelist, 1), txn=txn)
 
             txn.commit()
@@ -329,7 +329,7 @@
                 # store the table's new extended column list
                 if newcolumnlist != oldcolumnlist :
                     # delete the old one first since we opened with DB_DUP
-                    self.db.delete(columnlist_key, txn)
+                    self.db.delete(columnlist_key, txn=txn)
                     self.db.put(columnlist_key,
                                 pickle.dumps(newcolumnlist, 1),
                                 txn=txn)
@@ -362,10 +362,11 @@
             # Generate a random 64-bit row ID string
             # (note: this code has <64 bits of randomness
             # but it's plenty for our database id needs!)
-            p = xdrlib.Packer()
-            p.pack_int(int(random.random()*2147483647))
-            p.pack_int(int(random.random()*2147483647))
-            newid = p.get_buffer()
+            # We must ensure that no null bytes are in the id value.
+            blist = []
+            for x in xrange(_rowid_str_len):
+                blist.append(random.randint(1,255))
+            newid = struct.pack('B'*_rowid_str_len, *blist)
 
             # Guarantee uniqueness by adding this key to the database
             try:
@@ -444,10 +445,10 @@
                         try:
                             dataitem = self.db.get(
                                 _data_key(table, column, rowid),
-                                txn)
+                                txn=txn)
                             self.db.delete(
                                 _data_key(table, column, rowid),
-                                txn)
+                                txn=txn)
                         except DBNotFoundError:
                              # XXXXXXX row key somehow didn't exist, assume no
                              # error
@@ -490,13 +491,13 @@
                         # delete the data key
                         try:
                             self.db.delete(_data_key(table, column, rowid),
-                                           txn)
+                                           txn=txn)
                         except DBNotFoundError:
                             # XXXXXXX column may not exist, assume no error
                             pass
 
                     try:
-                        self.db.delete(_rowid_key(table, rowid), txn)
+                        self.db.delete(_rowid_key(table, rowid), txn=txn)
                     except DBNotFoundError:
                         # XXXXXXX row key somehow didn't exist, assume no error
                         pass
@@ -652,7 +653,7 @@
             txn = self.env.txn_begin()
 
             # delete the column list
-            self.db.delete(_columns_key(table), txn)
+            self.db.delete(_columns_key(table), txn=txn)
 
             cur = self.db.cursor(txn)
 
@@ -691,7 +692,7 @@
                 # hmm, it wasn't there, oh well, that's what we want.
                 pass
             # delete 1st, incase we opened with DB_DUP
-            self.db.delete(_table_names_key, txn)
+            self.db.delete(_table_names_key, txn=txn)
             self.db.put(_table_names_key, pickle.dumps(tablelist, 1), txn=txn)
 
             txn.commit()

Modified: python/branches/ctypes-branch/Lib/bsddb/test/test_1413192.py
==============================================================================
--- python/branches/ctypes-branch/Lib/bsddb/test/test_1413192.py	(original)
+++ python/branches/ctypes-branch/Lib/bsddb/test/test_1413192.py	Tue Oct 23 20:47:50 2007
@@ -5,6 +5,7 @@
 
 import shutil
 import tempfile
+import warnings
 try:
     # For Pythons w/distutils and add-on pybsddb
     from bsddb3 import db
@@ -32,8 +33,12 @@
         del self.the_txn
 
 
-context = Context()
-del context
+warnings.filterwarnings('ignore', 'DBTxn aborted in destructor')
+try:
+    context = Context()
+    del context
+finally:
+    warnings.resetwarnings()
 
 # try not to leave a turd
 try:

Modified: python/branches/ctypes-branch/Lib/bsddb/test/test_dbshelve.py
==============================================================================
--- python/branches/ctypes-branch/Lib/bsddb/test/test_dbshelve.py	(original)
+++ python/branches/ctypes-branch/Lib/bsddb/test/test_dbshelve.py	Tue Oct 23 20:47:50 2007
@@ -41,17 +41,22 @@
         except os.error:
             pass
 
+    def mk(self, key):
+        """Turn key into an appropriate key type for this db"""
+        # override in child class for RECNO
+        return key
+
     def populateDB(self, d):
         for x in string.letters:
-            d['S' + x] = 10 * x           # add a string
-            d['I' + x] = ord(x)           # add an integer
-            d['L' + x] = [x] * 10         # add a list
+            d[self.mk('S' + x)] = 10 * x           # add a string
+            d[self.mk('I' + x)] = ord(x)           # add an integer
+            d[self.mk('L' + x)] = [x] * 10         # add a list
 
             inst = DataClass()            # add an instance
             inst.S = 10 * x
             inst.I = ord(x)
             inst.L = [x] * 10
-            d['O' + x] = inst
+            d[self.mk('O' + x)] = inst
 
 
     # overridable in derived classes to affect how the shelf is created/opened
@@ -85,14 +90,14 @@
             print "keys:", k
             print "stats:", s
 
-        assert 0 == d.has_key('bad key')
-        assert 1 == d.has_key('IA')
-        assert 1 == d.has_key('OA')
-
-        d.delete('IA')
-        del d['OA']
-        assert 0 == d.has_key('IA')
-        assert 0 == d.has_key('OA')
+        assert 0 == d.has_key(self.mk('bad key'))
+        assert 1 == d.has_key(self.mk('IA'))
+        assert 1 == d.has_key(self.mk('OA'))
+
+        d.delete(self.mk('IA'))
+        del d[self.mk('OA')]
+        assert 0 == d.has_key(self.mk('IA'))
+        assert 0 == d.has_key(self.mk('OA'))
         assert len(d) == l-2
 
         values = []
@@ -115,18 +120,18 @@
         for key, value in items:
             self.checkrec(key, value)
 
-        assert d.get('bad key') == None
-        assert d.get('bad key', None) == None
-        assert d.get('bad key', 'a string') == 'a string'
-        assert d.get('bad key', [1, 2, 3]) == [1, 2, 3]
+        assert d.get(self.mk('bad key')) == None
+        assert d.get(self.mk('bad key'), None) == None
+        assert d.get(self.mk('bad key'), 'a string') == 'a string'
+        assert d.get(self.mk('bad key'), [1, 2, 3]) == [1, 2, 3]
 
         d.set_get_returns_none(0)
-        self.assertRaises(db.DBNotFoundError, d.get, 'bad key')
+        self.assertRaises(db.DBNotFoundError, d.get, self.mk('bad key'))
         d.set_get_returns_none(1)
 
-        d.put('new key', 'new data')
-        assert d.get('new key') == 'new data'
-        assert d['new key'] == 'new data'
+        d.put(self.mk('new key'), 'new data')
+        assert d.get(self.mk('new key')) == 'new data'
+        assert d[self.mk('new key')] == 'new data'
 
 
 
@@ -165,14 +170,24 @@
 
         assert count == len(d)
 
-        c.set('SS')
+        c.set(self.mk('SS'))
         key, value = c.current()
         self.checkrec(key, value)
         del c
 
 
+    def test03_append(self):
+        # NOTE: this is overridden in RECNO subclass, don't change its name.
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test03_append..." % self.__class__.__name__
+
+        self.assertRaises(dbshelve.DBShelveError,
+                          self.d.append, 'unit test was here')
+
 
     def checkrec(self, key, value):
+        # override this in a subclass if the key type is different
         x = key[1]
         if key[0] == 'S':
             assert type(value) == StringType
@@ -281,7 +296,43 @@
 
 
 #----------------------------------------------------------------------
-# TODO:  Add test cases for a DBShelf in a RECNO DB.
+# test cases for a DBShelf in a RECNO DB.
+
+class RecNoShelveTestCase(BasicShelveTestCase):
+    dbtype = db.DB_RECNO
+    dbflags = db.DB_CREATE
+
+    def setUp(self):
+        BasicShelveTestCase.setUp(self)
+
+        # pool to assign integer key values out of
+        self.key_pool = list(range(1, 5000))
+        self.key_map = {}     # map string keys to the number we gave them
+        self.intkey_map = {}  # reverse map of above
+
+    def mk(self, key):
+        if key not in self.key_map:
+            self.key_map[key] = self.key_pool.pop(0)
+            self.intkey_map[self.key_map[key]] = key
+        return self.key_map[key]
+
+    def checkrec(self, intkey, value):
+        key = self.intkey_map[intkey]
+        BasicShelveTestCase.checkrec(self, key, value)
+
+    def test03_append(self):
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test03_append..." % self.__class__.__name__
+
+        self.d[1] = 'spam'
+        self.d[5] = 'eggs'
+        self.assertEqual(6, self.d.append('spam'))
+        self.assertEqual(7, self.d.append('baked beans'))
+        self.assertEqual('spam', self.d.get(6))
+        self.assertEqual('spam', self.d.get(1))
+        self.assertEqual('baked beans', self.d.get(7))
+        self.assertEqual('eggs', self.d.get(5))
 
 
 #----------------------------------------------------------------------
@@ -298,6 +349,7 @@
     suite.addTest(unittest.makeSuite(EnvHashShelveTestCase))
     suite.addTest(unittest.makeSuite(EnvThreadBTreeShelveTestCase))
     suite.addTest(unittest.makeSuite(EnvThreadHashShelveTestCase))
+    suite.addTest(unittest.makeSuite(RecNoShelveTestCase))
 
     return suite
 

Modified: python/branches/ctypes-branch/Lib/bsddb/test/test_dbtables.py
==============================================================================
--- python/branches/ctypes-branch/Lib/bsddb/test/test_dbtables.py	(original)
+++ python/branches/ctypes-branch/Lib/bsddb/test/test_dbtables.py	Tue Oct 23 20:47:50 2007
@@ -21,6 +21,8 @@
 # $Id$
 
 import sys, os, re
+import tempfile
+import shutil
 try:
     import cPickle
     pickle = cPickle
@@ -47,8 +49,8 @@
     db_name = 'test-table.db'
 
     def setUp(self):
-        homeDir = os.path.join(tempfile.gettempdir(), 'db_home')
-        self.homeDir = homeDir
+        homeDir = tempfile.mkdtemp()
+        self.testHomeDir = homeDir
         try: os.mkdir(homeDir)
         except os.error: pass
         self.tdb = dbtables.bsdTableDB(
@@ -56,10 +58,7 @@
 
     def tearDown(self):
         self.tdb.close()
-        import glob
-        files = glob.glob(os.path.join(self.homeDir, '*'))
-        for file in files:
-            os.remove(file)
+        shutil.rmtree(self.testHomeDir)
 
     def test01(self):
         tabname = "test01"
@@ -78,7 +77,8 @@
             tabname, [colname], conditions={colname: None})
 
         colval = pickle.loads(values[0][colname])
-        assert(colval > 3.141 and colval < 3.142)
+        self.assert_(colval > 3.141)
+        self.assert_(colval < 3.142)
 
 
     def test02(self):
@@ -103,15 +103,15 @@
         values = self.tdb.Select(tabname, [col2],
             conditions={col0: lambda x: pickle.loads(x) >= 8})
 
-        assert len(values) == 2
+        self.assertEqual(len(values), 2)
         if values[0]['Species'] == 'Penguin' :
-            assert values[1]['Species'] == 'SR-71A Blackbird'
+            self.assertEqual(values[1]['Species'], 'SR-71A Blackbird')
         elif values[0]['Species'] == 'SR-71A Blackbird' :
-            assert values[1]['Species'] == 'Penguin'
+            self.assertEqual(values[1]['Species'], 'Penguin')
         else :
             if verbose:
                 print "values= %r" % (values,)
-            raise "Wrong values returned!"
+            raise RuntimeError("Wrong values returned!")
 
     def test03(self):
         tabname = "test03"
@@ -137,13 +137,13 @@
                             {'a': "",
                              'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1),
                              'f': "Zero"})
-            assert 0
+            self.fail('Expected an exception')
         except dbtables.TableDBError:
             pass
 
         try:
             self.tdb.Select(tabname, [], conditions={'foo': '123'})
-            assert 0
+            self.fail('Expected an exception')
         except dbtables.TableDBError:
             pass
 
@@ -172,20 +172,20 @@
         values = self.tdb.Select(tabname, ['b', 'a', 'd'],
             conditions={'e': re.compile('wuzzy').search,
                         'a': re.compile('^[0-9]+$').match})
-        assert len(values) == 2
+        self.assertEqual(len(values), 2)
 
         # now lets delete one of them and try again
         self.tdb.Delete(tabname, conditions={'b': dbtables.ExactCond('good')})
         values = self.tdb.Select(
             tabname, ['a', 'd', 'b'],
             conditions={'e': dbtables.PrefixCond('Fuzzy')})
-        assert len(values) == 1
-        assert values[0]['d'] == None
+        self.assertEqual(len(values), 1)
+        self.assertEqual(values[0]['d'], None)
 
         values = self.tdb.Select(tabname, ['b'],
             conditions={'c': lambda c: c == 'meep'})
-        assert len(values) == 1
-        assert values[0]['b'] == "bad"
+        self.assertEqual(len(values), 1)
+        self.assertEqual(values[0]['b'], "bad")
 
 
     def test04_MultiCondSelect(self):
@@ -201,7 +201,7 @@
                             {'a': "",
                              'e': pickle.dumps([{4:5, 6:7}, 'foo'], 1),
                              'f': "Zero"})
-            assert 0
+            self.fail('Expected an exception')
         except dbtables.TableDBError:
             pass
 
@@ -225,7 +225,7 @@
                         'a': dbtables.ExactCond('A'),
                         'd': dbtables.PrefixCond('-')
                        } )
-        assert len(values) == 0, values
+        self.assertEqual(len(values), 0, values)
 
 
     def test_CreateOrExtend(self):
@@ -238,7 +238,7 @@
                             {'taste': 'crap',
                              'filling': 'no',
                              'is it Guinness?': 'no'})
-            assert 0, "Insert should've failed due to bad column name"
+            self.fail("Insert should've failed due to bad column name")
         except:
             pass
         self.tdb.CreateOrExtendTable(tabname,
@@ -272,16 +272,16 @@
         values = self.tdb.Select(
             tabname, ['p', 'e'],
             conditions={'e': dbtables.PrefixCond('the l')})
-        assert len(values) == 2, values
-        assert values[0]['e'] == values[1]['e'], values
-        assert values[0]['p'] != values[1]['p'], values
+        self.assertEqual(len(values), 2, values)
+        self.assertEqual(values[0]['e'], values[1]['e'], values)
+        self.assertNotEqual(values[0]['p'], values[1]['p'], values)
 
         values = self.tdb.Select(
             tabname, ['d', 'a'],
             conditions={'a': dbtables.LikeCond('%aardvark%')})
-        assert len(values) == 1, values
-        assert values[0]['d'] == "is for dog", values
-        assert values[0]['a'] == "is for aardvark", values
+        self.assertEqual(len(values), 1, values)
+        self.assertEqual(values[0]['d'], "is for dog", values)
+        self.assertEqual(values[0]['a'], "is for aardvark", values)
 
         values = self.tdb.Select(tabname, None,
                                  {'b': dbtables.Cond(),
@@ -290,9 +290,9 @@
                                   'd':dbtables.ExactCond('is for dog'),
                                   'c':dbtables.PrefixCond('is for'),
                                   'p':lambda s: not s})
-        assert len(values) == 1, values
-        assert values[0]['d'] == "is for dog", values
-        assert values[0]['a'] == "is for aardvark", values
+        self.assertEqual(len(values), 1, values)
+        self.assertEqual(values[0]['d'], "is for dog", values)
+        self.assertEqual(values[0]['a'], "is for aardvark", values)
 
     def test_Delete(self):
         tabname = "test_Delete"
@@ -308,7 +308,7 @@
         self.tdb.Delete(tabname, conditions={'x': dbtables.PrefixCond('X')})
         values = self.tdb.Select(tabname, ['y'],
                                  conditions={'x': dbtables.PrefixCond('X')})
-        assert len(values) == 0
+        self.assertEqual(len(values), 0)
 
     def test_Modify(self):
         tabname = "test_Modify"
@@ -354,24 +354,24 @@
         values = self.tdb.Select(
             tabname, None,
             conditions={'Type': dbtables.ExactCond('Unknown')})
-        assert len(values) == 1, values
-        assert values[0]['Name'] == None, values
-        assert values[0]['Access'] == None, values
+        self.assertEqual(len(values), 1, values)
+        self.assertEqual(values[0]['Name'], None, values)
+        self.assertEqual(values[0]['Access'], None, values)
 
         # Modify value by select conditions
         values = self.tdb.Select(
             tabname, None,
             conditions={'Name': dbtables.ExactCond('Nifty.MP3')})
-        assert len(values) == 1, values
-        assert values[0]['Type'] == "MP3", values
-        assert values[0]['Access'] == "2", values
+        self.assertEqual(len(values), 1, values)
+        self.assertEqual(values[0]['Type'], "MP3", values)
+        self.assertEqual(values[0]['Access'], "2", values)
 
         # Make sure change applied only to select conditions
         values = self.tdb.Select(
             tabname, None, conditions={'Name': dbtables.LikeCond('%doc%')})
-        assert len(values) == 1, values
-        assert values[0]['Type'] == "Word", values
-        assert values[0]['Access'] == "9", values
+        self.assertEqual(len(values), 1, values)
+        self.assertEqual(values[0]['Type'], "Word", values)
+        self.assertEqual(values[0]['Access'], "9", values)
 
 
 def test_suite():

Modified: python/branches/ctypes-branch/Lib/collections.py
==============================================================================
--- python/branches/ctypes-branch/Lib/collections.py	(original)
+++ python/branches/ctypes-branch/Lib/collections.py	Tue Oct 23 20:47:50 2007
@@ -2,6 +2,7 @@
 
 from _collections import deque, defaultdict
 from operator import itemgetter as _itemgetter
+from keyword import iskeyword as _iskeyword
 import sys as _sys
 
 def named_tuple(typename, field_names, verbose=False):
@@ -32,16 +33,19 @@
     if isinstance(field_names, basestring):
         field_names = field_names.replace(',', ' ').split() # names separated by whitespace and/or commas
     field_names = tuple(field_names)
-    if not ''.join((typename,) + field_names).replace('_', '').isalnum():
-        raise ValueError('Type names and field names can only contain alphanumeric characters and underscores')
+    for name in (typename,) + field_names:
+        if not name.replace('_', '').isalnum():
+            raise ValueError('Type names and field names can only contain alphanumeric characters and underscores: %r' % name)
+        if _iskeyword(name):
+            raise ValueError('Type names and field names cannot be a keyword: %r' % name)
+        if name[0].isdigit():
+            raise ValueError('Type names and field names cannot start with a number: %r' % name)
     seen_names = set()
     for name in field_names:
         if name.startswith('__') and name.endswith('__'):
-            raise ValueError('Field names cannot start and end with double underscores: %s' % name)
-        if name[:1].isdigit():
-            raise ValueError('Field names cannot start with a number: %s' % name)
+            raise ValueError('Field names cannot start and end with double underscores: %r' % name)
         if name in seen_names:
-            raise ValueError('Encountered duplicate field name: %s' % name)
+            raise ValueError('Encountered duplicate field name: %r' % name)
         seen_names.add(name)
 
     # Create and fill-in the class template

Modified: python/branches/ctypes-branch/Lib/ctypes/__init__.py
==============================================================================
--- python/branches/ctypes-branch/Lib/ctypes/__init__.py	(original)
+++ python/branches/ctypes-branch/Lib/ctypes/__init__.py	Tue Oct 23 20:47:50 2007
@@ -24,19 +24,12 @@
 
 DEFAULT_MODE = RTLD_LOCAL
 if _os.name == "posix" and _sys.platform == "darwin":
-    import gestalt
-
-    # gestalt.gestalt("sysv") returns the version number of the
-    # currently active system file as BCD.
-    # On OS X 10.4.6 -> 0x1046
-    # On OS X 10.2.8 -> 0x1028
-    # See also http://www.rgaros.nl/gestalt/
-    #
     # On OS X 10.3, we use RTLD_GLOBAL as default mode
     # because RTLD_LOCAL does not work at least on some
-    # libraries.
+    # libraries.  OS X 10.3 is Darwin 7, so we check for
+    # that.
 
-    if gestalt.gestalt("sysv") < 0x1040:
+    if int(_os.uname()[2].split('.')[0]) < 8:
         DEFAULT_MODE = RTLD_GLOBAL
 
 from _ctypes import FUNCFLAG_CDECL as _FUNCFLAG_CDECL, \

Modified: python/branches/ctypes-branch/Lib/decimal.py
==============================================================================
--- python/branches/ctypes-branch/Lib/decimal.py	(original)
+++ python/branches/ctypes-branch/Lib/decimal.py	Tue Oct 23 20:47:50 2007
@@ -562,20 +562,46 @@
         # tuple/list conversion (possibly from as_tuple())
         if isinstance(value, (list,tuple)):
             if len(value) != 3:
-                raise ValueError('Invalid arguments')
-            if value[0] not in (0,1):
-                raise ValueError('Invalid sign')
-            for digit in value[1]:
-                if not isinstance(digit, (int,long)) or digit < 0:
-                    raise ValueError("The second value in the tuple must be "
-                                "composed of non negative integer elements.")
+                raise ValueError('Invalid tuple size in creation of Decimal '
+                                 'from list or tuple.  The list or tuple '
+                                 'should have exactly three elements.')
+            # process sign.  The isinstance test rejects floats
+            if not (isinstance(value[0], (int, long)) and value[0] in (0,1)):
+                raise ValueError("Invalid sign.  The first value in the tuple "
+                                 "should be an integer; either 0 for a "
+                                 "positive number or 1 for a negative number.")
             self._sign = value[0]
-            self._int  = tuple(value[1])
-            if value[2] in ('F','n','N'):
+            if value[2] == 'F':
+                # infinity: value[1] is ignored
+                self._int = (0,)
                 self._exp = value[2]
                 self._is_special = True
             else:
-                self._exp  = int(value[2])
+                # process and validate the digits in value[1]
+                digits = []
+                for digit in value[1]:
+                    if isinstance(digit, (int, long)) and 0 <= digit <= 9:
+                        # skip leading zeros
+                        if digits or digit != 0:
+                            digits.append(digit)
+                    else:
+                        raise ValueError("The second value in the tuple must "
+                                         "be composed of integers in the range "
+                                         "0 through 9.")
+                if value[2] in ('n', 'N'):
+                    # NaN: digits form the diagnostic
+                    self._int = tuple(digits)
+                    self._exp = value[2]
+                    self._is_special = True
+                elif isinstance(value[2], (int, long)):
+                    # finite number: digits give the coefficient
+                    self._int = tuple(digits or [0])
+                    self._exp = value[2]
+                    self._is_special = False
+                else:
+                    raise ValueError("The third value in the tuple must "
+                                     "be an integer, or one of the "
+                                     "strings 'F', 'n', 'N'.")
             return self
 
         if isinstance(value, float):

Modified: python/branches/ctypes-branch/Lib/httplib.py
==============================================================================
--- python/branches/ctypes-branch/Lib/httplib.py	(original)
+++ python/branches/ctypes-branch/Lib/httplib.py	Tue Oct 23 20:47:50 2007
@@ -530,7 +530,8 @@
         s = self.fp.read(amt)
         if self.length is not None:
             self.length -= len(s)
-
+            if not self.length:
+                self.close()
         return s
 
     def _read_chunked(self, amt):

Modified: python/branches/ctypes-branch/Lib/idlelib/EditorWindow.py
==============================================================================
--- python/branches/ctypes-branch/Lib/idlelib/EditorWindow.py	(original)
+++ python/branches/ctypes-branch/Lib/idlelib/EditorWindow.py	Tue Oct 23 20:47:50 2007
@@ -414,6 +414,7 @@
 
     def paste(self,event):
         self.text.event_generate("<<Paste>>")
+        self.text.see("insert")
         return "break"
 
     def select_all(self, event=None):

Modified: python/branches/ctypes-branch/Lib/idlelib/NEWS.txt
==============================================================================
--- python/branches/ctypes-branch/Lib/idlelib/NEWS.txt	(original)
+++ python/branches/ctypes-branch/Lib/idlelib/NEWS.txt	Tue Oct 23 20:47:50 2007
@@ -3,6 +3,13 @@
 
 *Release date: XX-XXX-200X*
 
+- Show paste position if > 80 col.  Patch 1659326 Tal Einat.
+
+- Update cursor color without restarting.  Patch 1725576 Tal Einat.
+
+- Allow keyboard interrupt only when user code is executing in subprocess.
+  Patch 1225 Tal Einat (reworked from IDLE-Spoon).
+
 - configDialog cleanup. Patch 1730217 Tal Einat.
 
 - textView cleanup. Patch 1718043 Tal Einat.

Modified: python/branches/ctypes-branch/Lib/idlelib/configDialog.py
==============================================================================
--- python/branches/ctypes-branch/Lib/idlelib/configDialog.py	(original)
+++ python/branches/ctypes-branch/Lib/idlelib/configDialog.py	Tue Oct 23 20:47:50 2007
@@ -1118,12 +1118,15 @@
     def ActivateConfigChanges(self):
         "Dynamically apply configuration changes"
         winInstances=self.parent.instance_dict.keys()
+        theme = idleConf.CurrentTheme()
+        cursor_color = idleConf.GetHighlight(theme, 'cursor', fgBg='fg')
         for instance in winInstances:
             instance.ResetColorizer()
             instance.ResetFont()
             instance.set_notabs_indentwidth()
             instance.ApplyKeybindings()
             instance.reset_help_menu_entries()
+            instance.text.configure(insertbackground=cursor_color)
 
     def Cancel(self):
         self.destroy()

Modified: python/branches/ctypes-branch/Lib/idlelib/run.py
==============================================================================
--- python/branches/ctypes-branch/Lib/idlelib/run.py	(original)
+++ python/branches/ctypes-branch/Lib/idlelib/run.py	Tue Oct 23 20:47:50 2007
@@ -38,10 +38,11 @@
 
 # Thread shared globals: Establish a queue between a subthread (which handles
 # the socket) and the main thread (which runs user code), plus global
-# completion and exit flags:
+# completion, exit and interruptable (the main thread) flags:
 
 exit_now = False
 quitting = False
+interruptable = False
 
 def main(del_exitfunc=False):
     """Start the Python execution server in a subprocess
@@ -280,9 +281,14 @@
         self.autocomplete = AutoComplete.AutoComplete()
 
     def runcode(self, code):
+        global interruptable
         try:
             self.usr_exc_info = None
-            exec code in self.locals
+            interruptable = True
+            try:
+                exec code in self.locals
+            finally:
+                interruptable = False
         except:
             self.usr_exc_info = sys.exc_info()
             if quitting:
@@ -296,7 +302,8 @@
             flush_stdout()
 
     def interrupt_the_server(self):
-        thread.interrupt_main()
+        if interruptable:
+            thread.interrupt_main()
 
     def start_the_debugger(self, gui_adap_oid):
         return RemoteDebugger.start_debugger(self.rpchandler, gui_adap_oid)

Modified: python/branches/ctypes-branch/Lib/smtpd.py
==============================================================================
--- python/branches/ctypes-branch/Lib/smtpd.py	(original)
+++ python/branches/ctypes-branch/Lib/smtpd.py	Tue Oct 23 20:47:50 2007
@@ -221,7 +221,7 @@
 
     def smtp_MAIL(self, arg):
         print >> DEBUGSTREAM, '===> MAIL', arg
-        address = self.__getaddr('FROM:', arg)
+        address = self.__getaddr('FROM:', arg) if arg else None
         if not address:
             self.push('501 Syntax: MAIL FROM:<address>')
             return

Deleted: /python/branches/ctypes-branch/Lib/test/crashers/file_threads.py
==============================================================================
--- /python/branches/ctypes-branch/Lib/test/crashers/file_threads.py	Tue Oct 23 20:47:50 2007
+++ (empty file)
@@ -1,8 +0,0 @@
-# An example for http://bugs.python.org/issue815646
-
-import thread
-
-while 1:
-    f = open("/tmp/dupa", "w")
-    thread.start_new_thread(f.close, ())
-    f.close()

Modified: python/branches/ctypes-branch/Lib/test/test_collections.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_collections.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_collections.py	Tue Oct 23 20:47:50 2007
@@ -11,11 +11,17 @@
         self.assertEqual(Point.__slots__, ())
         self.assertEqual(Point.__module__, __name__)
         self.assertEqual(Point.__getitem__, tuple.__getitem__)
-        self.assertRaises(ValueError, named_tuple, 'abc%', 'def ghi')
-        self.assertRaises(ValueError, named_tuple, 'abc', 'def g%hi')
-        self.assertRaises(ValueError, named_tuple, 'abc', '__def__ ghi')
-        self.assertRaises(ValueError, named_tuple, 'abc', 'def def ghi')
-        self.assertRaises(ValueError, named_tuple, 'abc', '8def 9ghi')
+
+        self.assertRaises(ValueError, named_tuple, 'abc%', 'efg ghi')       # type has non-alpha char
+        self.assertRaises(ValueError, named_tuple, 'class', 'efg ghi')      # type has keyword
+        self.assertRaises(ValueError, named_tuple, '9abc', 'efg ghi')       # type starts with digit
+
+        self.assertRaises(ValueError, named_tuple, 'abc', 'efg g%hi')       # field with non-alpha char
+        self.assertRaises(ValueError, named_tuple, 'abc', 'abc class')      # field has keyword
+        self.assertRaises(ValueError, named_tuple, 'abc', '8efg 9ghi')      # field starts with digit
+        self.assertRaises(ValueError, named_tuple, 'abc', '__efg__ ghi')    # field with double underscores
+        self.assertRaises(ValueError, named_tuple, 'abc', 'efg efg ghi')    # duplicate field
+
         named_tuple('Point0', 'x1 y2')   # Verify that numbers are allowed in names
 
     def test_instance(self):
@@ -66,7 +72,6 @@
         self.assertEqual(p.y, y)
         self.assertRaises(AttributeError, eval, 'p.z', locals())
 
-
     def test_odd_sizes(self):
         Zero = named_tuple('Zero', '')
         self.assertEqual(Zero(), ())

Modified: python/branches/ctypes-branch/Lib/test/test_decimal.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_decimal.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_decimal.py	Tue Oct 23 20:47:50 2007
@@ -452,13 +452,18 @@
 
         #bad sign
         self.assertRaises(ValueError, Decimal, (8, (4, 3, 4, 9, 1), 2) )
+        self.assertRaises(ValueError, Decimal, (0., (4, 3, 4, 9, 1), 2) )
+        self.assertRaises(ValueError, Decimal, (Decimal(1), (4, 3, 4, 9, 1), 2))
 
         #bad exp
         self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 'wrong!') )
+        self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), 0.) )
+        self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, 9, 1), '1') )
 
         #bad coefficients
         self.assertRaises(ValueError, Decimal, (1, (4, 3, 4, None, 1), 2) )
         self.assertRaises(ValueError, Decimal, (1, (4, -3, 4, 9, 1), 2) )
+        self.assertRaises(ValueError, Decimal, (1, (4, 10, 4, 9, 1), 2) )
 
     def test_explicit_from_Decimal(self):
 
@@ -1060,6 +1065,28 @@
         d = Decimal("Infinity")
         self.assertEqual(d.as_tuple(), (0, (0,), 'F') )
 
+        #leading zeros in coefficient should be stripped
+        d = Decimal( (0, (0, 0, 4, 0, 5, 3, 4), -2) )
+        self.assertEqual(d.as_tuple(), (0, (4, 0, 5, 3, 4), -2) )
+        d = Decimal( (1, (0, 0, 0), 37) )
+        self.assertEqual(d.as_tuple(), (1, (0,), 37))
+        d = Decimal( (1, (), 37) )
+        self.assertEqual(d.as_tuple(), (1, (0,), 37))
+
+        #leading zeros in NaN diagnostic info should be stripped
+        d = Decimal( (0, (0, 0, 4, 0, 5, 3, 4), 'n') )
+        self.assertEqual(d.as_tuple(), (0, (4, 0, 5, 3, 4), 'n') )
+        d = Decimal( (1, (0, 0, 0), 'N') )
+        self.assertEqual(d.as_tuple(), (1, (), 'N') )
+        d = Decimal( (1, (), 'n') )
+        self.assertEqual(d.as_tuple(), (1, (), 'n') )
+
+        #coefficient in infinity should be ignored
+        d = Decimal( (0, (4, 5, 3, 4), 'F') )
+        self.assertEqual(d.as_tuple(), (0, (0,), 'F'))
+        d = Decimal( (1, (0, 2, 7, 1), 'F') )
+        self.assertEqual(d.as_tuple(), (1, (0,), 'F'))
+
     def test_immutability_operations(self):
         # Do operations and check that it didn't change change internal objects.
 

Modified: python/branches/ctypes-branch/Lib/test/test_deque.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_deque.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_deque.py	Tue Oct 23 20:47:50 2007
@@ -48,6 +48,7 @@
         self.assertEqual(list(d), range(50, 150))
 
     def test_maxlen(self):
+        self.assertRaises(ValueError, deque, 'abc', -1)
         self.assertRaises(ValueError, deque, 'abc', -2)
         d = deque(range(10), maxlen=3)
         self.assertEqual(repr(d), 'deque([7, 8, 9], maxlen=3)')
@@ -73,7 +74,7 @@
             fo.close()
             os.remove(test_support.TESTFN)
 
-        d = deque(range(10), maxlen=-1)
+        d = deque(range(10), maxlen=None)
         self.assertEqual(repr(d), 'deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])')
         try:
             fo = open(test_support.TESTFN, "wb")
@@ -489,6 +490,22 @@
         self.assertEqual(type(d), type(e))
         self.assertEqual(list(d), list(e))
 
+        d = Deque('abcde', maxlen=4)
+
+        e = d.__copy__()
+        self.assertEqual(type(d), type(e))
+        self.assertEqual(list(d), list(e))
+
+        e = Deque(d)
+        self.assertEqual(type(d), type(e))
+        self.assertEqual(list(d), list(e))
+
+        s = pickle.dumps(d)
+        e = pickle.loads(s)
+        self.assertNotEqual(id(d), id(e))
+        self.assertEqual(type(d), type(e))
+        self.assertEqual(list(d), list(e))
+
 ##    def test_pickle(self):
 ##        d = Deque('abc')
 ##        d.append(d)

Modified: python/branches/ctypes-branch/Lib/test/test_httplib.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_httplib.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_httplib.py	Tue Oct 23 20:47:50 2007
@@ -81,13 +81,25 @@
         resp = httplib.HTTPResponse(sock)
         resp.begin()
         self.assertEqual(resp.read(), 'Text')
-        resp.close()
+        self.assertTrue(resp.isclosed())
 
         body = "HTTP/1.1 400.100 Not Ok\r\n\r\nText"
         sock = FakeSocket(body)
         resp = httplib.HTTPResponse(sock)
         self.assertRaises(httplib.BadStatusLine, resp.begin)
 
+    def test_partial_reads(self):
+        # if we have a lenght, the system knows when to close itself
+        # same behaviour than when we read the whole thing with read()
+        body = "HTTP/1.1 200 Ok\r\nContent-Length: 4\r\n\r\nText"
+        sock = FakeSocket(body)
+        resp = httplib.HTTPResponse(sock)
+        resp.begin()
+        self.assertEqual(resp.read(2), 'Te')
+        self.assertFalse(resp.isclosed())
+        self.assertEqual(resp.read(2), 'xt')
+        self.assertTrue(resp.isclosed())
+
     def test_host_port(self):
         # Check invalid host_port
 
@@ -133,7 +145,6 @@
         resp.begin()
         if resp.read() != "":
             self.fail("Did not expect response from HEAD request")
-        resp.close()
 
     def test_send_file(self):
         expected = 'GET /foo HTTP/1.1\r\nHost: example.com\r\n' \

Modified: python/branches/ctypes-branch/Lib/test/test_itertools.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_itertools.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_itertools.py	Tue Oct 23 20:47:50 2007
@@ -67,7 +67,10 @@
         c.next()
         self.assertEqual(c.next(), -8)
         for i in (-sys.maxint-5, -sys.maxint+5 ,-10, -1, 0, 10, sys.maxint-5, sys.maxint+5):
-            self.assertEqual(repr(count(i)), 'count(%r)' % i)
+            # Test repr (ignoring the L in longs)
+            r1 = repr(count(i)).replace('L', '')
+            r2 = 'count(%r)'.__mod__(i).replace('L', '')
+            self.assertEqual(r1, r2)
 
     def test_cycle(self):
         self.assertEqual(take(10, cycle('abc')), list('abcabcabca'))

Modified: python/branches/ctypes-branch/Lib/test/test_list.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_list.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_list.py	Tue Oct 23 20:47:50 2007
@@ -1,4 +1,5 @@
 import unittest
+import sys
 from test import test_support, list_tests
 
 class ListTest(list_tests.CommonTest):
@@ -18,6 +19,14 @@
         self.assertEqual(len([0]), 1)
         self.assertEqual(len([0, 1, 2]), 3)
 
+    def test_overflow(self):
+        lst = [4, 5, 6, 7]
+        n = int((sys.maxint*2+2) // len(lst))
+        def mul(a, b): return a * b
+        def imul(a, b): a *= b
+        self.assertRaises((MemoryError, OverflowError), mul, lst, n)
+        self.assertRaises((MemoryError, OverflowError), imul, lst, n)
+
 def test_main(verbose=None):
     test_support.run_unittest(ListTest)
 

Modified: python/branches/ctypes-branch/Lib/test/test_mmap.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_mmap.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_mmap.py	Tue Oct 23 20:47:50 2007
@@ -340,6 +340,50 @@
                     m[start:stop:step] = data
                     self.assertEquals(m[:], "".join(L))
 
+    def make_mmap_file (self, f, halfsize):
+        # Write 2 pages worth of data to the file
+        f.write ('\0' * halfsize)
+        f.write ('foo')
+        f.write ('\0' * (halfsize - 3))
+        f.flush ()
+        return mmap.mmap (f.fileno(), 0)
+
+    def test_offset (self):
+        f = open (TESTFN, 'w+b')
+
+        try: # unlink TESTFN no matter what
+            halfsize = mmap.ALLOCATIONGRANULARITY
+            m = self.make_mmap_file (f, halfsize)
+            m.close ()
+            f.close ()
+
+            mapsize = halfsize * 2
+            # Try invalid offset
+            f = open(TESTFN, "r+b")
+            for offset in [-2, -1, None]:
+                try:
+                    m = mmap.mmap(f.fileno(), mapsize, offset=offset)
+                    self.assertEqual(0, 1)
+                except (ValueError, TypeError, OverflowError):
+                    pass
+                else:
+                    self.assertEqual(0, 0)
+            f.close()
+
+            # Try valid offset, hopefully 8192 works on all OSes
+            f = open(TESTFN, "r+b")
+            m = mmap.mmap(f.fileno(), mapsize - halfsize, offset=halfsize)
+            self.assertEqual(m[0:3], 'foo')
+            f.close()
+            m.close()
+
+        finally:
+            f.close()
+            try:
+                os.unlink(TESTFN)
+            except OSError:
+                pass
+
 def test_main():
     run_unittest(MmapTests)
 

Modified: python/branches/ctypes-branch/Lib/test/test_support.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_support.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_support.py	Tue Oct 23 20:47:50 2007
@@ -100,10 +100,19 @@
     tests and we don't try multiple ports, the test can fails.  This
     makes the test more robust."""
 
-    # some random ports that hopefully no one is listening on.
-    for port in [preferred_port, 9907, 10243, 32999]:
+    # Find some random ports that hopefully no one is listening on.
+    # Ideally each test would clean up after itself and not continue listening
+    # on any ports.  However, this isn't the case.  The last port (0) is
+    # a stop-gap that asks the O/S to assign a port.  Whenever the warning
+    # message below is printed, the test that is listening on the port should
+    # be fixed to close the socket at the end of the test.
+    # Another reason why we can't use a port is another process (possibly
+    # another instance of the test suite) is using the same port.
+    for port in [preferred_port, 9907, 10243, 32999, 0]:
         try:
             sock.bind((host, port))
+            if port == 0:
+                port = sock.getsockname()[1]
             return port
         except socket.error, (err, msg):
             if err != errno.EADDRINUSE:
@@ -535,8 +544,7 @@
         elif len(result.failures) == 1 and not result.errors:
             err = result.failures[0][1]
         else:
-            msg = "errors occurred; run in verbose mode for details"
-            raise TestFailed(msg)
+            err = "errors occurred; run in verbose mode for details"
         raise TestFailed(err)
 
 

Modified: python/branches/ctypes-branch/Lib/test/test_zlib.py
==============================================================================
--- python/branches/ctypes-branch/Lib/test/test_zlib.py	(original)
+++ python/branches/ctypes-branch/Lib/test/test_zlib.py	Tue Oct 23 20:47:50 2007
@@ -42,14 +42,18 @@
 
 class ExceptionTestCase(unittest.TestCase):
     # make sure we generate some expected errors
-    def test_bigbits(self):
-        # specifying total bits too large causes an error
-        self.assertRaises(zlib.error,
-                zlib.compress, 'ERROR', zlib.MAX_WBITS + 1)
+    def test_badlevel(self):
+        # specifying compression level out of range causes an error
+        # (but -1 is Z_DEFAULT_COMPRESSION and apparently the zlib
+        # accepts 0 too)
+        self.assertRaises(zlib.error, zlib.compress, 'ERROR', 10)
 
     def test_badcompressobj(self):
         # verify failure on building compress object with bad params
         self.assertRaises(ValueError, zlib.compressobj, 1, zlib.DEFLATED, 0)
+        # specifying total bits too large causes an error
+        self.assertRaises(ValueError,
+                zlib.compressobj, 1, zlib.DEFLATED, zlib.MAX_WBITS + 1)
 
     def test_baddecompressobj(self):
         # verify failure on building decompress object with bad params

Modified: python/branches/ctypes-branch/Makefile.pre.in
==============================================================================
--- python/branches/ctypes-branch/Makefile.pre.in	(original)
+++ python/branches/ctypes-branch/Makefile.pre.in	Tue Oct 23 20:47:50 2007
@@ -475,7 +475,7 @@
 
 
 $(GRAMMAR_H) $(GRAMMAR_C): $(PGEN) $(GRAMMAR_INPUT)
-		-@ mkdir Include
+		-@$(INSTALL) -d Include
 		-$(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
 
 $(PGEN):	$(PGENOBJS)

Modified: python/branches/ctypes-branch/Misc/NEWS
==============================================================================
--- python/branches/ctypes-branch/Misc/NEWS	(original)
+++ python/branches/ctypes-branch/Misc/NEWS	Tue Oct 23 20:47:50 2007
@@ -272,6 +272,12 @@
 Library
 -------
 
+- ctypes will now work correctly on 32-bit systems when Python is
+  configured with --with-system-ffi.
+
+- Patch #1203: ctypes now does work on OS X when Python is built with
+  --disable-toolbox-glue
+
 - collections.deque() now supports a "maxlen" argument.
 
 - itertools.count() is no longer bounded to LONG_MAX.  Formerly, it raised
@@ -802,6 +808,13 @@
 
 - Bug #1721309: prevent bsddb module from freeing random memory.
 
+- Bug #1233: fix bsddb.dbshelve.DBShelf append method to work as
+  intended for RECNO databases.
+
+- Fix bsddb.dbtables: Don't randomly corrupt newly inserted rows by
+  picking a rowid string with null bytes in it.  Such rows could not
+  later be deleted, modified or individually selected.
+
 - Bug #1686475: Support stat'ing open files on Windows again.
 
 - Patch #1185447: binascii.b2a_qp() now correctly quotes binary characters
@@ -1060,6 +1073,8 @@
 - Conditionalize definition of _CRT_SECURE_NO_DEPRECATE
   and _CRT_NONSTDC_NO_DEPRECATE.
 
+- Bug #1216: Restore support for Visual Studio 2002.
+
 
 Mac
 ---

Modified: python/branches/ctypes-branch/Misc/developers.txt
==============================================================================
--- python/branches/ctypes-branch/Misc/developers.txt	(original)
+++ python/branches/ctypes-branch/Misc/developers.txt	Tue Oct 23 20:47:50 2007
@@ -17,6 +17,9 @@
 Permissions History
 -------------------
 
+- Chris Monson was given SVN access on 20 October 2007 by NCN,
+  for his work on editing PEPs.
+
 - Bill Janssen was given SVN access on 28 August 2007 by NCN,
   for his work on the SSL module and other things related to (SSL) sockets.
 

Modified: python/branches/ctypes-branch/Modules/_bsddb.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_bsddb.c	(original)
+++ python/branches/ctypes-branch/Modules/_bsddb.c	Tue Oct 23 20:47:50 2007
@@ -4765,7 +4765,7 @@
 {
     int err;
     DBT key;
-    PyObject *retval;
+    PyObject *retval = NULL;
     key.flags = DB_DBT_MALLOC;
     CHECK_SEQUENCE_NOT_CLOSED(self)
     MYDB_BEGIN_ALLOW_THREADS
@@ -5903,7 +5903,9 @@
     bsddb_api.dbenv_type      = &DBEnv_Type;
     bsddb_api.dbtxn_type      = &DBTxn_Type;
     bsddb_api.dblock_type     = &DBLock_Type;
+#if (DBVER >= 43)
     bsddb_api.dbsequence_type = &DBSequence_Type;
+#endif
     bsddb_api.makeDBError     = makeDBError;
 
     py_api = PyCObject_FromVoidPtr((void*)&bsddb_api, NULL);

Modified: python/branches/ctypes-branch/Modules/_collectionsmodule.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_collectionsmodule.c	(original)
+++ python/branches/ctypes-branch/Modules/_collectionsmodule.c	Tue Oct 23 20:47:50 2007
@@ -598,8 +598,11 @@
 static PyObject *
 deque_copy(PyObject *deque)
 {
-	return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "Oi",
-		deque, ((dequeobject *)deque)->maxlen, NULL);
+	if (((dequeobject *)deque)->maxlen == -1)
+		return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "O", deque, NULL);
+	else
+		return PyObject_CallFunction((PyObject *)(Py_Type(deque)), "Oi",
+			deque, ((dequeobject *)deque)->maxlen, NULL);
 }
 
 PyDoc_STRVAR(copy_doc, "Return a shallow copy of a deque.");
@@ -617,10 +620,17 @@
 		Py_XDECREF(dict);
 		return NULL;
 	}
-	if (dict == NULL)
-		result = Py_BuildValue("O(Oi)", Py_Type(deque), aslist, deque->maxlen);
-	else
-		result = Py_BuildValue("O(Oi)O", Py_Type(deque), aslist, deque->maxlen, dict);
+	if (dict == NULL) {
+		if (deque->maxlen == -1)
+			result = Py_BuildValue("O(O)", Py_Type(deque), aslist);
+		else
+			result = Py_BuildValue("O(Oi)", Py_Type(deque), aslist, deque->maxlen);
+	} else {
+		if (deque->maxlen == -1)
+			result = Py_BuildValue("O(OO)O", Py_Type(deque), aslist, Py_None, dict);
+		else
+			result = Py_BuildValue("O(Oi)O", Py_Type(deque), aslist, deque->maxlen, dict);
+	}
 	Py_XDECREF(dict);
 	Py_DECREF(aslist);
 	return result;
@@ -797,14 +807,20 @@
 deque_init(dequeobject *deque, PyObject *args, PyObject *kwdargs)
 {
 	PyObject *iterable = NULL;
+	PyObject *maxlenobj = NULL;
 	int maxlen = -1;
 	char *kwlist[] = {"iterable", "maxlen", 0};
 
-	if (!PyArg_ParseTupleAndKeywords(args, kwdargs, "|Oi:deque", kwlist, &iterable, &maxlen))
-		return -1;
-	if (maxlen < -1) {
-		PyErr_SetString(PyExc_ValueError, "maxlen must be -1 or greater");
+	if (!PyArg_ParseTupleAndKeywords(args, kwdargs, "|OO:deque", kwlist, &iterable, &maxlenobj))
 		return -1;
+	if (maxlenobj != NULL && maxlenobj != Py_None) {
+		maxlen = PyInt_AsLong(maxlenobj);
+		if (maxlen == -1 && PyErr_Occurred())
+			return -1;
+		if (maxlen < 0) {
+			PyErr_SetString(PyExc_ValueError, "maxlen must be non-negative");
+			return -1;
+		}
 	}
 	deque->maxlen = maxlen;
 	if (iterable != NULL) {

Modified: python/branches/ctypes-branch/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_ctypes/cfield.c	(original)
+++ python/branches/ctypes-branch/Modules/_ctypes/cfield.c	Tue Oct 23 20:47:50 2007
@@ -1616,17 +1616,21 @@
 /* XXX Hm, sizeof(int) == sizeof(long) doesn't hold on every platform */
 /* As soon as we can get rid of the type codes, this is no longer a problem */
 #if SIZEOF_LONG == 4
-	{ 'l', l_set, l_get, &ffi_type_sint, l_set_sw, l_get_sw},
-	{ 'L', L_set, L_get, &ffi_type_uint, L_set_sw, L_get_sw},
+	{ 'l', l_set, l_get, &ffi_type_sint32, l_set_sw, l_get_sw},
+	{ 'L', L_set, L_get, &ffi_type_uint32, L_set_sw, L_get_sw},
 #elif SIZEOF_LONG == 8
-	{ 'l', l_set, l_get, &ffi_type_slong, l_set_sw, l_get_sw},
-	{ 'L', L_set, L_get, &ffi_type_ulong, L_set_sw, L_get_sw},
+	{ 'l', l_set, l_get, &ffi_type_sint64, l_set_sw, l_get_sw},
+	{ 'L', L_set, L_get, &ffi_type_uint64, L_set_sw, L_get_sw},
 #else
 # error
 #endif
 #ifdef HAVE_LONG_LONG
-	{ 'q', q_set, q_get, &ffi_type_slong, q_set_sw, q_get_sw},
-	{ 'Q', Q_set, Q_get, &ffi_type_ulong, Q_set_sw, Q_get_sw},
+#if SIZEOF_LONG_LONG == 8
+	{ 'q', q_set, q_get, &ffi_type_sint64, q_set_sw, q_get_sw},
+	{ 'Q', Q_set, Q_get, &ffi_type_uint64, Q_set_sw, Q_get_sw},
+#else
+# error
+#endif
 #endif
 	{ 'P', P_set, P_get, &ffi_type_pointer},
 	{ 'z', z_set, z_get, &ffi_type_pointer},

Modified: python/branches/ctypes-branch/Modules/_ctypes/libffi/src/alpha/ffi.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_ctypes/libffi/src/alpha/ffi.c	(original)
+++ python/branches/ctypes-branch/Modules/_ctypes/libffi/src/alpha/ffi.c	Tue Oct 23 20:47:50 2007
@@ -28,7 +28,7 @@
 
 #include <stdlib.h>
 
-extern void ffi_call_osf(void *, unsigned long, unsigned, void *, void (*)());
+extern void ffi_call_osf(void *, unsigned long, unsigned, void *, void (*)(void));
 extern void ffi_closure_osf(void);
 
 
@@ -58,7 +58,7 @@
 }
 
 void
-ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
+ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 {
   unsigned long *stack, *argp;
   long i, avn;

Modified: python/branches/ctypes-branch/Modules/_ctypes/libffi/src/ia64/ffi.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_ctypes/libffi/src/ia64/ffi.c	(original)
+++ python/branches/ctypes-branch/Modules/_ctypes/libffi/src/ia64/ffi.c	Tue Oct 23 20:47:50 2007
@@ -259,10 +259,10 @@
   return FFI_OK;
 }
 
-extern int ffi_call_unix (struct ia64_args *, PTR64, void (*)(), UINT64);
+extern int ffi_call_unix (struct ia64_args *, PTR64, void (*)(void), UINT64);
 
 void
-ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
+ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 {
   struct ia64_args *stack;
   long i, avn, gpcount, fpcount;
@@ -387,7 +387,7 @@
    gp pointer to the closure.  This allows the function entry code to
    both retrieve the user data, and to restire the correct gp pointer.  */
 
-extern void ffi_closure_unix ();
+extern void ffi_closure_unix (void);
 
 ffi_status
 ffi_prep_closure (ffi_closure* closure,

Modified: python/branches/ctypes-branch/Modules/_ctypes/libffi/src/mips/ffi.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_ctypes/libffi/src/mips/ffi.c	(original)
+++ python/branches/ctypes-branch/Modules/_ctypes/libffi/src/mips/ffi.c	Tue Oct 23 20:47:50 2007
@@ -445,14 +445,14 @@
 /* Low level routine for calling O32 functions */
 extern int ffi_call_O32(void (*)(char *, extended_cif *, int, int), 
 			extended_cif *, unsigned, 
-			unsigned, unsigned *, void (*)());
+			unsigned, unsigned *, void (*)(void));
 
 /* Low level routine for calling N32 functions */
 extern int ffi_call_N32(void (*)(char *, extended_cif *, int, int), 
 			extended_cif *, unsigned, 
-			unsigned, unsigned *, void (*)());
+			unsigned, unsigned *, void (*)(void));
 
-void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 {
   extended_cif ecif;
 

Modified: python/branches/ctypes-branch/Modules/_ctypes/libffi/src/pa/ffi.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_ctypes/libffi/src/pa/ffi.c	(original)
+++ python/branches/ctypes-branch/Modules/_ctypes/libffi/src/pa/ffi.c	Tue Oct 23 20:47:50 2007
@@ -345,12 +345,12 @@
 			   /*@out@*/ extended_cif *,
 			   unsigned, unsigned,
 			   /*@out@*/ unsigned *,
-			   void (*fn)());
+			   void (*fn)(void));
 /*@=declundef@*/
 /*@=exportheader@*/
 
 void ffi_call(/*@dependent@*/ ffi_cif *cif,
-	      void (*fn)(),
+	      void (*fn)(void),
 	      /*@out@*/ void *rvalue,
 	      /*@dependent@*/ void **avalue)
 {

Modified: python/branches/ctypes-branch/Modules/_ctypes/libffi/src/powerpc/ffi.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_ctypes/libffi/src/powerpc/ffi.c	(original)
+++ python/branches/ctypes-branch/Modules/_ctypes/libffi/src/powerpc/ffi.c	Tue Oct 23 20:47:50 2007
@@ -756,17 +756,17 @@
 extern void ffi_call_SYSV(/*@out@*/ extended_cif *,
 			  unsigned, unsigned,
 			  /*@out@*/ unsigned *,
-			  void (*fn)());
+			  void (*fn)(void));
 extern void FFI_HIDDEN ffi_call_LINUX64(/*@out@*/ extended_cif *,
 					unsigned long, unsigned long,
 					/*@out@*/ unsigned long *,
-					void (*fn)());
+					void (*fn)(void));
 /*@=declundef@*/
 /*@=exportheader@*/
 
 void
 ffi_call(/*@dependent@*/ ffi_cif *cif,
-	 void (*fn)(),
+	 void (*fn)(void),
 	 /*@out@*/ void *rvalue,
 	 /*@dependent@*/ void **avalue)
 {

Modified: python/branches/ctypes-branch/Modules/_ctypes/libffi/src/s390/ffi.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_ctypes/libffi/src/s390/ffi.c	(original)
+++ python/branches/ctypes-branch/Modules/_ctypes/libffi/src/s390/ffi.c	Tue Oct 23 20:47:50 2007
@@ -88,7 +88,7 @@
 			  void (*)(unsigned char *, extended_cif *),
 			  unsigned,
 			  void *,
-			  void (*fn)());
+			  void (*fn)(void));
 
 extern void ffi_closure_SYSV(void);
  
@@ -480,7 +480,7 @@
  
 void
 ffi_call(ffi_cif *cif,
-	 void (*fn)(),
+	 void (*fn)(void),
 	 void *rvalue,
 	 void **avalue)
 {

Modified: python/branches/ctypes-branch/Modules/_ctypes/libffi/src/sparc/ffi.c
==============================================================================
--- python/branches/ctypes-branch/Modules/_ctypes/libffi/src/sparc/ffi.c	(original)
+++ python/branches/ctypes-branch/Modules/_ctypes/libffi/src/sparc/ffi.c	Tue Oct 23 20:47:50 2007
@@ -358,13 +358,13 @@
 
 #ifdef SPARC64
 extern int ffi_call_v9(void *, extended_cif *, unsigned, 
-		       unsigned, unsigned *, void (*fn)());
+		       unsigned, unsigned *, void (*fn)(void));
 #else
 extern int ffi_call_v8(void *, extended_cif *, unsigned, 
-		       unsigned, unsigned *, void (*fn)());
+		       unsigned, unsigned *, void (*fn)(void));
 #endif
 
-void ffi_call(ffi_cif *cif, void (*fn)(), void *rvalue, void **avalue)
+void ffi_call(ffi_cif *cif, void (*fn)(void), void *rvalue, void **avalue)
 {
   extended_cif ecif;
   void *rval = rvalue;

Modified: python/branches/ctypes-branch/Modules/main.c
==============================================================================
--- python/branches/ctypes-branch/Modules/main.c	(original)
+++ python/branches/ctypes-branch/Modules/main.c	Tue Oct 23 20:47:50 2007
@@ -416,6 +416,7 @@
 				if (fstat(fileno(fp), &sb) == 0 &&
 				    S_ISDIR(sb.st_mode)) {
 					fprintf(stderr, "%s: '%s' is a directory, cannot continue\n", argv[0], filename);
+					fclose(fp);
 					return 1;
 				}
 			}

Modified: python/branches/ctypes-branch/Modules/mmapmodule.c
==============================================================================
--- python/branches/ctypes-branch/Modules/mmapmodule.c	(original)
+++ python/branches/ctypes-branch/Modules/mmapmodule.c	Tue Oct 23 20:47:50 2007
@@ -3,6 +3,9 @@
  /  Hacked for Unix by AMK
  /  $Id$
 
+ / Modified to support mmap with offset - to map a 'window' of a file
+ /   Author:  Yotam Medini  yotamm at mellanox.co.il
+ /
  / mmapmodule.cpp -- map a view of a file into memory
  /
  / todo: need permission flags, perhaps a 'chsize' analog
@@ -31,6 +34,16 @@
 	GetSystemInfo(&si);
 	return si.dwPageSize;
 }
+
+static int
+my_getallocationgranularity (void)
+{
+
+	SYSTEM_INFO si;
+	GetSystemInfo(&si);
+	return si.dwAllocationGranularity;
+}
+
 #endif
 
 #ifdef UNIX
@@ -43,6 +56,8 @@
 {
 	return sysconf(_SC_PAGESIZE);
 }
+
+#define my_getallocationgranularity my_getpagesize
 #else
 #define my_getpagesize getpagesize
 #endif
@@ -74,7 +89,8 @@
 	PyObject_HEAD
 	char *	data;
 	size_t	size;
-	size_t	pos;
+	size_t	pos;    /* relative to offset */
+	size_t	offset; 
 
 #ifdef MS_WINDOWS
 	HANDLE	map_handle;
@@ -387,18 +403,22 @@
 #ifdef MS_WINDOWS
 	} else {
 		DWORD dwErrCode = 0;
-		DWORD newSizeLow, newSizeHigh;
+		DWORD off_hi, off_lo, newSizeLow, newSizeHigh;
 		/* First, unmap the file view */
 		UnmapViewOfFile(self->data);
 		/* Close the mapping object */
 		CloseHandle(self->map_handle);
 		/* Move to the desired EOF position */
 #if SIZEOF_SIZE_T > 4
-		newSizeHigh = (DWORD)(new_size >> 32);
-		newSizeLow = (DWORD)(new_size & 0xFFFFFFFF);
+		newSizeHigh = (DWORD)((self->offset + new_size) >> 32);
+		newSizeLow = (DWORD)((self->offset + new_size) & 0xFFFFFFFF);
+		off_hi = (DWORD)(self->offset >> 32);
+		off_lo = (DWORD)(self->offset & 0xFFFFFFFF);
 #else
 		newSizeHigh = 0;
 		newSizeLow = (DWORD)new_size;
+		off_hi = 0;
+		off_lo = (DWORD)self->offset;
 #endif
 		SetFilePointer(self->file_handle,
 			       newSizeLow, &newSizeHigh, FILE_BEGIN);
@@ -409,15 +429,15 @@
 			self->file_handle,
 			NULL,
 			PAGE_READWRITE,
-			newSizeHigh,
-			newSizeLow,
+			0,
+			0,
 			self->tagname);
 		if (self->map_handle != NULL) {
 			self->data = (char *) MapViewOfFile(self->map_handle,
 							    FILE_MAP_WRITE,
-							    0,
-							    0,
-							    0);
+							    off_hi,
+							    off_lo,
+							    new_size);
 			if (self->data != NULL) {
 				self->size = new_size;
 				Py_INCREF(Py_None);
@@ -962,15 +982,18 @@
    Returns -1 on error, with an appropriate Python exception raised. On
    success, the map size is returned. */
 static Py_ssize_t
-_GetMapSize(PyObject *o)
+_GetMapSize(PyObject *o, const char* param)
 {
+	if (o == NULL)
+		return 0;
 	if (PyIndex_Check(o)) {
 		Py_ssize_t i = PyNumber_AsSsize_t(o, PyExc_OverflowError);
 		if (i==-1 && PyErr_Occurred()) 
 			return -1;
 		if (i < 0) {	 
-			PyErr_SetString(PyExc_OverflowError,
-					"memory mapped size must be positive");
+			PyErr_Format(PyExc_OverflowError,
+					"memory mapped %s must be positive",
+                                        param);
 			return -1;
 		}
 		return i;
@@ -988,22 +1011,25 @@
 	struct stat st;
 #endif
 	mmap_object *m_obj;
-	PyObject *map_size_obj = NULL;
-	Py_ssize_t map_size;
+	PyObject *map_size_obj = NULL, *offset_obj = NULL;
+	Py_ssize_t map_size, offset;
 	int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ;
 	int devzero = -1;
 	int access = (int)ACCESS_DEFAULT;
 	static char *keywords[] = {"fileno", "length",
                                          "flags", "prot",
-                                         "access", NULL};
+                                         "access", "offset", NULL};
 
-	if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iii", keywords,
+	if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iiiO", keywords,
 					 &fd, &map_size_obj, &flags, &prot,
-                                         &access))
+                                         &access, &offset_obj))
 		return NULL;
-	map_size = _GetMapSize(map_size_obj);
+	map_size = _GetMapSize(map_size_obj, "size");
 	if (map_size < 0)
 		return NULL;
+        offset = _GetMapSize(offset_obj, "offset");
+        if (offset < 0)
+                return NULL;
 
 	if ((access != (int)ACCESS_DEFAULT) &&
 	    ((flags != MAP_SHARED) || (prot != (PROT_WRITE | PROT_READ))))
@@ -1038,7 +1064,7 @@
 	if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
 		if (map_size == 0) {
 			map_size = st.st_size;
-		} else if ((size_t)map_size > st.st_size) {
+		} else if ((size_t)offset + (size_t)map_size > st.st_size) {
 			PyErr_SetString(PyExc_ValueError,
 					"mmap length is greater than file size");
 			return NULL;
@@ -1050,6 +1076,7 @@
 	m_obj->data = NULL;
 	m_obj->size = (size_t) map_size;
 	m_obj->pos = (size_t) 0;
+        m_obj->offset = offset;
 	if (fd == -1) {
 		m_obj->fd = -1;
 		/* Assume the caller wants to map anonymous memory.
@@ -1076,10 +1103,10 @@
 			return NULL;
 		}
 	}
-
+	
 	m_obj->data = mmap(NULL, map_size,
 			   prot, flags,
-			   fd, 0);
+			   fd, offset);
 
 	if (devzero != -1) {
 		close(devzero);
@@ -1101,10 +1128,12 @@
 new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
 {
 	mmap_object *m_obj;
-	PyObject *map_size_obj = NULL;
-	Py_ssize_t map_size;
-	DWORD size_hi;	/* upper 32 bits of m_obj->size */
-	DWORD size_lo;	/* lower 32 bits of m_obj->size */
+	PyObject *map_size_obj = NULL, *offset_obj = NULL;
+	Py_ssize_t map_size, offset;
+	DWORD off_hi;	/* upper 32 bits of offset */
+	DWORD off_lo;	/* lower 32 bits of offset */
+	DWORD size_hi;	/* upper 32 bits of size */
+	DWORD size_lo;	/* lower 32 bits of size */
 	char *tagname = "";
 	DWORD dwErr = 0;
 	int fileno;
@@ -1113,11 +1142,11 @@
 	DWORD flProtect, dwDesiredAccess;
 	static char *keywords[] = { "fileno", "length",
                                           "tagname",
-                                          "access", NULL };
+                                          "access", "offset", NULL };
 
-	if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|zi", keywords,
+	if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|ziO", keywords,
 					 &fileno, &map_size_obj,
-					 &tagname, &access)) {
+					 &tagname, &access, &offset_obj)) {
 		return NULL;
 	}
 
@@ -1139,9 +1168,12 @@
 				    "mmap invalid access parameter.");
 	}
 
-	map_size = _GetMapSize(map_size_obj);
+	map_size = _GetMapSize(map_size_obj, "size");
 	if (map_size < 0)
 		return NULL;
+        offset = _GetMapSize(offset_obj, "offset");
+        if (offset < 0)
+                return NULL;
 
 	/* assume -1 and 0 both mean invalid filedescriptor
 	   to 'anonymously' map memory.
@@ -1170,6 +1202,7 @@
 	m_obj->file_handle = INVALID_HANDLE_VALUE;
 	m_obj->map_handle = INVALID_HANDLE_VALUE;
 	m_obj->tagname = NULL;
+	m_obj->offset = offset;
 
 	if (fh) {
 		/* It is necessary to duplicate the handle, so the
@@ -1238,12 +1271,18 @@
 	 * right by 32, so we need different code.
 	 */
 #if SIZEOF_SIZE_T > 4
-	size_hi = (DWORD)(m_obj->size >> 32);
-	size_lo = (DWORD)(m_obj->size & 0xFFFFFFFF);
+	size_hi = (DWORD)((offset + m_obj->size) >> 32);
+	size_lo = (DWORD)((offset + m_obj->size) & 0xFFFFFFFF);
+	off_hi = (DWORD)(offset >> 32);
+	off_lo = (DWORD)(offset & 0xFFFFFFFF);
 #else
 	size_hi = 0;
-	size_lo = (DWORD)m_obj->size;
+	size_lo = (DWORD)(offset + m_obj->size);
+	off_hi = 0;
+	off_lo = (DWORD)offset;
 #endif
+	/* For files, it would be sufficient to pass 0 as size.
+	   For anonymous maps, we have to pass the size explicitly. */
 	m_obj->map_handle = CreateFileMapping(m_obj->file_handle,
 					      NULL,
 					      flProtect,
@@ -1253,8 +1292,8 @@
 	if (m_obj->map_handle != NULL) {
 		m_obj->data = (char *) MapViewOfFile(m_obj->map_handle,
 						     dwDesiredAccess,
-						     0,
-						     0,
+						     off_hi,
+						     off_lo,
 						     0);
 		if (m_obj->data != NULL)
 			return (PyObject *)m_obj;
@@ -1329,6 +1368,8 @@
 
 	setint(dict, "PAGESIZE", (long)my_getpagesize());
 
+	setint(dict, "ALLOCATIONGRANULARITY", (long)my_getallocationgranularity()); 
+
 	setint(dict, "ACCESS_READ", ACCESS_READ);
 	setint(dict, "ACCESS_WRITE", ACCESS_WRITE);
 	setint(dict, "ACCESS_COPY", ACCESS_COPY);

Modified: python/branches/ctypes-branch/Objects/dictobject.c
==============================================================================
--- python/branches/ctypes-branch/Objects/dictobject.c	(original)
+++ python/branches/ctypes-branch/Objects/dictobject.c	Tue Oct 23 20:47:50 2007
@@ -9,8 +9,6 @@
 
 #include "Python.h"
 
-typedef PyDictEntry dictentry;
-typedef PyDictObject dictobject;
 
 /* Set a key error with the specified argument, wrapping it in a
  * tuple automatically so that tuple keys are not unpacked as the
@@ -121,7 +119,7 @@
 the same number of operations but without as much potential parallelism
 (e.g., computing 5*j can go on at the same time as computing 1+perturb in the
 above, and then shifting perturb can be done while the table index is being
-masked); and the dictobject struct required a member to hold the table's
+masked); and the PyDictObject struct required a member to hold the table's
 polynomial.  In Tim's experiments the current scheme ran faster, produced
 equally good collision statistics, needed less code & used less memory.
 
@@ -137,7 +135,7 @@
 */
 
 /* Object used as dummy key to fill deleted entries */
-static PyObject *dummy = NULL; /* Initialized by first call to newdictobject() */
+static PyObject *dummy = NULL; /* Initialized by first call to newPyDictObject() */
 
 #ifdef Py_REF_DEBUG
 PyObject *
@@ -148,8 +146,8 @@
 #endif
 
 /* forward declarations */
-static dictentry *
-lookdict_string(dictobject *mp, PyObject *key, long hash);
+static PyDictEntry *
+lookdict_string(PyDictObject *mp, PyObject *key, long hash);
 
 #ifdef SHOW_CONVERSION_COUNTS
 static long created = 0L;
@@ -192,7 +190,7 @@
 PyObject *
 PyDict_New(void)
 {
-	register dictobject *mp;
+	register PyDictObject *mp;
 	if (dummy == NULL) { /* Auto-initialize dummy */
 		dummy = PyString_FromString("<dummy key>");
 		if (dummy == NULL)
@@ -213,7 +211,7 @@
 		assert (mp->ma_table == mp->ma_smalltable);
 		assert (mp->ma_mask == PyDict_MINSIZE - 1);
 	} else {
-		mp = PyObject_GC_New(dictobject, &PyDict_Type);
+		mp = PyObject_GC_New(PyDictObject, &PyDict_Type);
 		if (mp == NULL)
 			return NULL;
 		EMPTY_TO_MINSIZE(mp);
@@ -245,20 +243,20 @@
 comparison raises an exception (this was new in Python 2.5).
 lookdict_string() below is specialized to string keys, comparison of which can
 never raise an exception; that function can never return NULL.  For both, when
-the key isn't found a dictentry* is returned for which the me_value field is
+the key isn't found a PyDictEntry* is returned for which the me_value field is
 NULL; this is the slot in the dict at which the key would have been found, and
 the caller can (if it wishes) add the <key, value> pair to the returned
-dictentry*.
+PyDictEntry*.
 */
-static dictentry *
-lookdict(dictobject *mp, PyObject *key, register long hash)
+static PyDictEntry *
+lookdict(PyDictObject *mp, PyObject *key, register long hash)
 {
 	register size_t i;
 	register size_t perturb;
-	register dictentry *freeslot;
+	register PyDictEntry *freeslot;
 	register size_t mask = (size_t)mp->ma_mask;
-	dictentry *ep0 = mp->ma_table;
-	register dictentry *ep;
+	PyDictEntry *ep0 = mp->ma_table;
+	register PyDictEntry *ep;
 	register int cmp;
 	PyObject *startkey;
 
@@ -334,15 +332,15 @@
  *
  * This is valuable because dicts with only string keys are very common.
  */
-static dictentry *
-lookdict_string(dictobject *mp, PyObject *key, register long hash)
+static PyDictEntry *
+lookdict_string(PyDictObject *mp, PyObject *key, register long hash)
 {
 	register size_t i;
 	register size_t perturb;
-	register dictentry *freeslot;
+	register PyDictEntry *freeslot;
 	register size_t mask = (size_t)mp->ma_mask;
-	dictentry *ep0 = mp->ma_table;
-	register dictentry *ep;
+	PyDictEntry *ep0 = mp->ma_table;
+	register PyDictEntry *ep;
 
 	/* Make sure this function doesn't have to handle non-string keys,
 	   including subclasses of str; e.g., one reason to subclass
@@ -393,10 +391,10 @@
 Returns -1 if an error occurred, or 0 on success.
 */
 static int
-insertdict(register dictobject *mp, PyObject *key, long hash, PyObject *value)
+insertdict(register PyDictObject *mp, PyObject *key, long hash, PyObject *value)
 {
 	PyObject *old_value;
-	register dictentry *ep;
+	register PyDictEntry *ep;
 	typedef PyDictEntry *(*lookupfunc)(PyDictObject *, PyObject *, long);
 
 	assert(mp->ma_lookup != NULL);
@@ -436,14 +434,14 @@
 is responsible for incref'ing `key` and `value`.
 */
 static void
-insertdict_clean(register dictobject *mp, PyObject *key, long hash,
+insertdict_clean(register PyDictObject *mp, PyObject *key, long hash,
 		 PyObject *value)
 {
 	register size_t i;
 	register size_t perturb;
 	register size_t mask = (size_t)mp->ma_mask;
-	dictentry *ep0 = mp->ma_table;
-	register dictentry *ep;
+	PyDictEntry *ep0 = mp->ma_table;
+	register PyDictEntry *ep;
 
 	i = hash & mask;
 	ep = &ep0[i];
@@ -465,13 +463,13 @@
 actually be smaller than the old one.
 */
 static int
-dictresize(dictobject *mp, Py_ssize_t minused)
+dictresize(PyDictObject *mp, Py_ssize_t minused)
 {
 	Py_ssize_t newsize;
-	dictentry *oldtable, *newtable, *ep;
+	PyDictEntry *oldtable, *newtable, *ep;
 	Py_ssize_t i;
 	int is_oldtable_malloced;
-	dictentry small_copy[PyDict_MINSIZE];
+	PyDictEntry small_copy[PyDict_MINSIZE];
 
 	assert(minused >= 0);
 
@@ -510,7 +508,7 @@
 		}
 	}
 	else {
-		newtable = PyMem_NEW(dictentry, newsize);
+		newtable = PyMem_NEW(PyDictEntry, newsize);
 		if (newtable == NULL) {
 			PyErr_NoMemory();
 			return -1;
@@ -521,7 +519,7 @@
 	assert(newtable != oldtable);
 	mp->ma_table = newtable;
 	mp->ma_mask = newsize - 1;
-	memset(newtable, 0, sizeof(dictentry) * newsize);
+	memset(newtable, 0, sizeof(PyDictEntry) * newsize);
 	mp->ma_used = 0;
 	i = mp->ma_fill;
 	mp->ma_fill = 0;
@@ -561,8 +559,8 @@
 PyDict_GetItem(PyObject *op, PyObject *key)
 {
 	long hash;
-	dictobject *mp = (dictobject *)op;
-	dictentry *ep;
+	PyDictObject *mp = (PyDictObject *)op;
+	PyDictEntry *ep;
 	PyThreadState *tstate;
 	if (!PyDict_Check(op))
 		return NULL;
@@ -609,7 +607,7 @@
 int
 PyDict_SetItem(register PyObject *op, PyObject *key, PyObject *value)
 {
-	register dictobject *mp;
+	register PyDictObject *mp;
 	register long hash;
 	register Py_ssize_t n_used;
 
@@ -619,7 +617,7 @@
 	}
 	assert(key);
 	assert(value);
-	mp = (dictobject *)op;
+	mp = (PyDictObject *)op;
 	if (PyString_CheckExact(key)) {
 		hash = ((PyStringObject *)key)->ob_shash;
 		if (hash == -1)
@@ -658,9 +656,9 @@
 int
 PyDict_DelItem(PyObject *op, PyObject *key)
 {
-	register dictobject *mp;
+	register PyDictObject *mp;
 	register long hash;
-	register dictentry *ep;
+	register PyDictEntry *ep;
 	PyObject *old_value, *old_key;
 
 	if (!PyDict_Check(op)) {
@@ -674,7 +672,7 @@
 		if (hash == -1)
 			return -1;
 	}
-	mp = (dictobject *)op;
+	mp = (PyDictObject *)op;
 	ep = (mp->ma_lookup)(mp, key, hash);
 	if (ep == NULL)
 		return -1;
@@ -696,18 +694,18 @@
 void
 PyDict_Clear(PyObject *op)
 {
-	dictobject *mp;
-	dictentry *ep, *table;
+	PyDictObject *mp;
+	PyDictEntry *ep, *table;
 	int table_is_malloced;
 	Py_ssize_t fill;
-	dictentry small_copy[PyDict_MINSIZE];
+	PyDictEntry small_copy[PyDict_MINSIZE];
 #ifdef Py_DEBUG
 	Py_ssize_t i, n;
 #endif
 
 	if (!PyDict_Check(op))
 		return;
-	mp = (dictobject *)op;
+	mp = (PyDictObject *)op;
 #ifdef Py_DEBUG
 	n = mp->ma_mask + 1;
 	i = 0;
@@ -782,15 +780,15 @@
 {
 	register Py_ssize_t i;
 	register Py_ssize_t mask;
-	register dictentry *ep;
+	register PyDictEntry *ep;
 
 	if (!PyDict_Check(op))
 		return 0;
 	i = *ppos;
 	if (i < 0)
 		return 0;
-	ep = ((dictobject *)op)->ma_table;
-	mask = ((dictobject *)op)->ma_mask;
+	ep = ((PyDictObject *)op)->ma_table;
+	mask = ((PyDictObject *)op)->ma_mask;
 	while (i <= mask && ep[i].me_value == NULL)
 		i++;
 	*ppos = i+1;
@@ -809,15 +807,15 @@
 {
 	register Py_ssize_t i;
 	register Py_ssize_t mask;
-	register dictentry *ep;
+	register PyDictEntry *ep;
 
 	if (!PyDict_Check(op))
 		return 0;
 	i = *ppos;
 	if (i < 0)
 		return 0;
-	ep = ((dictobject *)op)->ma_table;
-	mask = ((dictobject *)op)->ma_mask;
+	ep = ((PyDictObject *)op)->ma_table;
+	mask = ((PyDictObject *)op)->ma_mask;
 	while (i <= mask && ep[i].me_value == NULL)
 		i++;
 	*ppos = i+1;
@@ -834,9 +832,9 @@
 /* Methods */
 
 static void
-dict_dealloc(register dictobject *mp)
+dict_dealloc(register PyDictObject *mp)
 {
-	register dictentry *ep;
+	register PyDictEntry *ep;
 	Py_ssize_t fill = mp->ma_fill;
  	PyObject_GC_UnTrack(mp);
 	Py_TRASHCAN_SAFE_BEGIN(mp)
@@ -857,7 +855,7 @@
 }
 
 static int
-dict_print(register dictobject *mp, register FILE *fp, register int flags)
+dict_print(register PyDictObject *mp, register FILE *fp, register int flags)
 {
 	register Py_ssize_t i;
 	register Py_ssize_t any;
@@ -878,7 +876,7 @@
 	Py_END_ALLOW_THREADS
 	any = 0;
 	for (i = 0; i <= mp->ma_mask; i++) {
-		dictentry *ep = mp->ma_table + i;
+		PyDictEntry *ep = mp->ma_table + i;
 		PyObject *pvalue = ep->me_value;
 		if (pvalue != NULL) {
 			/* Prevent PyObject_Repr from deleting value during
@@ -913,7 +911,7 @@
 }
 
 static PyObject *
-dict_repr(dictobject *mp)
+dict_repr(PyDictObject *mp)
 {
 	Py_ssize_t i;
 	PyObject *s, *temp, *colon = NULL;
@@ -992,17 +990,17 @@
 }
 
 static Py_ssize_t
-dict_length(dictobject *mp)
+dict_length(PyDictObject *mp)
 {
 	return mp->ma_used;
 }
 
 static PyObject *
-dict_subscript(dictobject *mp, register PyObject *key)
+dict_subscript(PyDictObject *mp, register PyObject *key)
 {
 	PyObject *v;
 	long hash;
-	dictentry *ep;
+	PyDictEntry *ep;
 	assert(mp->ma_table != NULL);
 	if (!PyString_CheckExact(key) ||
 	    (hash = ((PyStringObject *) key)->ob_shash) == -1) {
@@ -1036,7 +1034,7 @@
 }
 
 static int
-dict_ass_sub(dictobject *mp, PyObject *v, PyObject *w)
+dict_ass_sub(PyDictObject *mp, PyObject *v, PyObject *w)
 {
 	if (w == NULL)
 		return PyDict_DelItem((PyObject *)mp, v);
@@ -1051,11 +1049,11 @@
 };
 
 static PyObject *
-dict_keys(register dictobject *mp)
+dict_keys(register PyDictObject *mp)
 {
 	register PyObject *v;
 	register Py_ssize_t i, j;
-	dictentry *ep;
+	PyDictEntry *ep;
 	Py_ssize_t mask, n;
 
   again:
@@ -1085,11 +1083,11 @@
 }
 
 static PyObject *
-dict_values(register dictobject *mp)
+dict_values(register PyDictObject *mp)
 {
 	register PyObject *v;
 	register Py_ssize_t i, j;
-	dictentry *ep;
+	PyDictEntry *ep;
 	Py_ssize_t mask, n;
 
   again:
@@ -1119,13 +1117,13 @@
 }
 
 static PyObject *
-dict_items(register dictobject *mp)
+dict_items(register PyDictObject *mp)
 {
 	register PyObject *v;
 	register Py_ssize_t i, j, n;
 	Py_ssize_t mask;
 	PyObject *item, *key, *value;
-	dictentry *ep;
+	PyDictEntry *ep;
 
 	/* Preallocate the list of tuples, to avoid allocations during
 	 * the loop over the items, which could trigger GC, which
@@ -1187,7 +1185,7 @@
 		return NULL;
 
 	if (PyDict_CheckExact(d) && PyAnySet_CheckExact(seq)) {
-		dictobject *mp = (dictobject *)d;
+		PyDictObject *mp = (PyDictObject *)d;
 		Py_ssize_t pos = 0;
 		PyObject *key;
 		long hash;
@@ -1351,7 +1349,7 @@
 {
 	register PyDictObject *mp, *other;
 	register Py_ssize_t i;
-	dictentry *entry;
+	PyDictEntry *entry;
 
 	/* We accept for the argument either a concrete dictionary object,
 	 * or an abstract "mapping" object.  For the former, we can do
@@ -1362,9 +1360,9 @@
 		PyErr_BadInternalCall();
 		return -1;
 	}
-	mp = (dictobject*)a;
+	mp = (PyDictObject*)a;
 	if (PyDict_CheckExact(b)) {
-		other = (dictobject*)b;
+		other = (PyDictObject*)b;
 		if (other == mp || other->ma_used == 0)
 			/* a.update(a) or a.update({}); nothing to do */
 			return 0;
@@ -1444,7 +1442,7 @@
 }
 
 static PyObject *
-dict_copy(register dictobject *mp)
+dict_copy(register PyDictObject *mp)
 {
 	return PyDict_Copy((PyObject*)mp);
 }
@@ -1474,7 +1472,7 @@
 		PyErr_BadInternalCall();
 		return -1;
 	}
-	return ((dictobject *)mp)->ma_used;
+	return ((PyDictObject *)mp)->ma_used;
 }
 
 PyObject *
@@ -1484,7 +1482,7 @@
 		PyErr_BadInternalCall();
 		return NULL;
 	}
-	return dict_keys((dictobject *)mp);
+	return dict_keys((PyDictObject *)mp);
 }
 
 PyObject *
@@ -1494,7 +1492,7 @@
 		PyErr_BadInternalCall();
 		return NULL;
 	}
-	return dict_values((dictobject *)mp);
+	return dict_values((PyDictObject *)mp);
 }
 
 PyObject *
@@ -1504,7 +1502,7 @@
 		PyErr_BadInternalCall();
 		return NULL;
 	}
-	return dict_items((dictobject *)mp);
+	return dict_items((PyDictObject *)mp);
 }
 
 /* Subroutine which returns the smallest key in a for which b's value
@@ -1516,7 +1514,7 @@
    them before the caller is done looking at them). */
 
 static PyObject *
-characterize(dictobject *a, dictobject *b, PyObject **pval)
+characterize(PyDictObject *a, PyDictObject *b, PyObject **pval)
 {
 	PyObject *akey = NULL; /* smallest key in a s.t. a[akey] != b[akey] */
 	PyObject *aval = NULL; /* a[akey] */
@@ -1590,7 +1588,7 @@
 }
 
 static int
-dict_compare(dictobject *a, dictobject *b)
+dict_compare(PyDictObject *a, PyDictObject *b)
 {
 	PyObject *adiff, *bdiff, *aval, *bval;
 	int res;
@@ -1642,7 +1640,7 @@
  * Uses only Py_EQ comparison.
  */
 static int
-dict_equal(dictobject *a, dictobject *b)
+dict_equal(PyDictObject *a, PyDictObject *b)
 {
 	Py_ssize_t i;
 
@@ -1687,7 +1685,7 @@
 		res = Py_NotImplemented;
 	}
 	else if (op == Py_EQ || op == Py_NE) {
-		cmp = dict_equal((dictobject *)v, (dictobject *)w);
+		cmp = dict_equal((PyDictObject *)v, (PyDictObject *)w);
 		if (cmp < 0)
 			return NULL;
 		res = (cmp == (op == Py_EQ)) ? Py_True : Py_False;
@@ -1699,10 +1697,10 @@
  }
 
 static PyObject *
-dict_contains(register dictobject *mp, PyObject *key)
+dict_contains(register PyDictObject *mp, PyObject *key)
 {
 	long hash;
-	dictentry *ep;
+	PyDictEntry *ep;
 
 	if (!PyString_CheckExact(key) ||
 	    (hash = ((PyStringObject *) key)->ob_shash) == -1) {
@@ -1717,7 +1715,7 @@
 }
 
 static PyObject *
-dict_has_key(register dictobject *mp, PyObject *key)
+dict_has_key(register PyDictObject *mp, PyObject *key)
 {
 	if (Py_Py3kWarningFlag &&
 	    PyErr_Warn(PyExc_DeprecationWarning, 
@@ -1727,13 +1725,13 @@
 }
 
 static PyObject *
-dict_get(register dictobject *mp, PyObject *args)
+dict_get(register PyDictObject *mp, PyObject *args)
 {
 	PyObject *key;
 	PyObject *failobj = Py_None;
 	PyObject *val = NULL;
 	long hash;
-	dictentry *ep;
+	PyDictEntry *ep;
 
 	if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &failobj))
 		return NULL;
@@ -1756,13 +1754,13 @@
 
 
 static PyObject *
-dict_setdefault(register dictobject *mp, PyObject *args)
+dict_setdefault(register PyDictObject *mp, PyObject *args)
 {
 	PyObject *key;
 	PyObject *failobj = Py_None;
 	PyObject *val = NULL;
 	long hash;
-	dictentry *ep;
+	PyDictEntry *ep;
 
 	if (!PyArg_UnpackTuple(args, "setdefault", 1, 2, &key, &failobj))
 		return NULL;
@@ -1788,17 +1786,17 @@
 
 
 static PyObject *
-dict_clear(register dictobject *mp)
+dict_clear(register PyDictObject *mp)
 {
 	PyDict_Clear((PyObject *)mp);
 	Py_RETURN_NONE;
 }
 
 static PyObject *
-dict_pop(dictobject *mp, PyObject *args)
+dict_pop(PyDictObject *mp, PyObject *args)
 {
 	long hash;
-	dictentry *ep;
+	PyDictEntry *ep;
 	PyObject *old_value, *old_key;
 	PyObject *key, *deflt = NULL;
 
@@ -1841,10 +1839,10 @@
 }
 
 static PyObject *
-dict_popitem(dictobject *mp)
+dict_popitem(PyDictObject *mp)
 {
 	Py_ssize_t i = 0;
-	dictentry *ep;
+	PyDictEntry *ep;
 	PyObject *res;
 
 	/* Allocate the result tuple before checking the size.  Believe it
@@ -1923,22 +1921,22 @@
 extern PyTypeObject PyDictIterKey_Type; /* Forward */
 extern PyTypeObject PyDictIterValue_Type; /* Forward */
 extern PyTypeObject PyDictIterItem_Type; /* Forward */
-static PyObject *dictiter_new(dictobject *, PyTypeObject *);
+static PyObject *dictiter_new(PyDictObject *, PyTypeObject *);
 
 static PyObject *
-dict_iterkeys(dictobject *dict)
+dict_iterkeys(PyDictObject *dict)
 {
 	return dictiter_new(dict, &PyDictIterKey_Type);
 }
 
 static PyObject *
-dict_itervalues(dictobject *dict)
+dict_itervalues(PyDictObject *dict)
 {
 	return dictiter_new(dict, &PyDictIterValue_Type);
 }
 
 static PyObject *
-dict_iteritems(dictobject *dict)
+dict_iteritems(PyDictObject *dict)
 {
 	return dictiter_new(dict, &PyDictIterItem_Type);
 }
@@ -2041,8 +2039,8 @@
 PyDict_Contains(PyObject *op, PyObject *key)
 {
 	long hash;
-	dictobject *mp = (dictobject *)op;
-	dictentry *ep;
+	PyDictObject *mp = (PyDictObject *)op;
+	PyDictEntry *ep;
 
 	if (!PyString_CheckExact(key) ||
 	    (hash = ((PyStringObject *) key)->ob_shash) == -1) {
@@ -2058,8 +2056,8 @@
 int
 _PyDict_Contains(PyObject *op, PyObject *key, long hash)
 {
-	dictobject *mp = (dictobject *)op;
-	dictentry *ep;
+	PyDictObject *mp = (PyDictObject *)op;
+	PyDictEntry *ep;
 
 	ep = (mp->ma_lookup)(mp, key, hash);
 	return ep == NULL ? -1 : (ep->me_value != NULL);
@@ -2113,7 +2111,7 @@
 }
 
 static PyObject *
-dict_iter(dictobject *dict)
+dict_iter(PyDictObject *dict)
 {
 	return dictiter_new(dict, &PyDictIterKey_Type);
 }
@@ -2132,7 +2130,7 @@
 PyTypeObject PyDict_Type = {
 	PyVarObject_HEAD_INIT(&PyType_Type, 0)
 	"dict",
-	sizeof(dictobject),
+	sizeof(PyDictObject),
 	0,
 	(destructor)dict_dealloc,		/* tp_dealloc */
 	(printfunc)dict_print,			/* tp_print */
@@ -2217,7 +2215,7 @@
 
 typedef struct {
 	PyObject_HEAD
-	dictobject *di_dict; /* Set to NULL when iterator is exhausted */
+	PyDictObject *di_dict; /* Set to NULL when iterator is exhausted */
 	Py_ssize_t di_used;
 	Py_ssize_t di_pos;
 	PyObject* di_result; /* reusable result tuple for iteritems */
@@ -2225,7 +2223,7 @@
 } dictiterobject;
 
 static PyObject *
-dictiter_new(dictobject *dict, PyTypeObject *itertype)
+dictiter_new(PyDictObject *dict, PyTypeObject *itertype)
 {
 	dictiterobject *di;
 	di = PyObject_New(dictiterobject, itertype);
@@ -2276,8 +2274,8 @@
 {
 	PyObject *key;
 	register Py_ssize_t i, mask;
-	register dictentry *ep;
-	dictobject *d = di->di_dict;
+	register PyDictEntry *ep;
+	PyDictObject *d = di->di_dict;
 
 	if (d == NULL)
 		return NULL;
@@ -2348,8 +2346,8 @@
 {
 	PyObject *value;
 	register Py_ssize_t i, mask;
-	register dictentry *ep;
-	dictobject *d = di->di_dict;
+	register PyDictEntry *ep;
+	PyDictObject *d = di->di_dict;
 
 	if (d == NULL)
 		return NULL;
@@ -2420,8 +2418,8 @@
 {
 	PyObject *key, *value, *result = di->di_result;
 	register Py_ssize_t i, mask;
-	register dictentry *ep;
-	dictobject *d = di->di_dict;
+	register PyDictEntry *ep;
+	PyDictObject *d = di->di_dict;
 
 	if (d == NULL)
 		return NULL;

Modified: python/branches/ctypes-branch/Objects/listobject.c
==============================================================================
--- python/branches/ctypes-branch/Objects/listobject.c	(original)
+++ python/branches/ctypes-branch/Objects/listobject.c	Tue Oct 23 20:47:50 2007
@@ -499,10 +499,10 @@
 	if (n < 0)
 		n = 0;
 	size = Py_Size(a) * n;
-	if (size == 0)
-              return PyList_New(0);
 	if (n && size/n != Py_Size(a))
 		return PyErr_NoMemory();
+	if (size == 0)
+              return PyList_New(0);
 	np = (PyListObject *) PyList_New(size);
 	if (np == NULL)
 		return NULL;
@@ -669,7 +669,7 @@
 list_inplace_repeat(PyListObject *self, Py_ssize_t n)
 {
 	PyObject **items;
-	Py_ssize_t size, i, j, p;
+	Py_ssize_t size, i, j, p, newsize;
 
 
 	size = PyList_GET_SIZE(self);
@@ -684,7 +684,10 @@
 		return (PyObject *)self;
 	}
 
-	if (list_resize(self, size*n) == -1)
+	newsize = size * n;
+	if (newsize/n != size)
+		return PyErr_NoMemory();
+	if (list_resize(self, newsize) == -1)
 		return NULL;
 
 	p = size;

Modified: python/branches/ctypes-branch/PC/pyconfig.h
==============================================================================
--- python/branches/ctypes-branch/PC/pyconfig.h	(original)
+++ python/branches/ctypes-branch/PC/pyconfig.h	Tue Oct 23 20:47:50 2007
@@ -377,11 +377,11 @@
    define these.
    If some compiler does not provide them, modify the #if appropriately. */
 #if defined(_MSC_VER)
-#if _MSC_VER > 1201
+#if _MSC_VER > 1300
 #define HAVE_UINTPTR_T 1
 #define HAVE_INTPTR_T 1
 #else
-/* VC6 & eVC4 don't support the C99 LL suffix for 64-bit integer literals */
+/* VC6, VS 2002 and eVC4 don't support the C99 LL suffix for 64-bit integer literals */
 #define Py_LL(x) x##I64
 #endif  /* _MSC_VER > 1200  */
 #endif  /* _MSC_VER */

Modified: python/branches/ctypes-branch/Parser/pgen.c
==============================================================================
--- python/branches/ctypes-branch/Parser/pgen.c	(original)
+++ python/branches/ctypes-branch/Parser/pgen.c	Tue Oct 23 20:47:50 2007
@@ -124,7 +124,7 @@
 	
 	nf = newnfa(name);
 	gr->gr_nfa = (nfa **)PyObject_REALLOC(gr->gr_nfa,
-				      sizeof(nfa) * (gr->gr_nnfas + 1));
+				      sizeof(nfa*) * (gr->gr_nnfas + 1));
 	if (gr->gr_nfa == NULL)
 		Py_FatalError("out of mem");
 	gr->gr_nfa[gr->gr_nnfas++] = nf;
@@ -487,6 +487,7 @@
 	convert(d, xx_nstates, xx_state);
 	
 	/* XXX cleanup */
+	PyObject_FREE(xx_state);
 }
 
 static void

Modified: python/branches/ctypes-branch/Parser/tokenizer.c
==============================================================================
--- python/branches/ctypes-branch/Parser/tokenizer.c	(original)
+++ python/branches/ctypes-branch/Parser/tokenizer.c	Tue Oct 23 20:47:50 2007
@@ -1542,7 +1542,7 @@
 		Py_DECREF(unicode_text);
 	}
 	if (!ret) {
-		PyErr_Print();
+		PyErr_Clear();
 	}
 	return ret;
 }

Modified: python/branches/ctypes-branch/Python/marshal.c
==============================================================================
--- python/branches/ctypes-branch/Python/marshal.c	(original)
+++ python/branches/ctypes-branch/Python/marshal.c	Tue Oct 23 20:47:50 2007
@@ -1013,6 +1013,7 @@
 	RFILE rf;
 	rf.fp = fp;
 	rf.strings = NULL;
+	rf.ptr = rf.end = NULL;
 	return r_long(&rf);
 }
 
@@ -1086,6 +1087,7 @@
 	rf.fp = fp;
 	rf.strings = PyList_New(0);
 	rf.depth = 0;
+	rf.ptr = rf.end = NULL;
 	result = r_object(&rf);
 	Py_DECREF(rf.strings);
 	return result;

Modified: python/branches/ctypes-branch/setup.py
==============================================================================
--- python/branches/ctypes-branch/setup.py	(original)
+++ python/branches/ctypes-branch/setup.py	Tue Oct 23 20:47:50 2007
@@ -660,7 +660,7 @@
         #  http://www.oracle.com/database/berkeley-db/db/index.html
         #
         # This requires the Sleepycat^WOracle DB code. The supported versions
-        # are set below.  Visit http://www.sleepycat.com/ to download
+        # are set below.  Visit the URL above to download
         # a release.  Most open source OSes come with one or more
         # versions of BerkeleyDB already installed.
 


More information about the Python-checkins mailing list