[Python-checkins] r51030 - in python/branches/bcannon-sandboxing: Doc/Makefile.deps Doc/api/api.tex Doc/api/concrete.tex Doc/api/exceptions.tex Doc/api/intro.tex Doc/api/refcounts.dat Doc/commontex/boilerplate.tex Doc/dist/dist.tex Doc/doc/doc.tex Doc/ext/newtypes.tex Doc/ext/windows.tex Doc/howto/doanddont.tex Doc/inst/inst.tex Doc/lib/email.tex Doc/lib/emailgenerator.tex Doc/lib/lib.tex Doc/lib/libanydbm.tex Doc/lib/libbase64.tex Doc/lib/libbinascii.tex Doc/lib/libbsddb.tex Doc/lib/libcompileall.tex Doc/lib/libcookielib.tex Doc/lib/libcsv.tex Doc/lib/libctypes.tex Doc/lib/libetree.tex Doc/lib/libfuncs.tex Doc/lib/libgettext.tex Doc/lib/libimp.tex Doc/lib/libinspect.tex Doc/lib/liblogging.tex Doc/lib/libmailbox.tex Doc/lib/libmimetypes.tex Doc/lib/libnew.tex Doc/lib/liboptparse.tex Doc/lib/libossaudiodev.tex Doc/lib/libpickle.tex Doc/lib/libpkgutil.tex Doc/lib/libposixpath.tex Doc/lib/librandom.tex Doc/lib/libre.tex Doc/lib/libreadline.tex Doc/lib/librunpy.tex Doc/lib/libshelve.tex Doc/lib/libsocket.tex Doc/lib/libsocksvr.tex Doc/lib/libsqlite3.tex Doc/lib/libstdtypes.tex Doc/lib/libstringio.tex Doc/lib/libsubprocess.tex Doc/lib/libsys.tex Doc/lib/libtime.tex Doc/lib/libturtle.tex Doc/lib/libtypes.tex Doc/lib/libundoc.tex Doc/lib/libunicodedata.tex Doc/lib/liburllib.tex Doc/lib/liburllib2.tex Doc/lib/libuuid.tex Doc/lib/libwarnings.tex Doc/lib/libweakref.tex Doc/lib/libwebbrowser.tex Doc/lib/libzipfile.tex Doc/lib/sqlite3/complete_statement.py Doc/lib/tkinter.tex Doc/mac/libmacfs.tex Doc/mac/libmacos.tex Doc/mac/using.tex Doc/ref/ref3.tex Doc/tut/tut.tex Doc/whatsnew/whatsnew20.tex Doc/whatsnew/whatsnew21.tex Doc/whatsnew/whatsnew23.tex Doc/whatsnew/whatsnew24.tex Doc/whatsnew/whatsnew25.tex Include/patchlevel.h Include/pyerrors.h Include/pystate.h Lib/binhex.py Lib/bsddb/test/test_basics.py Lib/compiler/future.py Lib/compiler/transformer.py Lib/ctypes/__init__.py Lib/ctypes/test/test_parameters.py Lib/ctypes/test/test_pointers.py Lib/ctypes/test/test_structures.py Lib/ctypes/test/test_varsize_struct.py Lib/ctypes/test/test_win32.py Lib/ctypes/util.py Lib/distutils/__init__.py Lib/distutils/command/upload.py Lib/distutils/msvccompiler.py Lib/doctest.py Lib/email/__init__.py Lib/email/message.py Lib/email/test/test_email.py Lib/email/test/test_email_renamed.py Lib/email/utils.py Lib/httplib.py Lib/idlelib/CREDITS.txt Lib/idlelib/CallTipWindow.py Lib/idlelib/CallTips.py Lib/idlelib/CodeContext.py Lib/idlelib/ColorDelegator.py Lib/idlelib/EditorWindow.py Lib/idlelib/NEWS.txt Lib/idlelib/ParenMatch.py Lib/idlelib/PyShell.py Lib/idlelib/ScriptBinding.py Lib/idlelib/config-keys.def Lib/idlelib/idlever.py Lib/idlelib/keybindingDialog.py Lib/idlelib/macosxSupport.py Lib/inspect.py Lib/lib-tk/Tkinter.py Lib/lib-tk/turtle.py Lib/logging/handlers.py Lib/mailbox.py Lib/msilib/__init__.py Lib/optparse.py Lib/os.py Lib/pdb.py Lib/pkgutil.py Lib/popen2.py Lib/pydoc.py Lib/runpy.py Lib/shutil.py Lib/socket.py Lib/struct.py Lib/subprocess.py Lib/tarfile.py Lib/test/crashers/bogus_code_obj.py Lib/test/crashers/borrowed_ref_1.py Lib/test/crashers/borrowed_ref_2.py Lib/test/crashers/gc_inspection.py Lib/test/crashers/recursion_limit_too_high.py Lib/test/crashers/recursive_call.py Lib/test/fork_wait.py Lib/test/output/test_ossaudiodev Lib/test/string_tests.py Lib/test/test_ast.py Lib/test/test_bsddb.py Lib/test/test_compile.py Lib/test/test_compiler.py Lib/test/test_defaultdict.py Lib/test/test_dis.py Lib/test/test_doctest.py Lib/test/test_email_codecs.py Lib/test/test_filecmp.py Lib/test/test_fork1.py Lib/test/test_generators.py Lib/test/test_getargs2.py Lib/test/test_grammar.py Lib/test/test_inspect.py Lib/test/test_iterlen.py Lib/test/test_mailbox.py Lib/test/test_mimetools.py Lib/test/test_mimetypes.py Lib/test/test_minidom.py Lib/test/test_multibytecodec.py Lib/test/test_optparse.py Lib/test/test_ossaudiodev.py Lib/test/test_runpy.py Lib/test/test_sax.py Lib/test/test_scope.py Lib/test/test_shutil.py Lib/test/test_signal.py Lib/test/test_subprocess.py Lib/test/test_sys.py Lib/test/test_time.py Lib/test/test_traceback.py Lib/test/test_urllib2.py Lib/test/test_uuid.py Lib/test/test_wait3.py Lib/test/test_wait4.py Lib/test/test_winreg.py Lib/test/test_xml_etree.py Lib/test/test_xml_etree_c.py Lib/traceback.py Lib/types.py Lib/urllib.py Lib/urllib2.py Lib/uuid.py Lib/warnings.py Lib/xml Lib/xml.py Lib/xml/dom Lib/xml/parsers Lib/xml/sax Lib/xmlcore Lib/zipfile.py Mac/BuildScript/scripts/postflight.patch-profile Mac/IDLE/config-main.def Mac/Modules/MacOS.c Mac/Modules/macosmodule.c Mac/PythonLauncher/FileSettings.m Makefile.pre.in Misc/ACKS Misc/NEWS Misc/RPM/python-2.5.spec Misc/build.sh Misc/python-config.in Modules/_bsddb.c Modules/_ctypes/_ctypes.c Modules/_ctypes/callbacks.c Modules/_ctypes/callproc.c Modules/_ctypes/cfield.c Modules/_ctypes/ctypes.h Modules/_ctypes/libffi/configure Modules/_ctypes/libffi/configure.ac Modules/_ctypes/stgdict.c Modules/_cursesmodule.c Modules/_sqlite/cursor.c Modules/_sqlite/util.c Modules/_sqlite/util.h Modules/_ssl.c Modules/_struct.c Modules/_testcapimodule.c Modules/_tkinter.c Modules/_typesmodule.c Modules/bz2module.c Modules/cPickle.c Modules/collectionsmodule.c Modules/config.c.in Modules/cryptmodule.c Modules/dlmodule.c Modules/expat/xmlparse.c Modules/fcntlmodule.c Modules/fpectlmodule.c Modules/getpath.c Modules/itertoolsmodule.c Modules/main.c Modules/posixmodule.c Modules/pyexpat.c Modules/readline.c Modules/selectmodule.c Modules/socketmodule.c Modules/timemodule.c Modules/unicodedata.c Objects/codeobject.c Objects/complexobject.c Objects/dictobject.c Objects/fileobject.c Objects/frameobject.c Objects/funcobject.c Objects/listsort.txt Objects/longobject.c Objects/setobject.c Objects/stringobject.c Objects/typeobject.c Objects/unicodeobject.c PC/_winreg.c PC/config.c PC/getpathp.c PC/os2emx/Makefile PC/os2emx/README.os2emx PC/os2emx/config.c PC/os2emx/pyconfig.h PC/os2emx/python24.def PC/os2emx/python25.def PC/winsound.c PCbuild/_ssl.vcproj PCbuild/build_ssl.bat PCbuild/build_ssl.py PCbuild/pythoncore.vcproj PCbuild/readme.txt Python/ast.c Python/compile.c Python/errors.c Python/future.c Python/getargs.c Python/getopt.c Python/import.c Python/mactoolboxglue.c Python/mystrtoul.c Python/pyarena.c Python/pystate.c Python/pythonrun.c Python/symtable.c Python/sysmodule.c Python/thread.c Python/thread_os2.h README Tools/buildbot/kill_python.c Tools/faqwiz/faqw.py Tools/msi Tools/msi/msi.py Tools/msi/uuids.py Tools/scripts/README Tools/webchecker/webchecker.py configure configure.in

brett.cannon python-checkins at python.org
Wed Aug 2 00:52:37 CEST 2006


Author: brett.cannon
Date: Wed Aug  2 00:51:44 2006
New Revision: 51030

Added:
   python/branches/bcannon-sandboxing/Doc/lib/libetree.tex
      - copied unchanged from r51028, python/trunk/Doc/lib/libetree.tex
   python/branches/bcannon-sandboxing/Lib/test/crashers/borrowed_ref_1.py
      - copied unchanged from r51028, python/trunk/Lib/test/crashers/borrowed_ref_1.py
   python/branches/bcannon-sandboxing/Lib/test/crashers/borrowed_ref_2.py
      - copied unchanged from r51028, python/trunk/Lib/test/crashers/borrowed_ref_2.py
   python/branches/bcannon-sandboxing/Lib/test/crashers/recursion_limit_too_high.py
      - copied unchanged from r51028, python/trunk/Lib/test/crashers/recursion_limit_too_high.py
   python/branches/bcannon-sandboxing/Lib/xml/   (props changed)
      - copied from r51028, python/trunk/Lib/xml/
   python/branches/bcannon-sandboxing/Mac/Modules/MacOS.c
      - copied unchanged from r51028, python/trunk/Mac/Modules/MacOS.c
   python/branches/bcannon-sandboxing/Modules/_typesmodule.c
      - copied unchanged from r51028, python/trunk/Modules/_typesmodule.c
   python/branches/bcannon-sandboxing/PC/os2emx/python25.def
      - copied unchanged from r51028, python/trunk/PC/os2emx/python25.def
   python/branches/bcannon-sandboxing/PCbuild/build_ssl.bat
      - copied unchanged from r51028, python/trunk/PCbuild/build_ssl.bat
Removed:
   python/branches/bcannon-sandboxing/Lib/xml.py
   python/branches/bcannon-sandboxing/Lib/xmlcore/
   python/branches/bcannon-sandboxing/Mac/Modules/macosmodule.c
   python/branches/bcannon-sandboxing/PC/os2emx/python24.def
Modified:
   python/branches/bcannon-sandboxing/   (props changed)
   python/branches/bcannon-sandboxing/Doc/Makefile.deps
   python/branches/bcannon-sandboxing/Doc/api/api.tex
   python/branches/bcannon-sandboxing/Doc/api/concrete.tex
   python/branches/bcannon-sandboxing/Doc/api/exceptions.tex
   python/branches/bcannon-sandboxing/Doc/api/intro.tex
   python/branches/bcannon-sandboxing/Doc/api/refcounts.dat
   python/branches/bcannon-sandboxing/Doc/commontex/boilerplate.tex
   python/branches/bcannon-sandboxing/Doc/dist/dist.tex
   python/branches/bcannon-sandboxing/Doc/doc/doc.tex
   python/branches/bcannon-sandboxing/Doc/ext/newtypes.tex
   python/branches/bcannon-sandboxing/Doc/ext/windows.tex
   python/branches/bcannon-sandboxing/Doc/howto/doanddont.tex
   python/branches/bcannon-sandboxing/Doc/inst/inst.tex
   python/branches/bcannon-sandboxing/Doc/lib/email.tex
   python/branches/bcannon-sandboxing/Doc/lib/emailgenerator.tex
   python/branches/bcannon-sandboxing/Doc/lib/lib.tex
   python/branches/bcannon-sandboxing/Doc/lib/libanydbm.tex
   python/branches/bcannon-sandboxing/Doc/lib/libbase64.tex
   python/branches/bcannon-sandboxing/Doc/lib/libbinascii.tex
   python/branches/bcannon-sandboxing/Doc/lib/libbsddb.tex
   python/branches/bcannon-sandboxing/Doc/lib/libcompileall.tex
   python/branches/bcannon-sandboxing/Doc/lib/libcookielib.tex
   python/branches/bcannon-sandboxing/Doc/lib/libcsv.tex
   python/branches/bcannon-sandboxing/Doc/lib/libctypes.tex
   python/branches/bcannon-sandboxing/Doc/lib/libfuncs.tex
   python/branches/bcannon-sandboxing/Doc/lib/libgettext.tex
   python/branches/bcannon-sandboxing/Doc/lib/libimp.tex
   python/branches/bcannon-sandboxing/Doc/lib/libinspect.tex
   python/branches/bcannon-sandboxing/Doc/lib/liblogging.tex
   python/branches/bcannon-sandboxing/Doc/lib/libmailbox.tex
   python/branches/bcannon-sandboxing/Doc/lib/libmimetypes.tex
   python/branches/bcannon-sandboxing/Doc/lib/libnew.tex
   python/branches/bcannon-sandboxing/Doc/lib/liboptparse.tex
   python/branches/bcannon-sandboxing/Doc/lib/libossaudiodev.tex
   python/branches/bcannon-sandboxing/Doc/lib/libpickle.tex
   python/branches/bcannon-sandboxing/Doc/lib/libpkgutil.tex
   python/branches/bcannon-sandboxing/Doc/lib/libposixpath.tex
   python/branches/bcannon-sandboxing/Doc/lib/librandom.tex
   python/branches/bcannon-sandboxing/Doc/lib/libre.tex
   python/branches/bcannon-sandboxing/Doc/lib/libreadline.tex
   python/branches/bcannon-sandboxing/Doc/lib/librunpy.tex
   python/branches/bcannon-sandboxing/Doc/lib/libshelve.tex
   python/branches/bcannon-sandboxing/Doc/lib/libsocket.tex
   python/branches/bcannon-sandboxing/Doc/lib/libsocksvr.tex
   python/branches/bcannon-sandboxing/Doc/lib/libsqlite3.tex
   python/branches/bcannon-sandboxing/Doc/lib/libstdtypes.tex
   python/branches/bcannon-sandboxing/Doc/lib/libstringio.tex
   python/branches/bcannon-sandboxing/Doc/lib/libsubprocess.tex
   python/branches/bcannon-sandboxing/Doc/lib/libsys.tex
   python/branches/bcannon-sandboxing/Doc/lib/libtime.tex
   python/branches/bcannon-sandboxing/Doc/lib/libturtle.tex
   python/branches/bcannon-sandboxing/Doc/lib/libtypes.tex
   python/branches/bcannon-sandboxing/Doc/lib/libundoc.tex
   python/branches/bcannon-sandboxing/Doc/lib/libunicodedata.tex
   python/branches/bcannon-sandboxing/Doc/lib/liburllib.tex
   python/branches/bcannon-sandboxing/Doc/lib/liburllib2.tex
   python/branches/bcannon-sandboxing/Doc/lib/libuuid.tex
   python/branches/bcannon-sandboxing/Doc/lib/libwarnings.tex
   python/branches/bcannon-sandboxing/Doc/lib/libweakref.tex
   python/branches/bcannon-sandboxing/Doc/lib/libwebbrowser.tex
   python/branches/bcannon-sandboxing/Doc/lib/libzipfile.tex
   python/branches/bcannon-sandboxing/Doc/lib/sqlite3/complete_statement.py
   python/branches/bcannon-sandboxing/Doc/lib/tkinter.tex
   python/branches/bcannon-sandboxing/Doc/mac/libmacfs.tex
   python/branches/bcannon-sandboxing/Doc/mac/libmacos.tex
   python/branches/bcannon-sandboxing/Doc/mac/using.tex
   python/branches/bcannon-sandboxing/Doc/ref/ref3.tex
   python/branches/bcannon-sandboxing/Doc/tut/tut.tex
   python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew20.tex
   python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew21.tex
   python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew23.tex
   python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew24.tex
   python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew25.tex
   python/branches/bcannon-sandboxing/Include/patchlevel.h
   python/branches/bcannon-sandboxing/Include/pyerrors.h
   python/branches/bcannon-sandboxing/Include/pystate.h
   python/branches/bcannon-sandboxing/Lib/binhex.py
   python/branches/bcannon-sandboxing/Lib/bsddb/test/test_basics.py
   python/branches/bcannon-sandboxing/Lib/compiler/future.py
   python/branches/bcannon-sandboxing/Lib/compiler/transformer.py
   python/branches/bcannon-sandboxing/Lib/ctypes/__init__.py
   python/branches/bcannon-sandboxing/Lib/ctypes/test/test_parameters.py
   python/branches/bcannon-sandboxing/Lib/ctypes/test/test_pointers.py
   python/branches/bcannon-sandboxing/Lib/ctypes/test/test_structures.py
   python/branches/bcannon-sandboxing/Lib/ctypes/test/test_varsize_struct.py
   python/branches/bcannon-sandboxing/Lib/ctypes/test/test_win32.py
   python/branches/bcannon-sandboxing/Lib/ctypes/util.py
   python/branches/bcannon-sandboxing/Lib/distutils/__init__.py
   python/branches/bcannon-sandboxing/Lib/distutils/command/upload.py
   python/branches/bcannon-sandboxing/Lib/distutils/msvccompiler.py
   python/branches/bcannon-sandboxing/Lib/doctest.py
   python/branches/bcannon-sandboxing/Lib/email/__init__.py
   python/branches/bcannon-sandboxing/Lib/email/message.py
   python/branches/bcannon-sandboxing/Lib/email/test/test_email.py
   python/branches/bcannon-sandboxing/Lib/email/test/test_email_renamed.py
   python/branches/bcannon-sandboxing/Lib/email/utils.py
   python/branches/bcannon-sandboxing/Lib/httplib.py
   python/branches/bcannon-sandboxing/Lib/idlelib/CREDITS.txt
   python/branches/bcannon-sandboxing/Lib/idlelib/CallTipWindow.py
   python/branches/bcannon-sandboxing/Lib/idlelib/CallTips.py
   python/branches/bcannon-sandboxing/Lib/idlelib/CodeContext.py
   python/branches/bcannon-sandboxing/Lib/idlelib/ColorDelegator.py
   python/branches/bcannon-sandboxing/Lib/idlelib/EditorWindow.py
   python/branches/bcannon-sandboxing/Lib/idlelib/NEWS.txt
   python/branches/bcannon-sandboxing/Lib/idlelib/ParenMatch.py
   python/branches/bcannon-sandboxing/Lib/idlelib/PyShell.py
   python/branches/bcannon-sandboxing/Lib/idlelib/ScriptBinding.py
   python/branches/bcannon-sandboxing/Lib/idlelib/config-keys.def
   python/branches/bcannon-sandboxing/Lib/idlelib/idlever.py
   python/branches/bcannon-sandboxing/Lib/idlelib/keybindingDialog.py
   python/branches/bcannon-sandboxing/Lib/idlelib/macosxSupport.py
   python/branches/bcannon-sandboxing/Lib/inspect.py
   python/branches/bcannon-sandboxing/Lib/lib-tk/Tkinter.py
   python/branches/bcannon-sandboxing/Lib/lib-tk/turtle.py
   python/branches/bcannon-sandboxing/Lib/logging/handlers.py
   python/branches/bcannon-sandboxing/Lib/mailbox.py
   python/branches/bcannon-sandboxing/Lib/msilib/__init__.py
   python/branches/bcannon-sandboxing/Lib/optparse.py
   python/branches/bcannon-sandboxing/Lib/os.py
   python/branches/bcannon-sandboxing/Lib/pdb.py
   python/branches/bcannon-sandboxing/Lib/pkgutil.py
   python/branches/bcannon-sandboxing/Lib/popen2.py
   python/branches/bcannon-sandboxing/Lib/pydoc.py
   python/branches/bcannon-sandboxing/Lib/runpy.py
   python/branches/bcannon-sandboxing/Lib/shutil.py
   python/branches/bcannon-sandboxing/Lib/socket.py
   python/branches/bcannon-sandboxing/Lib/struct.py
   python/branches/bcannon-sandboxing/Lib/subprocess.py
   python/branches/bcannon-sandboxing/Lib/tarfile.py
   python/branches/bcannon-sandboxing/Lib/test/crashers/bogus_code_obj.py
   python/branches/bcannon-sandboxing/Lib/test/crashers/gc_inspection.py
   python/branches/bcannon-sandboxing/Lib/test/crashers/recursive_call.py
   python/branches/bcannon-sandboxing/Lib/test/fork_wait.py
   python/branches/bcannon-sandboxing/Lib/test/output/test_ossaudiodev
   python/branches/bcannon-sandboxing/Lib/test/string_tests.py
   python/branches/bcannon-sandboxing/Lib/test/test_ast.py
   python/branches/bcannon-sandboxing/Lib/test/test_bsddb.py
   python/branches/bcannon-sandboxing/Lib/test/test_compile.py
   python/branches/bcannon-sandboxing/Lib/test/test_compiler.py
   python/branches/bcannon-sandboxing/Lib/test/test_defaultdict.py
   python/branches/bcannon-sandboxing/Lib/test/test_dis.py
   python/branches/bcannon-sandboxing/Lib/test/test_doctest.py
   python/branches/bcannon-sandboxing/Lib/test/test_email_codecs.py
   python/branches/bcannon-sandboxing/Lib/test/test_filecmp.py
   python/branches/bcannon-sandboxing/Lib/test/test_fork1.py
   python/branches/bcannon-sandboxing/Lib/test/test_generators.py
   python/branches/bcannon-sandboxing/Lib/test/test_getargs2.py
   python/branches/bcannon-sandboxing/Lib/test/test_grammar.py
   python/branches/bcannon-sandboxing/Lib/test/test_inspect.py
   python/branches/bcannon-sandboxing/Lib/test/test_iterlen.py
   python/branches/bcannon-sandboxing/Lib/test/test_mailbox.py
   python/branches/bcannon-sandboxing/Lib/test/test_mimetools.py
   python/branches/bcannon-sandboxing/Lib/test/test_mimetypes.py
   python/branches/bcannon-sandboxing/Lib/test/test_minidom.py
   python/branches/bcannon-sandboxing/Lib/test/test_multibytecodec.py
   python/branches/bcannon-sandboxing/Lib/test/test_optparse.py
   python/branches/bcannon-sandboxing/Lib/test/test_ossaudiodev.py
   python/branches/bcannon-sandboxing/Lib/test/test_runpy.py
   python/branches/bcannon-sandboxing/Lib/test/test_sax.py
   python/branches/bcannon-sandboxing/Lib/test/test_scope.py
   python/branches/bcannon-sandboxing/Lib/test/test_shutil.py
   python/branches/bcannon-sandboxing/Lib/test/test_signal.py
   python/branches/bcannon-sandboxing/Lib/test/test_subprocess.py
   python/branches/bcannon-sandboxing/Lib/test/test_sys.py
   python/branches/bcannon-sandboxing/Lib/test/test_time.py
   python/branches/bcannon-sandboxing/Lib/test/test_traceback.py
   python/branches/bcannon-sandboxing/Lib/test/test_urllib2.py
   python/branches/bcannon-sandboxing/Lib/test/test_uuid.py
   python/branches/bcannon-sandboxing/Lib/test/test_wait3.py
   python/branches/bcannon-sandboxing/Lib/test/test_wait4.py
   python/branches/bcannon-sandboxing/Lib/test/test_winreg.py
   python/branches/bcannon-sandboxing/Lib/test/test_xml_etree.py
   python/branches/bcannon-sandboxing/Lib/test/test_xml_etree_c.py
   python/branches/bcannon-sandboxing/Lib/traceback.py
   python/branches/bcannon-sandboxing/Lib/types.py
   python/branches/bcannon-sandboxing/Lib/urllib.py
   python/branches/bcannon-sandboxing/Lib/urllib2.py
   python/branches/bcannon-sandboxing/Lib/uuid.py
   python/branches/bcannon-sandboxing/Lib/warnings.py
   python/branches/bcannon-sandboxing/Lib/xml/dom/   (props changed)
   python/branches/bcannon-sandboxing/Lib/xml/parsers/   (props changed)
   python/branches/bcannon-sandboxing/Lib/xml/sax/   (props changed)
   python/branches/bcannon-sandboxing/Lib/zipfile.py
   python/branches/bcannon-sandboxing/Mac/BuildScript/scripts/postflight.patch-profile
   python/branches/bcannon-sandboxing/Mac/IDLE/config-main.def
   python/branches/bcannon-sandboxing/Mac/PythonLauncher/FileSettings.m
   python/branches/bcannon-sandboxing/Makefile.pre.in
   python/branches/bcannon-sandboxing/Misc/ACKS
   python/branches/bcannon-sandboxing/Misc/NEWS
   python/branches/bcannon-sandboxing/Misc/RPM/python-2.5.spec
   python/branches/bcannon-sandboxing/Misc/build.sh
   python/branches/bcannon-sandboxing/Misc/python-config.in
   python/branches/bcannon-sandboxing/Modules/_bsddb.c
   python/branches/bcannon-sandboxing/Modules/_ctypes/_ctypes.c
   python/branches/bcannon-sandboxing/Modules/_ctypes/callbacks.c
   python/branches/bcannon-sandboxing/Modules/_ctypes/callproc.c
   python/branches/bcannon-sandboxing/Modules/_ctypes/cfield.c
   python/branches/bcannon-sandboxing/Modules/_ctypes/ctypes.h
   python/branches/bcannon-sandboxing/Modules/_ctypes/libffi/configure
   python/branches/bcannon-sandboxing/Modules/_ctypes/libffi/configure.ac
   python/branches/bcannon-sandboxing/Modules/_ctypes/stgdict.c
   python/branches/bcannon-sandboxing/Modules/_cursesmodule.c
   python/branches/bcannon-sandboxing/Modules/_sqlite/cursor.c
   python/branches/bcannon-sandboxing/Modules/_sqlite/util.c
   python/branches/bcannon-sandboxing/Modules/_sqlite/util.h
   python/branches/bcannon-sandboxing/Modules/_ssl.c
   python/branches/bcannon-sandboxing/Modules/_struct.c
   python/branches/bcannon-sandboxing/Modules/_testcapimodule.c
   python/branches/bcannon-sandboxing/Modules/_tkinter.c
   python/branches/bcannon-sandboxing/Modules/bz2module.c
   python/branches/bcannon-sandboxing/Modules/cPickle.c
   python/branches/bcannon-sandboxing/Modules/collectionsmodule.c
   python/branches/bcannon-sandboxing/Modules/config.c.in
   python/branches/bcannon-sandboxing/Modules/cryptmodule.c
   python/branches/bcannon-sandboxing/Modules/dlmodule.c
   python/branches/bcannon-sandboxing/Modules/expat/xmlparse.c
   python/branches/bcannon-sandboxing/Modules/fcntlmodule.c
   python/branches/bcannon-sandboxing/Modules/fpectlmodule.c
   python/branches/bcannon-sandboxing/Modules/getpath.c
   python/branches/bcannon-sandboxing/Modules/itertoolsmodule.c
   python/branches/bcannon-sandboxing/Modules/main.c
   python/branches/bcannon-sandboxing/Modules/posixmodule.c
   python/branches/bcannon-sandboxing/Modules/pyexpat.c
   python/branches/bcannon-sandboxing/Modules/readline.c
   python/branches/bcannon-sandboxing/Modules/selectmodule.c
   python/branches/bcannon-sandboxing/Modules/socketmodule.c
   python/branches/bcannon-sandboxing/Modules/timemodule.c
   python/branches/bcannon-sandboxing/Modules/unicodedata.c
   python/branches/bcannon-sandboxing/Objects/codeobject.c
   python/branches/bcannon-sandboxing/Objects/complexobject.c
   python/branches/bcannon-sandboxing/Objects/dictobject.c
   python/branches/bcannon-sandboxing/Objects/fileobject.c
   python/branches/bcannon-sandboxing/Objects/frameobject.c
   python/branches/bcannon-sandboxing/Objects/funcobject.c
   python/branches/bcannon-sandboxing/Objects/listsort.txt
   python/branches/bcannon-sandboxing/Objects/longobject.c
   python/branches/bcannon-sandboxing/Objects/setobject.c
   python/branches/bcannon-sandboxing/Objects/stringobject.c
   python/branches/bcannon-sandboxing/Objects/typeobject.c
   python/branches/bcannon-sandboxing/Objects/unicodeobject.c
   python/branches/bcannon-sandboxing/PC/_winreg.c
   python/branches/bcannon-sandboxing/PC/config.c
   python/branches/bcannon-sandboxing/PC/getpathp.c
   python/branches/bcannon-sandboxing/PC/os2emx/Makefile
   python/branches/bcannon-sandboxing/PC/os2emx/README.os2emx
   python/branches/bcannon-sandboxing/PC/os2emx/config.c
   python/branches/bcannon-sandboxing/PC/os2emx/pyconfig.h
   python/branches/bcannon-sandboxing/PC/winsound.c
   python/branches/bcannon-sandboxing/PCbuild/_ssl.vcproj
   python/branches/bcannon-sandboxing/PCbuild/build_ssl.py
   python/branches/bcannon-sandboxing/PCbuild/pythoncore.vcproj
   python/branches/bcannon-sandboxing/PCbuild/readme.txt
   python/branches/bcannon-sandboxing/Python/ast.c
   python/branches/bcannon-sandboxing/Python/compile.c
   python/branches/bcannon-sandboxing/Python/errors.c
   python/branches/bcannon-sandboxing/Python/future.c
   python/branches/bcannon-sandboxing/Python/getargs.c
   python/branches/bcannon-sandboxing/Python/getopt.c
   python/branches/bcannon-sandboxing/Python/import.c
   python/branches/bcannon-sandboxing/Python/mactoolboxglue.c
   python/branches/bcannon-sandboxing/Python/mystrtoul.c
   python/branches/bcannon-sandboxing/Python/pyarena.c
   python/branches/bcannon-sandboxing/Python/pystate.c
   python/branches/bcannon-sandboxing/Python/pythonrun.c
   python/branches/bcannon-sandboxing/Python/symtable.c
   python/branches/bcannon-sandboxing/Python/sysmodule.c
   python/branches/bcannon-sandboxing/Python/thread.c
   python/branches/bcannon-sandboxing/Python/thread_os2.h
   python/branches/bcannon-sandboxing/README
   python/branches/bcannon-sandboxing/Tools/buildbot/kill_python.c
   python/branches/bcannon-sandboxing/Tools/faqwiz/faqw.py
   python/branches/bcannon-sandboxing/Tools/msi/   (props changed)
   python/branches/bcannon-sandboxing/Tools/msi/msi.py
   python/branches/bcannon-sandboxing/Tools/msi/uuids.py
   python/branches/bcannon-sandboxing/Tools/scripts/README
   python/branches/bcannon-sandboxing/Tools/webchecker/webchecker.py
   python/branches/bcannon-sandboxing/configure
   python/branches/bcannon-sandboxing/configure.in
Log:
Merged revisions 47248-51029 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/trunk



Modified: python/branches/bcannon-sandboxing/Doc/Makefile.deps
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/Makefile.deps	(original)
+++ python/branches/bcannon-sandboxing/Doc/Makefile.deps	Wed Aug  2 00:51:44 2006
@@ -270,6 +270,7 @@
 	lib/xmlsaxhandler.tex \
 	lib/xmlsaxutils.tex \
 	lib/xmlsaxreader.tex \
+	lib/libetree.tex \
 	lib/libqueue.tex \
 	lib/liblocale.tex \
 	lib/libgettext.tex \

Modified: python/branches/bcannon-sandboxing/Doc/api/api.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/api/api.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/api/api.tex	Wed Aug  2 00:51:44 2006
@@ -48,11 +48,6 @@
 \input{newtypes}
 
 
-% \chapter{Debugging \label{debugging}}
-%
-% XXX Explain Py_DEBUG, Py_TRACE_REFS, Py_REF_DEBUG.
-
-
 \appendix
 \chapter{Reporting Bugs}
 \input{reportingbugs}

Modified: python/branches/bcannon-sandboxing/Doc/api/concrete.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/api/concrete.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/api/concrete.tex	Wed Aug  2 00:51:44 2006
@@ -376,7 +376,7 @@
   \versionadded{2.3}
 \end{cfuncdesc}
 
-\begin{cfuncdesc}{unsigned long}{PyLong_AsUnsignedLongLongMask}{PyObject *io}
+\begin{cfuncdesc}{unsigned PY_LONG_LONG}{PyLong_AsUnsignedLongLongMask}{PyObject *io}
   Return a C \ctype{unsigned long long} from a Python long integer, without
   checking for overflow.
   \versionadded{2.3}

Modified: python/branches/bcannon-sandboxing/Doc/api/exceptions.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/api/exceptions.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/api/exceptions.tex	Wed Aug  2 00:51:44 2006
@@ -259,10 +259,14 @@
   argument.  It is mostly for internal use.
 \end{cfuncdesc}
 
-\begin{cfuncdesc}{int}{PyErr_Warn}{PyObject *category, char *message}
+\begin{cfuncdesc}{int}{PyErr_WarnEx}{PyObject *category, char *message, int stacklevel}
   Issue a warning message.  The \var{category} argument is a warning
   category (see below) or \NULL; the \var{message} argument is a
-  message string.
+  message string.  \var{stacklevel} is a positive number giving a
+  number of stack frames; the warning will be issued from the 
+  currently executing line of code in that stack frame.  A \var{stacklevel}
+  of 1 is the function calling \cfunction{PyErr_WarnEx()}, 2 is 
+  the function above that, and so forth.
 
   This function normally prints a warning message to \var{sys.stderr};
   however, it is also possible that the user has specified that
@@ -294,6 +298,16 @@
   command line documentation.  There is no C API for warning control.
 \end{cfuncdesc}
 
+\begin{cfuncdesc}{int}{PyErr_Warn}{PyObject *category, char *message}
+  Issue a warning message.  The \var{category} argument is a warning
+  category (see below) or \NULL; the \var{message} argument is a
+  message string.  The warning will appear to be issued from the function
+  calling \cfunction{PyErr_Warn()}, equivalent to calling
+  \cfunction{PyErr_WarnEx()} with a \var{stacklevel} of 1.
+  
+  Deprecated; use \cfunction{PyErr_WarnEx()} instead.
+\end{cfuncdesc}
+
 \begin{cfuncdesc}{int}{PyErr_WarnExplicit}{PyObject *category,
                 const char *message, const char *filename, int lineno,
                 const char *module, PyObject *registry}

Modified: python/branches/bcannon-sandboxing/Doc/api/intro.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/api/intro.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/api/intro.tex	Wed Aug  2 00:51:44 2006
@@ -580,3 +580,59 @@
 Notice that \cfunction{Py_Finalize} does \emph{not} free all memory
 allocated by the Python interpreter, e.g. memory allocated by extension
 modules currently cannot be released.
+
+
+\section{Debugging Builds \label{debugging}}
+
+Python can be built with several macros to enable extra checks of the
+interpreter and extension modules.  These checks tend to add a large
+amount of overhead to the runtime so they are not enabled by default.
+
+A full list of the various types of debugging builds is in the file
+\file{Misc/SpecialBuilds.txt} in the Python source distribution.
+Builds are available that support tracing of reference counts,
+debugging the memory allocator, or low-level profiling of the main
+interpreter loop.  Only the most frequently-used builds will be
+described in the remainder of this section.
+
+Compiling the interpreter with the \csimplemacro{Py_DEBUG} macro
+defined produces what is generally meant by "a debug build" of Python.
+\csimplemacro{Py_DEBUG} is enabled in the \UNIX{} build by adding
+\longprogramopt{with-pydebug} to the \file{configure} command.  It is also
+implied by the presence of the not-Python-specific
+\csimplemacro{_DEBUG} macro.  When \csimplemacro{Py_DEBUG} is enabled
+in the \UNIX{} build, compiler optimization is disabled.
+
+In addition to the reference count debugging described below, the
+following extra checks are performed:
+
+\begin{itemize}
+      \item Extra checks are added to the object allocator.
+      \item Extra checks are added to the parser and compiler.
+      \item Downcasts from wide types to narrow types are checked for
+            loss of information.
+      \item A number of assertions are added to the dictionary and set
+            implementations.  In addition, the set object acquires a
+            \method{test_c_api} method.
+      \item Sanity checks of the input arguments are added to frame
+            creation. 
+      \item The storage for long ints is initialized with a known
+            invalid pattern to catch reference to uninitialized
+            digits. 
+      \item Low-level tracing and extra exception checking are added
+            to the runtime virtual machine.
+      \item Extra checks are added to the memory arena implementation.
+      \item Extra debugging is added to the thread module.
+\end{itemize}
+
+There may be additional checks not mentioned here.
+
+Defining \csimplemacro{Py_TRACE_REFS} enables reference tracing.  When
+defined, a circular doubly linked list of active objects is maintained
+by adding two extra fields to every \ctype{PyObject}.  Total
+allocations are tracked as well.  Upon exit, all existing references
+are printed.  (In interactive mode this happens after every statement
+run by the interpreter.)  Implied by \csimplemacro{Py_DEBUG}.
+
+Please refer to \file{Misc/SpecialBuilds.txt} in the Python source
+distribution for more detailed information.

Modified: python/branches/bcannon-sandboxing/Doc/api/refcounts.dat
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/api/refcounts.dat	(original)
+++ python/branches/bcannon-sandboxing/Doc/api/refcounts.dat	Wed Aug  2 00:51:44 2006
@@ -303,6 +303,11 @@
 PyErr_Warn:PyObject*:category:0:
 PyErr_Warn:char*:message::
 
+PyErr_WarnEx:int:::
+PyErr_WarnEx:PyObject*:category:0:
+PyErr_WarnEx:const char*:message::
+PyErr_WarnEx:Py_ssize_t:stack_level::
+
 PyEval_AcquireLock:void:::
 
 PyEval_AcquireThread:void:::

Modified: python/branches/bcannon-sandboxing/Doc/commontex/boilerplate.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/commontex/boilerplate.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/commontex/boilerplate.tex	Wed Aug  2 00:51:44 2006
@@ -5,5 +5,5 @@
 	Email: \email{docs at python.org}
 }
 
-\date{\today}			% XXX update before final release!
+\date{11th July, 2006}			% XXX update before final release!
 \input{patchlevel}		% include Python version information

Modified: python/branches/bcannon-sandboxing/Doc/dist/dist.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/dist/dist.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/dist/dist.tex	Wed Aug  2 00:51:44 2006
@@ -530,7 +530,7 @@
 you can take advantage of the fact that header files are installed in a
 consistent way by the Distutils \command{install\_header} command.  For
 example, the Numerical Python header files are installed (on a standard
-Unix installation) to \file{/usr/local/include/python1.5/Numerical}.
+\UNIX{} installation) to \file{/usr/local/include/python1.5/Numerical}.
 (The exact location will differ according to your platform and Python
 installation.)  Since the Python include
 directory---\file{/usr/local/include/python1.5} in this case---is always
@@ -2317,7 +2317,7 @@
 \lineiii{name}{the full name of the extension, including any packages
 --- ie. \emph{not} a filename or pathname, but Python dotted name}{string}
 \lineiii{sources}{list of source filenames, relative to the distribution
-root (where the setup script lives), in Unix form (slash-separated) for
+root (where the setup script lives), in \UNIX{} form (slash-separated) for
 portability. Source files may be C, \Cpp, SWIG (.i), platform-specific
 resource files, or whatever else is recognized by the \command{build_ext}
 command as source for a Python extension.}{string}
@@ -2873,9 +2873,20 @@
 \modulesynopsis{Microsoft Compiler}
 
 This module provides \class{MSVCCompiler}, an implementation of the abstract 
-\class{CCompiler} class for Microsoft Visual Studio. It should also work using
-the freely available compiler provided as part of the .Net SDK download. XXX
-download link.
+\class{CCompiler} class for Microsoft Visual Studio. Typically, extension
+modules need to be compiled with the same compiler that was used to compile
+Python. For Python 2.3 and earlier, the compiler was Visual Studio 6. For
+Python 2.4 and 2.5, the compiler is Visual Studio .NET 2003. The AMD64
+and Itanium binaries are created using the Platform SDK.
+
+\class{MSVCCompiler} will normally choose the right compiler, linker etc.
+on its own. To override this choice, the environment variables
+\var{DISTUTILS\_USE\_SDK} and \var{MSSdk} must be both set. \var{MSSdk}
+indicates that the current environment has been setup by the SDK's
+\code{SetEnv.Cmd} script, or that the environment variables had been
+registered when the SDK was installed; \var{DISTUTILS\_USE\_SDK} indicates
+that the distutils user has made an explicit choice to override the
+compiler selection by \class{MSVCCompiler}.
 
 \section{\module{distutils.bcppcompiler} --- Borland Compiler}
 \declaremodule{standard}{distutils.bcppcompiler}
@@ -3088,7 +3099,7 @@
 Move file \var{src} to \var{dst}. If \var{dst} is a directory, the file will
 be moved into it with the same name; otherwise, \var{src} is just renamed
 to \var{dst}.  Returns the new full name of the file.
-\warning{Handles cross-device moves on Unix using \function{copy_file()}.  
+\warning{Handles cross-device moves on \UNIX{} using \function{copy_file()}.  
 What about other systems???}
 \end{funcdesc}
 
@@ -3131,7 +3142,7 @@
 Return 'pathname' as a name that will work on the native filesystem,
 i.e. split it on '/' and put it back together again using the current
 directory separator.  Needed because filenames in the setup script are
-always supplied in Unix style, and have to be converted to the local
+always supplied in \UNIX{} style, and have to be converted to the local
 convention before we can actually use them in the filesystem.  Raises
 \exception{ValueError} on non-\UNIX-ish systems if \var{pathname} either 
 starts or ends with a slash.
@@ -3180,7 +3191,7 @@
 \end{funcdesc}
 
 \begin{funcdesc}{split_quoted}{s}
-Split a string up according to Unix shell-like rules for quotes and
+Split a string up according to \UNIX{} shell-like rules for quotes and
 backslashes.  In short: words are delimited by spaces, as long as those
 spaces are not escaped by a backslash, or inside a quoted string.
 Single and double quotes are equivalent, and the quote characters can

Modified: python/branches/bcannon-sandboxing/Doc/doc/doc.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/doc/doc.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/doc/doc.tex	Wed Aug  2 00:51:44 2006
@@ -187,6 +187,20 @@
   Topics which are not covered in the Apple's style guide will be
   discussed in this document if necessary.
 
+  Footnotes are generally discouraged due to the pain of using
+  footnotes in the HTML conversion of documents.  Footnotes may be
+  used when they are the best way to present specific information.
+  When a footnote reference is added at the end of the sentence, it
+  should follow the sentence-ending punctuation.  The \LaTeX{} markup
+  should appear something like this:
+
+\begin{verbatim}
+This sentence has a footnote reference.%
+  \footnote{This is the footnote text.}
+\end{verbatim}
+
+  Footnotes may appear in the middle of sentences where appropriate.
+
   Many special names are used in the Python documentation, including
   the names of operating systems, programming languages, standards
   bodies, and the like.  Many of these were assigned \LaTeX{} macros
@@ -281,10 +295,10 @@
     to know about \LaTeX{} syntax.
 
     A \dfn{comment} is started by the ``percent'' character
-    (\character{\%}) and continues through the end of the line and all
-    leading whitespace on the following line.  This is a little
-    different from any programming language I know of, so an example
-    is in order:
+    (\character{\%}) and continues through the end of the line
+    \emph{and all leading whitespace on the following line}.  This is
+    a little different from any programming language I know of, so an
+    example is in order:
 
 \begin{verbatim}
 This is text.% comment

Modified: python/branches/bcannon-sandboxing/Doc/ext/newtypes.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/ext/newtypes.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/ext/newtypes.tex	Wed Aug  2 00:51:44 2006
@@ -16,8 +16,9 @@
 The way new types are defined changed dramatically (and for the
 better) in Python 2.2.  This document documents how to define new
 types for Python 2.2 and later.  If you need to support older
-versions of Python, you will need to refer to older versions of this
-documentation.
+versions of Python, you will need to refer to
+\ulink{older versions of this documentation}
+      {http://www.python.org/doc/versions/}.
 \end{notice}
 
 \section{The Basics
@@ -479,7 +480,7 @@
   1
 \item when we know that deallocation of the object\footnote{This is
   true when we know that the object is a basic type, like a string or
-  a float} will not cause any
+  a float.} will not cause any
   calls back into our type's code
 \item when decrementing a reference count in a \member{tp_dealloc}
   handler when garbage-collections is not supported\footnote{We relied
@@ -791,9 +792,9 @@
 
 In the second version of the \class{Noddy} example, we allowed any
 kind of object to be stored in the \member{first} or \member{last}
-attributes\footnote{Even in the third version, we aren't guaranteed to
+attributes.\footnote{Even in the third version, we aren't guaranteed to
 avoid cycles.  Instances of string subclasses are allowed and string
-subclasses could allow cycles even if normal strings don't.}. This
+subclasses could allow cycles even if normal strings don't.} This
 means that \class{Noddy} objects can participate in cycles:
 
 \begin{verbatim}
@@ -1563,6 +1564,85 @@
 avoiding the exception can yield slightly better performance.  If an
 actual error occurs, it should set an exception and return \NULL.
 
+
+\subsection{Weak Reference Support\label{weakref-support}}
+
+One of the goals of Python's weak-reference implementation is to allow
+any type to participate in the weak reference mechanism without
+incurring the overhead on those objects which do not benefit by weak
+referencing (such as numbers).
+
+For an object to be weakly referencable, the extension must include a
+\ctype{PyObject*} field in the instance structure for the use of the
+weak reference mechanism; it must be initialized to \NULL{} by the
+object's constructor.  It must also set the \member{tp_weaklistoffset}
+field of the corresponding type object to the offset of the field.
+For example, the instance type is defined with the following
+structure:
+
+\begin{verbatim}
+typedef struct {
+    PyObject_HEAD
+    PyClassObject *in_class;       /* The class object */
+    PyObject      *in_dict;        /* A dictionary */
+    PyObject      *in_weakreflist; /* List of weak references */
+} PyInstanceObject;
+\end{verbatim}
+
+The statically-declared type object for instances is defined this way:
+
+\begin{verbatim}
+PyTypeObject PyInstance_Type = {
+    PyObject_HEAD_INIT(&PyType_Type)
+    0,
+    "module.instance",
+
+    /* Lots of stuff omitted for brevity... */
+
+    Py_TPFLAGS_DEFAULT,                         /* tp_flags */
+    0,                                          /* tp_doc */
+    0,                                          /* tp_traverse */
+    0,                                          /* tp_clear */
+    0,                                          /* tp_richcompare */
+    offsetof(PyInstanceObject, in_weakreflist), /* tp_weaklistoffset */
+};
+\end{verbatim}
+
+The type constructor is responsible for initializing the weak reference
+list to \NULL:
+
+\begin{verbatim}
+static PyObject *
+instance_new() {
+    /* Other initialization stuff omitted for brevity */
+
+    self->in_weakreflist = NULL;
+
+    return (PyObject *) self;
+}
+\end{verbatim}
+
+The only further addition is that the destructor needs to call the
+weak reference manager to clear any weak references.  This should be
+done before any other parts of the destruction have occurred, but is
+only required if the weak reference list is non-\NULL:
+
+\begin{verbatim}
+static void
+instance_dealloc(PyInstanceObject *inst)
+{
+    /* Allocate temporaries if needed, but do not begin
+       destruction just yet.
+     */
+
+    if (inst->in_weakreflist != NULL)
+        PyObject_ClearWeakRefs((PyObject *) inst);
+
+    /* Proceed with object destruction normally. */
+}
+\end{verbatim}
+
+
 \subsection{More Suggestions}
 
 Remember that you can omit most of these functions, in which case you

Modified: python/branches/bcannon-sandboxing/Doc/ext/windows.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/ext/windows.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/ext/windows.tex	Wed Aug  2 00:51:44 2006
@@ -28,13 +28,15 @@
 \section{A Cookbook Approach \label{win-cookbook}}
 
 There are two approaches to building extension modules on Windows,
-just as there are on \UNIX: use the \refmodule{distutils} package to
+just as there are on \UNIX: use the
+\ulink{\module{distutils}}{../lib/module-distutils.html} package to
 control the build process, or do things manually.  The distutils
 approach works well for most extensions; documentation on using
-\refmodule{distutils} to build and package extension modules is
-available in \citetitle[../dist/dist.html]{Distributing Python
-Modules}.  This section describes the manual approach to building
-Python extensions written in C or \Cpp.
+\ulink{\module{distutils}}{../lib/module-distutils.html} to build and
+package extension modules is available in
+\citetitle[../dist/dist.html]{Distributing Python Modules}.  This
+section describes the manual approach to building Python extensions
+written in C or \Cpp.
 
 To build extensions using these instructions, you need to have a copy
 of the Python sources of the same version as your installed Python.

Modified: python/branches/bcannon-sandboxing/Doc/howto/doanddont.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/howto/doanddont.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/howto/doanddont.tex	Wed Aug  2 00:51:44 2006
@@ -288,8 +288,9 @@
 There are also many useful builtin functions people seem not to be
 aware of for some reason: \function{min()} and \function{max()} can
 find the minimum/maximum of any sequence with comparable semantics,
-for example, yet many people write they own max/min. Another highly
-useful function is \function{reduce()}. Classical use of \function{reduce()}
+for example, yet many people write their own
+\function{max()}/\function{min()}. Another highly useful function is
+\function{reduce()}. A classical use of \function{reduce()}
 is something like
 
 \begin{verbatim}

Modified: python/branches/bcannon-sandboxing/Doc/inst/inst.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/inst/inst.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/inst/inst.tex	Wed Aug  2 00:51:44 2006
@@ -262,7 +262,7 @@
 \code{setup.py install}---then the \command{install} command installs to
 the standard location for third-party Python modules.  This location
 varies by platform and by how you built/installed Python itself.  On
-\UNIX{} (and Mac OS X, which is also Unix-based),
+\UNIX{} (and Mac OS X, which is also \UNIX-based),
 it also depends on whether the module distribution
 being installed is pure Python or contains extensions (``non-pure''):
 \begin{tableiv}{l|l|l|c}{textrm}%

Modified: python/branches/bcannon-sandboxing/Doc/lib/email.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/email.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/email.tex	Wed Aug  2 00:51:44 2006
@@ -105,7 +105,7 @@
 \lineiii{4.0}{Python 2.5}{Python 2.3 to 2.5}
 \end{tableiii}
 
-Here are the major differences between \module{email} verson 4 and version 3:
+Here are the major differences between \module{email} version 4 and version 3:
 
 \begin{itemize}
 \item All modules have been renamed according to \pep{8} standards.  For
@@ -126,6 +126,15 @@
 \item Methods that were deprecated in version 3 have been removed.  These
       include \method{Generator.__call__()}, \method{Message.get_type()},
       \method{Message.get_main_type()}, \method{Message.get_subtype()}.
+
+\item Fixes have been added for \rfc{2231} support which can change some of
+      the return types for \function{Message.get_param()} and friends.  Under
+      some circumstances, values which used to return a 3-tuple now return
+      simple strings (specifically, if all extended parameter segments were
+      unencoded, there is no language and charset designation expected, so the
+      return type is now a simple string).  Also, \%-decoding used to be done
+      for both encoded and unencoded segments; this decoding is now done only
+      for encoded segments.
 \end{itemize}
 
 Here are the major differences between \module{email} version 3 and version 2:

Modified: python/branches/bcannon-sandboxing/Doc/lib/emailgenerator.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/emailgenerator.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/emailgenerator.tex	Wed Aug  2 00:51:44 2006
@@ -31,11 +31,11 @@
 \samp{>} character in front of any line in the body that starts exactly as
 \samp{From }, i.e. \code{From} followed by a space at the beginning of the
 line.  This is the only guaranteed portable way to avoid having such
-lines be mistaken for a Unix mailbox format envelope header separator (see
+lines be mistaken for a \UNIX{} mailbox format envelope header separator (see
 \ulink{WHY THE CONTENT-LENGTH FORMAT IS BAD}
 {http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html}
 for details).  \var{mangle_from_} defaults to \code{True}, but you
-might want to set this to \code{False} if you are not writing Unix
+might want to set this to \code{False} if you are not writing \UNIX{}
 mailbox format files.
 
 Optional \var{maxheaderlen} specifies the longest length for a

Modified: python/branches/bcannon-sandboxing/Doc/lib/lib.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/lib.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/lib.tex	Wed Aug  2 00:51:44 2006
@@ -71,12 +71,12 @@
 % BUILT-INs
 % =============
 
-\input{libobjs}                 % Built-in Types, Exceptions and Functions
+\input{libobjs}                 % Built-in Exceptions and Functions
 \input{libfuncs}
-\input{libstdtypes}
 \input{libexcs}
 \input{libconsts}
 
+\input{libstdtypes}             % Built-in types
 
 
 % =============
@@ -154,8 +154,8 @@
 
 % encoding stuff
 \input{libbase64}
-\input{libbinascii}
 \input{libbinhex}
+\input{libbinascii}
 \input{libquopri}
 \input{libuu}
 
@@ -171,6 +171,7 @@
 \input{xmlsaxhandler}
 \input{xmlsaxutils}
 \input{xmlsaxreader}
+\input{libetree}
 % \input{libxmllib}
 
 \input{fileformats}		% Miscellaneous file formats

Modified: python/branches/bcannon-sandboxing/Doc/lib/libanydbm.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libanydbm.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libanydbm.tex	Wed Aug  2 00:51:44 2006
@@ -46,6 +46,32 @@
 \method{keys()} methods are available.  Keys and values must always be
 strings.
 
+The following example records some hostnames and a corresponding title, 
+and then prints out the contents of the database:
+
+\begin{verbatim}
+import anydbm
+
+# Open database, creating it if necessary.
+db = anydbm.open('cache', 'c')
+
+# Record some values
+db['www.python.org'] = 'Python Website'
+db['www.cnn.com'] = 'Cable News Network'
+
+# Loop through contents.  Other dictionary methods
+# such as .keys(), .values() also work.
+for k, v in db.iteritems():
+    print k, '\t', v
+
+# Storing a non-string key or value will raise an exception (most
+# likely a TypeError).
+db['www.yahoo.com'] = 4
+
+# Close when done.
+db.close()
+\end{verbatim}
+
 
 \begin{seealso}
   \seemodule{dbhash}{BSD \code{db} database interface.}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libbase64.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libbase64.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libbase64.tex	Wed Aug  2 00:51:44 2006
@@ -146,6 +146,18 @@
 always including an extra trailing newline (\code{'\e n'}).
 \end{funcdesc}
 
+An example usage of the module:
+
+\begin{verbatim}
+>>> import base64
+>>> encoded = base64.b64encode('data to be encoded')
+>>> encoded
+'ZGF0YSB0byBiZSBlbmNvZGVk'
+>>> data = base64.b64decode(encoded)
+>>> data
+'data to be encoded'
+\end{verbatim}
+
 \begin{seealso}
   \seemodule{binascii}{Support module containing \ASCII-to-binary
                        and binary-to-\ASCII{} conversions.}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libbinascii.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libbinascii.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libbinascii.tex	Wed Aug  2 00:51:44 2006
@@ -9,10 +9,11 @@
 The \module{binascii} module contains a number of methods to convert
 between binary and various \ASCII-encoded binary
 representations. Normally, you will not use these functions directly
-but use wrapper modules like \refmodule{uu}\refstmodindex{uu} or
-\refmodule{binhex}\refstmodindex{binhex} instead, this module solely
-exists because bit-manipulation of large amounts of data is slow in
-Python.
+but use wrapper modules like \refmodule{uu}\refstmodindex{uu},
+\refmodule{base64}\refstmodindex{base64}, or
+\refmodule{binhex}\refstmodindex{binhex} instead. The \module{binascii} module
+contains low-level functions written in C for greater speed
+that are used by the higher-level modules.
 
 The \module{binascii} module defines the following functions:
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libbsddb.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libbsddb.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libbsddb.tex	Wed Aug  2 00:51:44 2006
@@ -94,7 +94,7 @@
 
 
 \begin{notice}
-Beginning in 2.3 some Unix versions of Python may have a \module{bsddb185}
+Beginning in 2.3 some \UNIX{} versions of Python may have a \module{bsddb185}
 module.  This is present \emph{only} to allow backwards compatibility with
 systems which ship with the old Berkeley DB 1.85 database library.  The
 \module{bsddb185} module should never be used directly in new code.

Modified: python/branches/bcannon-sandboxing/Doc/lib/libcompileall.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libcompileall.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libcompileall.tex	Wed Aug  2 00:51:44 2006
@@ -44,6 +44,19 @@
   \function{compile_dir()} function.
 \end{funcdesc}
 
+To force a recompile of all the \file{.py} files in the \file{Lib/}
+subdirectory and all its subdirectories:
+
+\begin{verbatim}
+import compileall
+
+compileall.compile_dir('Lib/', force=True)
+
+# Perform same compilation, excluding files in .svn directories.
+import re
+compileall.compile_dir('Lib/', rx=re.compile('/[.]svn'), force=True)
+\end{verbatim}
+
 
 \begin{seealso}
   \seemodule[pycompile]{py_compile}{Byte-compile a single source file.}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libcookielib.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libcookielib.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libcookielib.tex	Wed Aug  2 00:51:44 2006
@@ -24,7 +24,7 @@
 the de-facto Netscape cookie protocol (which differs substantially
 from that set out in the original Netscape specification), including
 taking note of the \code{max-age} and \code{port} cookie-attributes
-introduced with RFC 2109.  \note{The various named parameters found in
+introduced with RFC 2965.  \note{The various named parameters found in
 \mailheader{Set-Cookie} and \mailheader{Set-Cookie2} headers
 (eg. \code{domain} and \code{expires}) are conventionally referred to
 as \dfn{attributes}.  To distinguish them from Python attributes, the

Modified: python/branches/bcannon-sandboxing/Doc/lib/libcsv.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libcsv.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libcsv.tex	Wed Aug  2 00:51:44 2006
@@ -55,7 +55,7 @@
 Return a reader object which will iterate over lines in the given
 {}\var{csvfile}.  \var{csvfile} can be any object which supports the
 iterator protocol and returns a string each time its \method{next}
-method is called - file objects and list objects are both suitable.  
+method is called --- file objects and list objects are both suitable.  
 If \var{csvfile} is a file object, it must be opened with
 the 'b' flag on platforms where that makes a difference.  An optional
 {}\var{dialect} parameter can be given
@@ -70,6 +70,18 @@
 
 All data read are returned as strings.  No automatic data type
 conversion is performed.
+
+\versionchanged[
+The parser is now stricter with respect to multi-line quoted
+fields. Previously, if a line ended within a quoted field without a
+terminating newline character, a newline would be inserted into the
+returned field. This behavior caused problems when reading files
+which contained carriage return characters within fields.  The
+behavior was changed to return the field without inserting newlines. As
+a consequence, if newlines embedded within fields are important, the
+input should be split into lines in a manner which preserves the newline
+characters]{2.5}
+
 \end{funcdesc}
 
 \begin{funcdesc}{writer}{csvfile\optional{,
@@ -404,7 +416,7 @@
 reader = csv.reader(open("passwd", "rb"), 'unixpwd')
 \end{verbatim}
 
-A slightly more advanced use of the reader - catching and reporting errors:
+A slightly more advanced use of the reader --- catching and reporting errors:
 
 \begin{verbatim}
 import csv, sys

Modified: python/branches/bcannon-sandboxing/Doc/lib/libctypes.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libctypes.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libctypes.tex	Wed Aug  2 00:51:44 2006
@@ -790,10 +790,6 @@
 
 \subsubsection{Pointers\label{ctypes-pointers}}
 
-XXX Rewrite this section.  Normally one only uses indexing, not the .contents
-attribute!
-List some recipes with pointers.  bool(ptr),  POINTER(tp)(), ...?
-
 Pointer instances are created by calling the \code{pointer} function on a
 \code{ctypes} type:
 \begin{verbatim}
@@ -826,7 +822,8 @@
 attribute would cause the pointer to point to the memory location
 where this is stored:
 \begin{verbatim}
->>> pi.contents = c_int(99)
+>>> i = c_int(99)
+>>> pi.contents = i
 >>> pi.contents
 c_long(99)
 >>>
@@ -855,9 +852,6 @@
 pointer from a C function, and you \emph{know} that the pointer actually
 points to an array instead of a single item.
 
-
-\subsubsection{Pointer classes/types\label{ctypes-pointer-classestypes}}
-
 Behind the scenes, the \code{pointer} function does more than simply
 create pointer instances, it has to create pointer \emph{types} first.
 This is done with the \code{POINTER} function, which accepts any
@@ -875,6 +869,31 @@
 >>>
 \end{verbatim}
 
+Calling the pointer type without an argument creates a \code{NULL}
+pointer.  \code{NULL} pointers have a \code{False} boolean value:
+\begin{verbatim}
+>>> null_ptr = POINTER(c_int)()
+>>> print bool(null_ptr)
+False
+>>>
+\end{verbatim}
+
+\code{ctypes} checks for \code{NULL} when dereferencing pointers (but
+dereferencing non-\code{NULL} pointers would crash Python):
+\begin{verbatim}
+>>> null_ptr[0]
+Traceback (most recent call last):
+    ....
+ValueError: NULL pointer access
+>>>
+
+>>> null_ptr[0] = 1234
+Traceback (most recent call last):
+    ....
+ValueError: NULL pointer access
+>>>
+\end{verbatim}
+
 
 \subsubsection{Type conversions\label{ctypes-type-conversions}}
 
@@ -1357,35 +1376,6 @@
 >>>
 \end{verbatim}
 
-The solution is to use 1-element arrays; as a special case ctypes does
-no bounds checking on them:
-\begin{verbatim}
->>> short_array = (c_short * 1)()
->>> print sizeof(short_array)
-2
->>> resize(short_array, 32)
->>> sizeof(short_array)
-32
->>> sizeof(type(short_array))
-2
->>> short_array[0:8]
-[0, 0, 0, 0, 0, 0, 0, 0]
->>> short_array[7] = 42
->>> short_array[0:8]
-[0, 0, 0, 0, 0, 0, 0, 42]
->>>
-\end{verbatim}
-
-Using 1-element arrays as variable sized fields in structures works as
-well, but they should be used as the last field in the structure
-definition.  This example shows a definition from the Windows header
-files:
-\begin{verbatim}
-class SP_DEVICE_INTERFACE_DETAIL_DATA(Structure):
-    _fields_ = [("cbSize", c_int),
-                ("DevicePath", c_char * 1)]
-\end{verbatim}
-
 Another way to use variable-sized data types with \code{ctypes} is to use
 the dynamic nature of Python, and (re-)define the data type after the
 required size is already known, on a case by case basis.
@@ -1474,13 +1464,13 @@
 There are several ways to loaded shared libraries into the Python
 process.  One way is to instantiate one of the following classes:
 
-\begin{classdesc}{CDLL}{name, mode=RTLD_LOCAL, handle=None}
+\begin{classdesc}{CDLL}{name, mode=DEFAULT_MODE, handle=None}
 Instances of this class represent loaded shared libraries.
 Functions in these libraries use the standard C calling
 convention, and are assumed to return \code{int}.
 \end{classdesc}
 
-\begin{classdesc}{OleDLL}{name, mode=RTLD_LOCAL, handle=None}
+\begin{classdesc}{OleDLL}{name, mode=DEFAULT_MODE, handle=None}
 Windows only: Instances of this class represent loaded shared
 libraries, functions in these libraries use the \code{stdcall}
 calling convention, and are assumed to return the windows specific
@@ -1490,7 +1480,7 @@
 failure, an \class{WindowsError} is automatically raised.
 \end{classdesc}
 
-\begin{classdesc}{WinDLL}{name, mode=RTLD_LOCAL, handle=None}
+\begin{classdesc}{WinDLL}{name, mode=DEFAULT_MODE, handle=None}
 Windows only: Instances of this class represent loaded shared
 libraries, functions in these libraries use the \code{stdcall}
 calling convention, and are assumed to return \code{int} by default.
@@ -1503,7 +1493,7 @@
 The Python GIL is released before calling any function exported by
 these libraries, and reaquired afterwards.
 
-\begin{classdesc}{PyDLL}{name, mode=RTLD_LOCAL, handle=None}
+\begin{classdesc}{PyDLL}{name, mode=DEFAULT_MODE, handle=None}
 Instances of this class behave like \class{CDLL} instances, except
 that the Python GIL is \emph{not} released during the function call,
 and after the function execution the Python error flag is checked.
@@ -1533,6 +1523,12 @@
 available, it is the same as \var{RTLD{\_}GLOBAL}.
 \end{datadescni}
 
+\begin{datadescni}{DEFAULT_MODE}
+The default mode which is used to load shared libraries.  On OSX
+10.3, this is \var{RTLD{\_}GLOBAL}, otherwise it is the same as
+\var{RTLD{\_}LOCAL}.
+\end{datadescni}
+
 Instances of these classes have no public methods, however
 \method{{\_}{\_}getattr{\_}{\_}} and \method{{\_}{\_}getitem{\_}{\_}} have special behaviour: functions
 exported by the shared library can be accessed as attributes of by
@@ -1566,10 +1562,9 @@
 return the same library each time.
 \end{classdesc}
 
-\begin{methoddesc}{LoadLibrary}{name, mode=RTLD_LOCAL, handle=None}
+\begin{methoddesc}{LoadLibrary}{name}
 Load a shared library into the process and return it.  This method
-always creates a new instance of the library.  All three
-parameters are passed to the constructor of the library object.
+always returns a new instance of the library.
 \end{methoddesc}
 
 These prefabricated library loaders are available:
@@ -1648,6 +1643,12 @@
 example, a \class{c{\_}char{\_}p} item in the \member{argtypes} tuple will
 convert a unicode string passed as argument into an byte string
 using ctypes conversion rules.
+
+New: It is now possible to put items in argtypes which are not
+ctypes types, but each item must have a \method{from{\_}param} method
+which returns a value usable as argument (integer, string, ctypes
+instance).  This allows to define adapters that can adapt custom
+objects as function parameters.
 \end{memberdesc}
 
 \begin{memberdesc}{errcheck}
@@ -2389,6 +2390,13 @@
 separate \member{{\_}fields{\_}} variable, the fields specified in this are
 appended to the fields of the base class.
 
+Structure and union constructors accept both positional and
+keyword arguments.  Positional arguments are used to initialize member
+fields in the same order as they are appear in \member{{\_}fields{\_}}.  Keyword
+arguments in the constructor are interpreted as attribute assignments,
+so they will initialize \member{{\_}fields{\_}} with the same name, or create new
+attributes for names not present in \member{{\_}fields{\_}}.
+
 
 \subsubsection{Arrays and pointers\label{ctypes-arrays-pointers}}
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libfuncs.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libfuncs.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libfuncs.tex	Wed Aug  2 00:51:44 2006
@@ -401,67 +401,17 @@
 \end{funcdesc}
 
 \begin{funcdesc}{file}{filename\optional{, mode\optional{, bufsize}}}
-  Return a new file object (described in
-  section~\ref{bltin-file-objects}, ``\ulink{File
-  Objects}{bltin-file-objects.html}'').
-  The first two arguments are the same as for \code{stdio}'s
-  \cfunction{fopen()}: \var{filename} is the file name to be opened,
-  \var{mode} indicates how the file is to be opened: \code{'r'} for
-  reading, \code{'w'} for writing (truncating an existing file), and
-  \code{'a'} opens it for appending (which on \emph{some} \UNIX{}
-  systems means that \emph{all} writes append to the end of the file,
-  regardless of the current seek position).
+  Constructor function for the \class{file} type, described further 
+  in section~\ref{bltin-file-objects}, ``\ulink{File
+  Objects}{bltin-file-objects.html}''.  The constructor's arguments
+  are the same as those of the \function{open()} built-in function
+  described below.
 
-  Modes \code{'r+'}, \code{'w+'} and \code{'a+'} open the file for
-  updating (note that \code{'w+'} truncates the file).  Append
-  \code{'b'} to the mode to open the file in binary mode, on systems
-  that differentiate between binary and text files (else it is
-  ignored).  If the file cannot be opened, \exception{IOError} is
-  raised.
-  
-  In addition to the standard \cfunction{fopen()} values \var{mode}
-  may be \code{'U'} or \code{'rU'}. If Python is built with universal
-  newline support (the default) the file is opened as a text file, but
-  lines may be terminated by any of \code{'\e n'}, the Unix end-of-line
-  convention,
-  \code{'\e r'}, the Macintosh convention or \code{'\e r\e n'}, the Windows
-  convention. All of these external representations are seen as
-  \code{'\e n'}
-  by the Python program. If Python is built without universal newline support
-  \var{mode} \code{'U'} is the same as normal text mode.  Note that
-  file objects so opened also have an attribute called
-  \member{newlines} which has a value of \code{None} (if no newlines
-  have yet been seen), \code{'\e n'}, \code{'\e r'}, \code{'\e r\e n'},
-  or a tuple containing all the newline types seen.
-
-  Python enforces that the mode, after stripping \code{'U'}, begins with
-  \code{'r'}, \code{'w'} or \code{'a'}.
-
-  If \var{mode} is omitted, it defaults to \code{'r'}.  When opening a
-  binary file, you should append \code{'b'} to the \var{mode} value
-  for improved portability.  (It's useful even on systems which don't
-  treat binary and text files differently, where it serves as
-  documentation.)
-  \index{line-buffered I/O}\index{unbuffered I/O}\index{buffer size, I/O}
-  \index{I/O control!buffering}
-  The optional \var{bufsize} argument specifies the
-  file's desired buffer size: 0 means unbuffered, 1 means line
-  buffered, any other positive value means use a buffer of
-  (approximately) that size.  A negative \var{bufsize} means to use
-  the system default, which is usually line buffered for tty
-  devices and fully buffered for other files.  If omitted, the system
-  default is used.\footnote{
-    Specifying a buffer size currently has no effect on systems that
-    don't have \cfunction{setvbuf()}.  The interface to specify the
-    buffer size is not done using a method that calls
-    \cfunction{setvbuf()}, because that may dump core when called
-    after any I/O has been performed, and there's no reliable way to
-    determine whether this is the case.}
+  When opening a file, it's preferable to use \function{open()} instead of 
+  invoking this constructor directly.  \class{file} is more suited to
+  type testing (for example, writing \samp{isinstance(f, file)}).
 
   \versionadded{2.2}
-
-  \versionchanged[Restriction on first letter of mode string
-                  introduced]{2.5}
 \end{funcdesc}
 
 \begin{funcdesc}{filter}{function, list}
@@ -726,10 +676,71 @@
 \end{funcdesc}
 
 \begin{funcdesc}{open}{filename\optional{, mode\optional{, bufsize}}}
-  A wrapper for the \function{file()} function above.  The intent is
-  for \function{open()} to be preferred for use as a factory function
-  returning a new \class{file} object.  \class{file} is more suited to
-  type testing (for example, writing \samp{isinstance(f, file)}).
+  Open a file, returning an object of the \class{file} type described
+  in section~\ref{bltin-file-objects}, ``\ulink{File
+  Objects}{bltin-file-objects.html}''.  If the file cannot be opened,
+  \exception{IOError} is raised.  When opening a file, it's
+  preferable to use \function{open()} instead of invoking the
+  \class{file} constructor directly.
+
+  The first two arguments are the same as for \code{stdio}'s
+  \cfunction{fopen()}: \var{filename} is the file name to be opened,
+  and \var{mode} is a string indicating how the file is to be opened.
+
+  The most commonly-used values of \var{mode} are \code{'r'} for
+  reading, \code{'w'} for writing (truncating the file if it already
+  exists), and \code{'a'} for appending (which on \emph{some} \UNIX{}
+  systems means that \emph{all} writes append to the end of the file
+  regardless of the current seek position).  If \var{mode} is omitted,
+  it defaults to \code{'r'}.  When opening a binary file, you should
+  append \code{'b'} to the \var{mode} value to open the file in binary
+  mode, which will improve portability.  (Appending \code{'b'} is
+  useful even on systems that don't treat binary and text files
+  differently, where it serves as documentation.)  See below for more
+  possible values of \var{mode}.
+
+  \index{line-buffered I/O}\index{unbuffered I/O}\index{buffer size, I/O}
+  \index{I/O control!buffering}
+  The optional \var{bufsize} argument specifies the
+  file's desired buffer size: 0 means unbuffered, 1 means line
+  buffered, any other positive value means use a buffer of
+  (approximately) that size.  A negative \var{bufsize} means to use
+  the system default, which is usually line buffered for tty
+  devices and fully buffered for other files.  If omitted, the system
+  default is used.\footnote{
+    Specifying a buffer size currently has no effect on systems that
+    don't have \cfunction{setvbuf()}.  The interface to specify the
+    buffer size is not done using a method that calls
+    \cfunction{setvbuf()}, because that may dump core when called
+    after any I/O has been performed, and there's no reliable way to
+    determine whether this is the case.}
+
+  Modes \code{'r+'}, \code{'w+'} and \code{'a+'} open the file for
+  updating (note that \code{'w+'} truncates the file).  Append
+  \code{'b'} to the mode to open the file in binary mode, on systems
+  that differentiate between binary and text files; on systems
+  that don't have this distinction, adding the \code{'b'} has no effect.
+  
+  In addition to the standard \cfunction{fopen()} values \var{mode}
+  may be \code{'U'} or \code{'rU'}.  Python is usually built with universal
+  newline support; supplying \code{'U'} opens the file as a text file, but
+  lines may be terminated by any of the following: the \UNIX{} end-of-line
+  convention \code{'\e n'}, 
+  the Macintosh convention \code{'\e r'}, or the Windows
+  convention \code{'\e r\e n'}. All of these external representations are seen as
+  \code{'\e n'}
+  by the Python program. If Python is built without universal newline support
+  a \var{mode} with \code{'U'} is the same as normal text mode.  Note that
+  file objects so opened also have an attribute called
+  \member{newlines} which has a value of \code{None} (if no newlines
+  have yet been seen), \code{'\e n'}, \code{'\e r'}, \code{'\e r\e n'},
+  or a tuple containing all the newline types seen.
+
+  Python enforces that the mode, after stripping \code{'U'}, begins with
+  \code{'r'}, \code{'w'} or \code{'a'}.
+
+  \versionchanged[Restriction on first letter of mode string
+                  introduced]{2.5}
 \end{funcdesc}
 
 \begin{funcdesc}{ord}{c}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libgettext.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libgettext.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libgettext.tex	Wed Aug  2 00:51:44 2006
@@ -549,7 +549,7 @@
 written a program called
 \program{xpot} which does a similar job.  It is available as part of
 his \program{po-utils} package at
-\url{http://www.iro.umontreal.ca/contrib/po-utils/HTML/}.} program
+\url{http://po-utils.progiciels-bpi.ca/}.} program
 scans all your Python source code looking for the strings you
 previously marked as translatable.  It is similar to the GNU
 \program{gettext} program except that it understands all the
@@ -585,8 +585,8 @@
 translation processing during run-time.
 
 How you use the \module{gettext} module in your code depends on
-whether you are internationalizing your entire application or a single
-module.
+whether you are internationalizing a single module or your entire application.
+The next two sections will discuss each case.
 
 \subsubsection{Localizing your module}
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libimp.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libimp.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libimp.tex	Wed Aug  2 00:51:44 2006
@@ -232,6 +232,24 @@
 source file.
 \end{funcdesc}
 
+\begin{classdesc}{NullImporter}{path_string}
+The \class{NullImporter} type is a \pep{302} import hook that handles
+non-directory path strings by failing to find any modules.  Calling this
+type with an existing directory or empty string raises
+\exception{ImportError}.  Otherwise, a \class{NullImporter} instance is
+returned.
+
+Python adds instances of this type to \code{sys.path_importer_cache} for
+any path entries that are not directories and are not handled by any other
+path hooks on \code{sys.path_hooks}.  Instances have only one method:
+
+\begin{methoddesc}{find_module}{fullname \optional{, path}}
+This method always returns \code{None}, indicating that the requested
+module could not be found.
+\end{methoddesc}
+
+\versionadded{2.5}
+\end{classdesc}
 
 \subsection{Examples}
 \label{examples-imp}
@@ -257,7 +275,7 @@
     # there's a problem we can't handle -- let the caller handle it.
 
     fp, pathname, description = imp.find_module(name)
-    
+
     try:
         return imp.load_module(name, fp, pathname, description)
     finally:

Modified: python/branches/bcannon-sandboxing/Doc/lib/libinspect.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libinspect.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libinspect.tex	Wed Aug  2 00:51:44 2006
@@ -180,13 +180,32 @@
   Return true if the object is a data descriptor.
 
   Data descriptors have both a __get__ and a __set__ attribute.  Examples are
-  properties (defined in Python) and getsets and members (defined in C).
-  Typically, data descriptors will also have __name__ and __doc__ attributes 
-  (properties, getsets, and members have both of these attributes), but this 
-  is not guaranteed.
+  properties (defined in Python), getsets, and members.  The latter two are
+  defined in C and there are more specific tests available for those types,
+  which is robust across Python implementations.  Typically, data descriptors
+  will also have __name__ and __doc__ attributes (properties, getsets, and
+  members have both of these attributes), but this is not guaranteed.
 \versionadded{2.3}
 \end{funcdesc}
 
+\begin{funcdesc}{isgetsetdescriptor}{object}
+  Return true if the object is a getset descriptor.
+
+  getsets are attributes defined in extension modules via \code{PyGetSetDef}
+  structures.  For Python implementations without such types, this method will
+  always return \code{False}.
+\versionadded{2.5}
+\end{funcdesc}
+
+\begin{funcdesc}{ismemberdescriptor}{object}
+  Return true if the object is a member descriptor.
+
+  Member descriptors are attributes defined in extension modules via
+  \code{PyMemberDef} structures.  For Python implementations without such
+  types, this method will always return \code{False}.
+\versionadded{2.5}
+\end{funcdesc}
+
 \subsection{Retrieving source code
             \label{inspect-source}}
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/liblogging.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/liblogging.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/liblogging.tex	Wed Aug  2 00:51:44 2006
@@ -1068,13 +1068,11 @@
 \end{tableii}
 
 If \var{backupCount} is non-zero, the system will save old log files by
-appending the extensions ".1", ".2" etc., to the filename. For example,
-with a \var{backupCount} of 5 and a base file name of \file{app.log},
-you would get \file{app.log}, \file{app.log.1}, \file{app.log.2}, up to
-\file{app.log.5}. The file being written to is always \file{app.log}.
-When this file is filled, it is closed and renamed to \file{app.log.1},
-and if files \file{app.log.1}, \file{app.log.2}, etc. exist, then they
-are renamed to \file{app.log.2}, \file{app.log.3} etc. respectively.
+appending extensions to the filename. The extensions are date-and-time
+based, using the strftime format \code{\%Y-\%m-\%d_\%H-\%M-\%S} or a leading
+portion thereof, depending on the rollover interval. At most \var{backupCount}
+files will be kept, and if more would be created when rollover occurs, the
+oldest one is deleted.
 \end{classdesc}
 
 \begin{methoddesc}{doRollover}{}
@@ -1539,7 +1537,7 @@
 To stop the server, call \function{stopListening()}. To send a configuration
 to the socket, read in the configuration file and send it to the socket
 as a string of bytes preceded by a four-byte length packed in binary using
-struct.\code{pack(">L", n)}.
+struct.\code{pack('>L', n)}.
 \end{funcdesc}
 
 \begin{funcdesc}{stopListening}{}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libmailbox.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libmailbox.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libmailbox.tex	Wed Aug  2 00:51:44 2006
@@ -1367,9 +1367,8 @@
         print subject
 \end{verbatim}
 
-A (surprisingly) simple example of copying all mail from a Babyl mailbox to an
-MH mailbox, converting all of the format-specific information that can be
-converted:
+To copy all mail from a Babyl mailbox to an MH mailbox, converting all
+of the format-specific information that can be converted:
 
 \begin{verbatim}
 import mailbox

Modified: python/branches/bcannon-sandboxing/Doc/lib/libmimetypes.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libmimetypes.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libmimetypes.tex	Wed Aug  2 00:51:44 2006
@@ -158,6 +158,20 @@
   \versionadded{2.2}
 \end{classdesc}
 
+An example usage of the module:
+
+\begin{verbatim}
+>>> import mimetypes
+>>> mimetypes.init()
+>>> mimetypes.knownfiles
+['/etc/mime.types', '/etc/httpd/mime.types', ... ]
+>>> mimetypes.suffix_map['.tgz']
+'.tar.gz'
+>>> mimetypes.encodings_map['.gz']
+'gzip'
+>>> mimetypes.types_map['.tgz']
+'application/x-tar-gz'
+\end{verbatim}
 
 \subsection{MimeTypes Objects \label{mimetypes-objects}}
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libnew.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libnew.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libnew.tex	Wed Aug  2 00:51:44 2006
@@ -30,13 +30,16 @@
 callable.
 \end{funcdesc}
 
-\begin{funcdesc}{function}{code, globals\optional{, name\optional{, argdefs}}}
+\begin{funcdesc}{function}{code, globals\optional{, name\optional{,
+                           argdefs\optional{, closure}}}}
 Returns a (Python) function with the given code and globals. If
 \var{name} is given, it must be a string or \code{None}.  If it is a
 string, the function will have the given name, otherwise the function
 name will be taken from \code{\var{code}.co_name}.  If
 \var{argdefs} is given, it must be a tuple and will be used to
-determine the default values of parameters.
+determine the default values of parameters.  If \var{closure} is given,
+it must be \code{None} or a tuple of cell objects containing objects
+to bind to the names in \code{\var{code}.co_freevars}.
 \end{funcdesc}
 
 \begin{funcdesc}{code}{argcount, nlocals, stacksize, flags, codestring,

Modified: python/branches/bcannon-sandboxing/Doc/lib/liboptparse.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/liboptparse.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/liboptparse.tex	Wed Aug  2 00:51:44 2006
@@ -1390,7 +1390,7 @@
 \end{verbatim}
 
 \end{itemize}
-% $Id: reference.txt 505 2005-07-22 01:52:40Z gward $ 
+% $Id: reference.txt 519 2006-06-11 14:39:11Z gward $ 
 
 
 \subsection{Option Callbacks\label{optparse-option-callbacks}}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libossaudiodev.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libossaudiodev.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libossaudiodev.tex	Wed Aug  2 00:51:44 2006
@@ -68,7 +68,7 @@
 Open an audio device and return an OSS audio device object.  This
 object supports many file-like methods, such as \method{read()},
 \method{write()}, and \method{fileno()} (although there are subtle
-differences between conventional Unix read/write semantics and those of
+differences between conventional \UNIX{} read/write semantics and those of
 OSS audio devices).  It also supports a number of audio-specific
 methods; see below for the complete list of methods.
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libpickle.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libpickle.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libpickle.tex	Wed Aug  2 00:51:44 2006
@@ -725,7 +725,50 @@
 
 \subsection{Example \label{pickle-example}}
 
-Here's a simple example of how to modify pickling behavior for a
+For the simplest code, use the \function{dump()} and \function{load()}
+functions.  Note that a self-referencing list is pickled and restored
+correctly.
+
+\begin{verbatim}
+import pickle
+
+data1 = {'a': [1, 2.0, 3, 4+6j],
+         'b': ('string', u'Unicode string'),
+         'c': None}
+
+selfref_list = [1, 2, 3]
+selfref_list.append(selfref_list)
+
+output = open('data.pkl', 'wb')
+
+# Pickle dictionary using protocol 0.
+pickle.dump(data1, output)
+
+# Pickle the list using the highest protocol available.
+pickle.dump(selfref_list, output, -1)
+
+output.close()
+\end{verbatim}
+
+The following example reads the resulting pickled data.  When reading
+a pickle-containing file, you should open the file in binary mode
+because you can't be sure if the ASCII or binary format was used.
+
+\begin{verbatim}
+import pprint, pickle
+
+pkl_file = open('data.pkl', 'rb')
+
+data1 = pickle.load(pkl_file)
+pprint.pprint(data1)
+
+data2 = pickle.load(pkl_file)
+pprint.pprint(data2)
+
+pkl_file.close()
+\end{verbatim}
+
+Here's a larger example that shows how to modify pickling behavior for a
 class.  The \class{TextReader} class opens a text file, and returns
 the line number and line contents each time its \method{readline()}
 method is called. If a \class{TextReader} instance is pickled, all

Modified: python/branches/bcannon-sandboxing/Doc/lib/libpkgutil.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libpkgutil.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libpkgutil.tex	Wed Aug  2 00:51:44 2006
@@ -30,7 +30,7 @@
   with \code{import}.  A \file{*.pkg} file is trusted at face value:
   apart from checking for duplicates, all entries found in a
   \file{*.pkg} file are added to the path, regardless of whether they
-  exist the filesystem.  (This is a feature.)
+  exist on the filesystem.  (This is a feature.)
 
   If the input path is not a list (as is the case for frozen
   packages) it is returned unchanged.  The input path is not

Modified: python/branches/bcannon-sandboxing/Doc/lib/libposixpath.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libposixpath.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libposixpath.tex	Wed Aug  2 00:51:44 2006
@@ -42,8 +42,11 @@
 \end{funcdesc}
 
 \begin{funcdesc}{exists}{path}
-Return \code{True} if \var{path} refers to an existing path.
-Returns \code{False} for broken symbolic links.
+Return \code{True} if \var{path} refers to an existing path.  Returns
+\code{False} for broken symbolic links. On some platforms, this
+function may return \code{False} if permission is not granted to
+execute \function{os.stat()} on the requested file, even if the
+\var{path} physically exists.
 \end{funcdesc}
 
 \begin{funcdesc}{lexists}{path}
@@ -190,9 +193,8 @@
 \end{funcdesc}
 
 \begin{funcdesc}{sameopenfile}{fp1, fp2}
-Return \code{True} if the file objects \var{fp1} and \var{fp2} refer to the
-same file.  The two file objects may represent different file
-descriptors.
+Return \code{True} if the file descriptors \var{fp1} and \var{fp2} refer
+to the same file.
 Availability:  Macintosh, \UNIX.
 \end{funcdesc}
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/librandom.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/librandom.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/librandom.tex	Wed Aug  2 00:51:44 2006
@@ -236,7 +236,7 @@
   \var{beta} is the shape parameter.
 \end{funcdesc}
 
-Alternative Generators
+Alternative Generators:
 
 \begin{classdesc}{WichmannHill}{\optional{seed}}
 Class that implements the Wichmann-Hill algorithm as the core generator.
@@ -267,6 +267,30 @@
 \versionadded{2.4}
 \end{classdesc}
 
+Examples of basic usage:
+
+\begin{verbatim}
+>>> random.random()        # Random float x, 0.0 <= x < 1.0
+0.37444887175646646
+>>> random.uniform(1, 10)  # Random float x, 1.0 <= x < 10.0
+1.1800146073117523
+>>> random.randint(1, 10)  # Integer from 1 to 10, endpoints included
+7
+>>> random.randrange(0, 101, 2)  # Even integer from 0 to 100
+26
+>>> random.choice('abcdefghij')  # Choose a random element
+'c'
+
+>>> items = [1, 2, 3, 4, 5, 6, 7]
+>>> random.shuffle(items)
+>>> items
+[7, 3, 2, 5, 6, 4, 1]
+
+>>> random.sample([1, 2, 3, 4, 5],  3)  # Choose 3 elements
+[4, 1, 5]
+
+\end{verbatim}
+
 \begin{seealso}
   \seetext{M. Matsumoto and T. Nishimura, ``Mersenne Twister: A
 	   623-dimensionally equidistributed uniform pseudorandom

Modified: python/branches/bcannon-sandboxing/Doc/lib/libre.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libre.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libre.tex	Wed Aug  2 00:51:44 2006
@@ -897,7 +897,7 @@
   \lineii{\code{\%d}}
          {\regexp{[-+]?\e d+}}
   \lineii{\code{\%e}, \code{\%E}, \code{\%f}, \code{\%g}}
-         {\regexp{[-+]?(\e d+(\e.\e d*)?|\e d*\e.\e d+)([eE][-+]?\e d+)?}}
+         {\regexp{[-+]?(\e d+(\e.\e d*)?|\e.\e d+)([eE][-+]?\e d+)?}}
   \lineii{\code{\%i}}
          {\regexp{[-+]?(0[xX][\e dA-Fa-f]+|0[0-7]*|\e d+)}}
   \lineii{\code{\%o}}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libreadline.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libreadline.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libreadline.tex	Wed Aug  2 00:51:44 2006
@@ -7,10 +7,13 @@
 \modulesynopsis{GNU readline support for Python.}
 
 
-The \module{readline} module defines a number of functions used either
-directly or from the \refmodule{rlcompleter} module to facilitate
-completion and history file read and write from the Python
-interpreter.
+The \module{readline} module defines a number of functions to
+facilitate completion and reading/writing of history files from the
+Python interpreter.  This module can be used directly or via the
+\refmodule{rlcompleter} module.  Settings made using 
+this module affect the behaviour of both the interpreter's interactive prompt 
+and the prompts offered by the \function{raw_input()} and \function{input()}
+built-in functions.
 
 The \module{readline} module defines the following functions:
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/librunpy.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/librunpy.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/librunpy.tex	Wed Aug  2 00:51:44 2006
@@ -35,19 +35,16 @@
 global variables below are defined in the supplied dictionary, those
 definitions are overridden by the \code{run_module} function.
 
-The special global variables \code{__name__}, \code{__module_name__},
-\code{__file__}, \code{__loader__} and \code{__builtins__} are
-set in the globals dictionary before the module code is executed.
+The special global variables \code{__name__}, \code{__file__},
+\code{__loader__} and \code{__builtins__} are set in the globals
+dictionary before the module code is executed.
 
 \code{__name__} is set to \var{run_name} if this optional argument is
 supplied, and the \var{mod_name} argument otherwise.
 
-\code{__module_name__} is always set to \var{mod_name} (this allows
-modules to use imports relative to their package name).
-
 \code{__loader__} is set to the PEP 302 module loader used to retrieve
-the code for the module (This will not be defined if the module was
-found using the standard import mechanism).
+the code for the module (This loader may be a wrapper around the
+standard import mechanism).
 
 \code{__file__} is set to the name provided by the module loader. If
 the loader does not make filename information available, this
@@ -58,12 +55,10 @@
 
 If the argument \var{alter_sys} is supplied and evaluates to
 \code{True}, then \code{sys.argv[0]} is updated with the value of
-\code{__file__} and \code{sys.modules[mod_name]} is updated with a
+\code{__file__} and \code{sys.modules[__name__]} is updated with a
 temporary module object for the module being executed. Both
-\code{sys.argv[0]} and \code{sys.modules[mod_name]} are restored to
-their original values before the function returns. If \var{run_name}
-differs from \var{mod_name} entries are made in \code{sys.modules}
-for both names.
+\code{sys.argv[0]} and \code{sys.modules[__name__]} are restored to
+their original values before the function returns.
 
 Note that this manipulation of \module{sys} is not thread-safe. Other
 threads may see the partially initialised module, as well as the

Modified: python/branches/bcannon-sandboxing/Doc/lib/libshelve.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libshelve.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libshelve.tex	Wed Aug  2 00:51:44 2006
@@ -143,15 +143,17 @@
 del d[key]      # delete data stored at key (raises KeyError
                 # if no such key)
 flag = d.has_key(key)   # true if the key exists
-list = d.keys() # a list of all existing keys (slow!)
+klist = d.keys() # a list of all existing keys (slow!)
 
 # as d was opened WITHOUT writeback=True, beware:
 d['xx'] = range(4)  # this works as expected, but...
 d['xx'].append(5)   # *this doesn't!* -- d['xx'] is STILL range(4)!!!
+
 # having opened d without writeback=True, you need to code carefully:
 temp = d['xx']      # extracts the copy
 temp.append(5)      # mutates the copy
 d['xx'] = temp      # stores the copy right back, to persist it
+
 # or, d=shelve.open(filename,writeback=True) would let you just code
 # d['xx'].append(5) and have it work as expected, BUT it would also
 # consume more memory and make the d.close() operation slower.

Modified: python/branches/bcannon-sandboxing/Doc/lib/libsocket.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libsocket.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libsocket.tex	Wed Aug  2 00:51:44 2006
@@ -711,6 +711,17 @@
 read until EOF. The return value is a string of the bytes read.
 \end{methoddesc}
 
+\begin{methoddesc}{server}{}
+Returns a string containing the ASN.1 distinguished name identifying the 
+server's certificate.  (See below for an example
+showing what distinguished names look like.)
+\end{methoddesc}
+
+\begin{methoddesc}{issuer}{}
+Returns a string containing the ASN.1 distinguished name identifying the
+issuer of the server's certificate.
+\end{methoddesc}
+
 \subsection{Example \label{socket-example}}
 
 Here are four minimal example programs using the TCP/IP protocol:\ a
@@ -833,3 +844,44 @@
 s.close()
 print 'Received', repr(data)
 \end{verbatim}
+
+This example connects to an SSL server, prints the 
+server and issuer's distinguished names, sends some bytes,
+and reads part of the response:
+
+\begin{verbatim}
+import socket
+
+s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+s.connect(('www.verisign.com', 443))
+
+ssl_sock = socket.ssl(s)
+
+print repr(ssl_sock.server())
+print repr(ssl_sock.issuer())
+
+# Set a simple HTTP request -- use httplib in actual code.
+ssl_sock.write("""GET / HTTP/1.0\r
+Host: www.verisign.com\r\n\r\n""")
+
+# Read a chunk of data.  Will not necessarily
+# read all the data returned by the server.
+data = ssl_sock.read()
+
+# Note that you need to close the underlying socket, not the SSL object.
+del ssl_sock
+s.close()
+\end{verbatim}
+
+At this writing, this SSL example prints the following output (line
+breaks inserted for readability):
+
+\begin{verbatim}
+'/C=US/ST=California/L=Mountain View/
+ O=VeriSign, Inc./OU=Production Services/
+ OU=Terms of use at www.verisign.com/rpa (c)00/
+ CN=www.verisign.com'
+'/O=VeriSign Trust Network/OU=VeriSign, Inc./
+ OU=VeriSign International Server CA - Class 3/
+ OU=www.verisign.com/CPS Incorp.by Ref. LIABILITY LTD.(c)97 VeriSign'
+\end{verbatim}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libsocksvr.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libsocksvr.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libsocksvr.tex	Wed Aug  2 00:51:44 2006
@@ -74,9 +74,9 @@
 \end{verbatim}
 
 Note that \class{UnixDatagramServer} derives from \class{UDPServer}, not
-from \class{UnixStreamServer} -- the only difference between an IP and a
-Unix stream server is the address family, which is simply repeated in both
-unix server classes.
+from \class{UnixStreamServer} --- the only difference between an IP and a
+\UNIX{} stream server is the address family, which is simply repeated in both
+\UNIX{} server classes.
 
 Forking and threading versions of each type of server can be created using
 the \class{ForkingMixIn} and \class{ThreadingMixIn} mix-in classes.  For

Modified: python/branches/bcannon-sandboxing/Doc/lib/libsqlite3.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libsqlite3.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libsqlite3.tex	Wed Aug  2 00:51:44 2006
@@ -512,10 +512,10 @@
 \class{object} as one of its bases.
 \end{notice}
 
-The \module{sqlite3} module has two default adapters for Python's builtin
-\class{datetime.date} and \class{datetime.datetime} types. Now let's suppose we
-want to store \class{datetime.datetime} objects not in ISO representation, but
-as Unix timestamp.
+The \module{sqlite3} module has two default adapters for Python's built-in
+\class{datetime.date} and \class{datetime.datetime} types.  Now let's suppose
+we want to store \class{datetime.datetime} objects not in ISO representation,
+but as a \UNIX{} timestamp.
 
     \verbatiminput{sqlite3/adapter_datetime.py}
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libstdtypes.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libstdtypes.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libstdtypes.tex	Wed Aug  2 00:51:44 2006
@@ -1,4 +1,4 @@
-\section{Built-in Types \label{types}}
+\chapter{Built-in Types \label{types}}
 
 The following sections describe the standard types that are built into
 the interpreter.
@@ -7,14 +7,14 @@
 the built-in types as the basis for object-oriented inheritance.
 This limitation does not exist any longer.}
 
-The principal built-in types are numerics, sequences, mappings, files
+The principal built-in types are numerics, sequences, mappings, files,
 classes, instances and exceptions.
 \indexii{built-in}{types}
 
 Some operations are supported by several object types; in particular,
 practically all objects can be compared, tested for truth value,
-and converted to a string (with the \code{`\textrm{\ldots}`} notation,
-the equivalent \function{repr()} function, or the slightly different
+and converted to a string (with
+the \function{repr()} function or the slightly different
 \function{str()} function).  The latter
 function is implicitly used when an object is written by the
 \keyword{print}\stindex{print} statement.
@@ -24,7 +24,7 @@
 \citetitle[../tut/tut.html]{Python Tutorial}.)
 
 
-\subsection{Truth Value Testing\label{truth}}
+\section{Truth Value Testing\label{truth}}
 
 Any object can be tested for truth value, for use in an \keyword{if} or
 \keyword{while} condition or as operand of the Boolean operations below.
@@ -71,7 +71,7 @@
 \index{False}
 \index{True}
 
-\subsection{Boolean Operations ---
+\section{Boolean Operations ---
 	    \keyword{and}, \keyword{or}, \keyword{not}
 	    \label{boolean}}
 
@@ -107,7 +107,7 @@
 \end{description}
 
 
-\subsection{Comparisons \label{comparisons}}
+\section{Comparisons \label{comparisons}}
 
 Comparison operations are supported by all objects.  They all have the
 same priority (which is higher than that of the Boolean operations).
@@ -174,7 +174,7 @@
 only by sequence types (below).
 
 
-\subsection{Numeric Types ---
+\section{Numeric Types ---
 	    \class{int}, \class{float}, \class{long}, \class{complex}
 	    \label{typesnumeric}}
 
@@ -307,7 +307,7 @@
 \end{description}
 % XXXJH exceptions: overflow (when? what operations?) zerodivision
 
-\subsubsection{Bit-string Operations on Integer Types \label{bitstring-ops}}
+\subsection{Bit-string Operations on Integer Types \label{bitstring-ops}}
 \nodename{Bit-string Operations}
 
 Plain and long integer types support additional operations that make
@@ -350,7 +350,7 @@
 \end{description}
 
 
-\subsection{Iterator Types \label{typeiter}}
+\section{Iterator Types \label{typeiter}}
 
 \versionadded{2.2}
 \index{iterator protocol}
@@ -414,7 +414,7 @@
 supplying the \method{__iter__()} and \method{next()} methods.
 
 
-\subsection{Sequence Types ---
+\section{Sequence Types ---
 	    \class{str}, \class{unicode}, \class{list},
 	    \class{tuple}, \class{buffer}, \class{xrange}
 	    \label{typesseq}}
@@ -566,7 +566,7 @@
 \end{description}
 
 
-\subsubsection{String Methods \label{string-methods}}
+\subsection{String Methods \label{string-methods}}
 \indexii{string}{methods}
 
 These are the string methods which both 8-bit strings and Unicode
@@ -901,7 +901,7 @@
 \end{methoddesc}
 
 
-\subsubsection{String Formatting Operations \label{typesseq-strings}}
+\subsection{String Formatting Operations \label{typesseq-strings}}
 
 \index{formatting, string (\%{})}
 \index{interpolation, string (\%{})}
@@ -1072,7 +1072,7 @@
 \refmodule{re}.\refstmodindex{re}
 
 
-\subsubsection{XRange Type \label{typesseq-xrange}}
+\subsection{XRange Type \label{typesseq-xrange}}
 
 The \class{xrange}\obindex{xrange} type is an immutable sequence which
 is commonly used for looping.  The advantage of the \class{xrange}
@@ -1084,7 +1084,7 @@
 iteration, and the \function{len()} function.
 
 
-\subsubsection{Mutable Sequence Types \label{typesseq-mutable}}
+\subsection{Mutable Sequence Types \label{typesseq-mutable}}
 
 List objects support additional operations that allow in-place
 modification of the object.
@@ -1216,7 +1216,7 @@
   that the list has been mutated during a sort.
 \end{description}
 
-\subsection{Set Types ---
+\section{Set Types ---
 	    \class{set}, \class{frozenset}
 	    \label{types-set}}
 \obindex{set}
@@ -1355,7 +1355,7 @@
 \end{seealso}
      
 
-\subsection{Mapping Types --- \class{dict} \label{typesmapping}}
+\section{Mapping Types --- \class{dict} \label{typesmapping}}
 \obindex{mapping}
 \obindex{dictionary}
 
@@ -1518,7 +1518,7 @@
 
 \end{description}
 
-\subsection{File Objects
+\section{File Objects
             \label{bltin-file-objects}}
 
 File objects\obindex{file} are implemented using C's \code{stdio}
@@ -1797,7 +1797,7 @@
 \end{memberdesc}
 
 
-\subsection{Context Manager Types \label{typecontextmanager}}
+\section{Context Manager Types \label{typecontextmanager}}
 
 \versionadded{2.5}
 \index{context manager}
@@ -1878,13 +1878,13 @@
 is negligible.
 
 
-\subsection{Other Built-in Types \label{typesother}}
+\section{Other Built-in Types \label{typesother}}
 
 The interpreter supports several other kinds of objects.
 Most of these support only one or two operations.
 
 
-\subsubsection{Modules \label{typesmodules}}
+\subsection{Modules \label{typesmodules}}
 
 The only special operation on a module is attribute access:
 \code{\var{m}.\var{name}}, where \var{m} is a module and \var{name}
@@ -1910,14 +1910,14 @@
 '/usr/local/lib/python\shortversion/os.pyc'>}.
 
 
-\subsubsection{Classes and Class Instances \label{typesobjects}}
+\subsection{Classes and Class Instances \label{typesobjects}}
 \nodename{Classes and Instances}
 
 See chapters 3 and 7 of the \citetitle[../ref/ref.html]{Python
 Reference Manual} for these.
 
 
-\subsubsection{Functions \label{typesfunctions}}
+\subsection{Functions \label{typesfunctions}}
 
 Function objects are created by function definitions.  The only
 operation on a function object is to call it:
@@ -1931,7 +1931,7 @@
 See the \citetitle[../ref/ref.html]{Python Reference Manual} for more
 information.
 
-\subsubsection{Methods \label{typesmethods}}
+\subsection{Methods \label{typesmethods}}
 \obindex{method}
 
 Methods are functions that are called using the attribute notation.
@@ -1976,7 +1976,7 @@
 information.
 
 
-\subsubsection{Code Objects \label{bltin-code-objects}}
+\subsection{Code Objects \label{bltin-code-objects}}
 \obindex{code}
 
 Code objects are used by the implementation to represent
@@ -1999,7 +1999,7 @@
 information.
 
 
-\subsubsection{Type Objects \label{bltin-type-objects}}
+\subsection{Type Objects \label{bltin-type-objects}}
 
 Type objects represent the various object types.  An object's type is
 accessed by the built-in function \function{type()}.  There are no special
@@ -2011,7 +2011,7 @@
 Types are written like this: \code{<type 'int'>}.
 
 
-\subsubsection{The Null Object \label{bltin-null-object}}
+\subsection{The Null Object \label{bltin-null-object}}
 
 This object is returned by functions that don't explicitly return a
 value.  It supports no special operations.  There is exactly one null
@@ -2020,7 +2020,7 @@
 It is written as \code{None}.
 
 
-\subsubsection{The Ellipsis Object \label{bltin-ellipsis-object}}
+\subsection{The Ellipsis Object \label{bltin-ellipsis-object}}
 
 This object is used by extended slice notation (see the
 \citetitle[../ref/ref.html]{Python Reference Manual}).  It supports no
@@ -2029,7 +2029,7 @@
 
 It is written as \code{Ellipsis}.
 
-\subsubsection{Boolean Values}
+\subsection{Boolean Values}
 
 Boolean values are the two constant objects \code{False} and
 \code{True}.  They are used to represent truth values (although other
@@ -2046,14 +2046,14 @@
 \indexii{Boolean}{values}
 
 
-\subsubsection{Internal Objects \label{typesinternal}}
+\subsection{Internal Objects \label{typesinternal}}
 
 See the \citetitle[../ref/ref.html]{Python Reference Manual} for this
 information.  It describes stack frame objects, traceback objects, and
 slice objects.
 
 
-\subsection{Special Attributes \label{specialattrs}}
+\section{Special Attributes \label{specialattrs}}
 
 The implementation adds a few special read-only attributes to several
 object types, where they are relevant.  Some of these are not reported

Modified: python/branches/bcannon-sandboxing/Doc/lib/libstringio.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libstringio.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libstringio.tex	Wed Aug  2 00:51:44 2006
@@ -37,6 +37,24 @@
 Free the memory buffer.
 \end{methoddesc}
 
+Example usage:
+
+\begin{verbatim}
+import StringIO
+
+output = StringIO.StringIO()
+output.write('First line.\n')
+print >>output, 'Second line.'
+
+# Retrieve file contents -- this will be
+# 'First line.\nSecond line.\n'
+contents = output.getvalue()
+
+# Close object and discard memory buffer -- 
+# .getvalue() will now raise an exception.
+output.close()
+\end{verbatim}
+
 
 \section{\module{cStringIO} ---
          Faster version of \module{StringIO}}
@@ -82,3 +100,22 @@
 
 There is a C API to the module as well; refer to the module source for 
 more information.
+
+Example usage:
+
+\begin{verbatim}
+import cStringIO
+
+output = cStringIO.StringIO()
+output.write('First line.\n')
+print >>output, 'Second line.'
+
+# Retrieve file contents -- this will be
+# 'First line.\nSecond line.\n'
+contents = output.getvalue()
+
+# Close object and discard memory buffer -- 
+# .getvalue() will now raise an exception.
+output.close()
+\end{verbatim}
+

Modified: python/branches/bcannon-sandboxing/Doc/lib/libsubprocess.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libsubprocess.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libsubprocess.tex	Wed Aug  2 00:51:44 2006
@@ -107,7 +107,7 @@
 
 If \var{universal_newlines} is \constant{True}, the file objects stdout
 and stderr are opened as text files, but lines may be terminated by
-any of \code{'\e n'}, the Unix end-of-line convention, \code{'\e r'},
+any of \code{'\e n'}, the \UNIX{} end-of-line convention, \code{'\e r'},
 the Macintosh convention or \code{'\e r\e n'}, the Windows convention.
 All of these external representations are seen as \code{'\e n'} by the
 Python program.  \note{This feature is only available if Python is built
@@ -140,7 +140,7 @@
 Run command with arguments.  Wait for command to complete. If the exit
 code was zero then return, otherwise raise \exception{CalledProcessError.}
 The \exception{CalledProcessError} object will have the return code in the
-\member{errno} attribute.
+\member{returncode} attribute.
 
 The arguments are the same as for the Popen constructor.  Example:
 
@@ -164,9 +164,8 @@
 A \exception{ValueError} will be raised if \class{Popen} is called
 with invalid arguments.
 
-check_call() will raise \exception{CalledProcessError}, which is a
-subclass of \exception{OSError}, if the called process returns a
-non-zero return code.
+check_call() will raise \exception{CalledProcessError}, if the called
+process returns a non-zero return code.
 
 
 \subsubsection{Security}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libsys.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libsys.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libsys.tex	Wed Aug  2 00:51:44 2006
@@ -21,7 +21,7 @@
 
 \begin{datadesc}{byteorder}
   An indicator of the native byte order.  This will have the value
-  \code{'big'} on big-endian (most-signigicant byte first) platforms,
+  \code{'big'} on big-endian (most-significant byte first) platforms,
   and \code{'little'} on little-endian (least-significant byte first)
   platforms.
   \versionadded{2.0}
@@ -41,7 +41,7 @@
   \code{Include/patchlevel.h} if the branch is a tag. Otherwise,
   it is \code{None}.
   \versionadded{2.5}
-\end{datadesc}  
+\end{datadesc}
 
 \begin{datadesc}{builtin_module_names}
   A tuple of strings giving the names of all modules that are compiled
@@ -55,6 +55,23 @@
   interpreter.
 \end{datadesc}
 
+\begin{funcdesc}{_current_frames}{}
+  Return a dictionary mapping each thread's identifier to the topmost stack
+  frame currently active in that thread at the time the function is called.
+  Note that functions in the \refmodule{traceback} module can build the
+  call stack given such a frame.
+
+  This is most useful for debugging deadlock:  this function does not
+  require the deadlocked threads' cooperation, and such threads' call stacks
+  are frozen for as long as they remain deadlocked.  The frame returned
+  for a non-deadlocked thread may bear no relationship to that thread's
+  current activity by the time calling code examines the frame.
+
+  This function should be used for internal and specialized purposes
+  only.
+  \versionadded{2.5}
+\end{funcdesc}
+
 \begin{datadesc}{dllhandle}
   Integer specifying the handle of the Python DLL.
   Availability: Windows.
@@ -142,7 +159,7 @@
   function, \function{exc_info()} will return three \code{None} values until
   another exception is raised in the current thread or the execution stack
   returns to a frame where another exception is being handled.
-  
+
   This function is only needed in only a few obscure situations.  These
   include logging and error handling systems that report information on the
   last or current exception.  This function can also be used to try to free
@@ -241,14 +258,14 @@
 \begin{itemize}
 \item On Windows 9x, the encoding is ``mbcs''.
 \item On Mac OS X, the encoding is ``utf-8''.
-\item On Unix, the encoding is the user's preference 
-      according to the result of nl_langinfo(CODESET), or None if
-      the nl_langinfo(CODESET) failed.
+\item On \UNIX, the encoding is the user's preference
+      according to the result of nl_langinfo(CODESET), or \constant{None}
+      if the \code{nl_langinfo(CODESET)} failed.
 \item On Windows NT+, file names are Unicode natively, so no conversion
-      is performed. \code{getfilesystemencoding} still returns ``mbcs'',
-      as this is the encoding that applications should use when they
-      explicitly want to convert Unicode strings to byte strings that
-      are equivalent when used as file names.
+      is performed. \function{getfilesystemencoding()} still returns
+      \code{'mbcs'}, as this is the encoding that applications should use
+      when they explicitly want to convert Unicode strings to byte strings
+      that are equivalent when used as file names.
 \end{itemize}
   \versionadded{2.3}
 \end{funcdesc}
@@ -279,8 +296,8 @@
 \end{funcdesc}
 
 \begin{funcdesc}{getwindowsversion}{}
-  Return a tuple containing five components, describing the Windows 
-  version currently running.  The elements are \var{major}, \var{minor}, 
+  Return a tuple containing five components, describing the Windows
+  version currently running.  The elements are \var{major}, \var{minor},
   \var{build}, \var{platform}, and \var{text}.  \var{text} contains
   a string while all other values are integers.
 
@@ -491,7 +508,7 @@
   be registered using \function{settrace()} for each thread being
   debugged.  \note{The \function{settrace()} function is intended only
   for implementing debuggers, profilers, coverage tools and the like.
-  Its behavior is part of the implementation platform, rather than 
+  Its behavior is part of the implementation platform, rather than
   part of the language definition, and thus may not be available in
   all Python implementations.}
 \end{funcdesc}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libtime.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libtime.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libtime.tex	Wed Aug  2 00:51:44 2006
@@ -226,6 +226,8 @@
 \versionchanged[Allowed \var{t} to be omitted]{2.1}
 \versionchanged[\exception{ValueError} raised if a field in \var{t} is
 out of range]{2.4}
+\versionchanged[0 is now a legal argument for any position in the time tuple;
+if it is normally illegal the value is forced to a correct one.]{2.5}
 
 
 The following directives can be embedded in the \var{format} string.
@@ -425,7 +427,7 @@
 '16:08:12 05/08/03 AEST'
 \end{verbatim}
 
-On many Unix systems (including *BSD, Linux, Solaris, and Darwin), it
+On many \UNIX{} systems (including *BSD, Linux, Solaris, and Darwin), it
 is more convenient to use the system's zoneinfo (\manpage{tzfile}{5}) 
 database to specify the timezone rules. To do this, set the 
 \envvar{TZ} environment variable to the path of the required timezone 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libturtle.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libturtle.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libturtle.tex	Wed Aug  2 00:51:44 2006
@@ -27,6 +27,45 @@
 Set angle measurement units to radians.
 \end{funcdesc}
 
+\begin{funcdesc}{setup}{**kwargs}
+Sets the size and position of the main window.  Keywords are:
+\begin{itemize}
+  \item \code{width}: either a size in pixels or a fraction of the screen.
+   The default is 50\% of the screen.
+  \item \code{height}: either a size in pixels or a fraction of the screen.
+   The default is 50\% of the screen.
+  \item \code{startx}: starting position in pixels from the left edge
+      of the screen. \code{None} is the default value and 
+      centers the window horizontally on screen.
+  \item \code{starty}: starting position in pixels from the top edge
+      of the screen. \code{None} is the default value and 
+      centers the window vertically on screen.
+\end{itemize}
+
+   Examples:
+
+\begin{verbatim}
+# Uses default geometry: 50% x 50% of screen, centered.
+setup()  
+
+# Sets window to 200x200 pixels, in upper left of screen
+setup (width=200, height=200, startx=0, starty=0)
+
+# Sets window to 75% of screen by 50% of screen, and centers it.
+setup(width=.75, height=0.5, startx=None, starty=None)
+\end{verbatim}
+
+\end{funcdesc}
+
+\begin{funcdesc}{title}{title_str}
+Set the window's title to \var{title}.
+\end{funcdesc}
+
+\begin{funcdesc}{done}{}
+Enters the Tk main loop.  The window will continue to 
+be displayed until the user closes it or the process is killed.
+\end{funcdesc}
+
 \begin{funcdesc}{reset}{}
 Clear the screen, re-center the pen, and set variables to the default
 values.
@@ -108,7 +147,9 @@
 \end{funcdesc}
 
 \begin{funcdesc}{begin\_fill}{}
-Switch turtle into filling mode; equivalent to \code{fill(1)}.
+Switch turtle into filling mode; 
+Must eventually be followed by a corresponding end_fill() call.
+Otherwise it will be ignored.
 \versionadded{2.5}
 \end{funcdesc}
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libtypes.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libtypes.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libtypes.tex	Wed Aug  2 00:51:44 2006
@@ -180,6 +180,30 @@
 \function{buffer()}\bifuncindex{buffer} function.
 \end{datadesc}
 
+\begin{datadesc}{DictProxyType}
+The type of dict proxies, such as \code{TypeType.__dict__}.
+\end{datadesc}
+
+\begin{datadesc}{NotImplementedType}
+The type of \code{NotImplemented}
+\end{datadesc}
+
+\begin{datadesc}{GetSetDescriptorType}
+The type of objects defined in extension modules with \code{PyGetSetDef}, such
+as \code{FrameType.f_locals} or \code{array.array.typecode}.  This constant is
+not defined in implementations of Python that do not have such extension
+types, so for portable code use \code{hasattr(types, 'GetSetDescriptorType')}.
+\versionadded{2.5}
+\end{datadesc}
+
+\begin{datadesc}{MemberDescriptorType}
+The type of objects defined in extension modules with \code{PyMemberDef}, such
+as \code {datetime.timedelta.days}.  This constant is not defined in
+implementations of Python that do not have such extension types, so for
+portable code use \code{hasattr(types, 'MemberDescriptorType')}.
+\versionadded{2.5}
+\end{datadesc}
+
 \begin{datadesc}{StringTypes}
 A sequence containing \code{StringType} and \code{UnicodeType} used to
 facilitate easier checking for any string object.  Using this is more

Modified: python/branches/bcannon-sandboxing/Doc/lib/libundoc.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libundoc.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libundoc.tex	Wed Aug  2 00:51:44 2006
@@ -49,7 +49,7 @@
 
 \item[\module{bsddb185}]
 --- Backwards compatibility module for systems which still use the Berkeley
-    DB 1.85 module.  It is normally only available on certain BSD Unix-based
+    DB 1.85 module.  It is normally only available on certain BSD \UNIX-based
     systems.  It should never be used directly.
 \end{description}
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libunicodedata.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libunicodedata.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libunicodedata.tex	Wed Aug  2 00:51:44 2006
@@ -14,11 +14,11 @@
 This module provides access to the Unicode Character Database which
 defines character properties for all Unicode characters. The data in
 this database is based on the \file{UnicodeData.txt} file version
-4.1.0 which is publically available from \url{ftp://ftp.unicode.org/}.
+4.1.0 which is publicly available from \url{ftp://ftp.unicode.org/}.
 
 The module uses the same names and symbols as defined by the
 UnicodeData File Format 4.1.0 (see
-\url{http://www.unicode.org/Public/4.1-Update/UnicodeData-4.1.0.html}).  It
+\url{http://www.unicode.org/Public/4.1.0/ucd/UCD.html}).  It
 defines the following functions:
 
 \begin{funcdesc}{lookup}{name}
@@ -108,7 +108,7 @@
 Normal form C (NFC) first applies a canonical decomposition, then
 composes pre-combined characters again.
 
-In addition to these two forms, there two additional normal forms
+In addition to these two forms, there are two additional normal forms
 based on compatibility equivalence. In Unicode, certain characters are
 supported which normally would be unified with other characters. For
 example, U+2160 (ROMAN NUMERAL ONE) is really the same thing as U+0049
@@ -139,3 +139,22 @@
 
 \versionadded{2.5}
 \end{datadesc}
+
+Examples:
+
+\begin{verbatim}
+>>> unicodedata.lookup('LEFT CURLY BRACKET')
+u'{'
+>>> unicodedata.name(u'/')
+'SOLIDUS'
+>>> unicodedata.decimal(u'9')
+9
+>>> unicodedata.decimal(u'a')
+Traceback (most recent call last):
+  File "<stdin>", line 1, in ?
+ValueError: not a decimal
+>>> unicodedata.category(u'A')  # 'L'etter, 'u'ppercase
+'Lu'   
+>>> unicodedata.bidirectional(u'\u0660') # 'A'rabic, 'N'umber
+'AN'
+\end{verbatim}

Modified: python/branches/bcannon-sandboxing/Doc/lib/liburllib.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/liburllib.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/liburllib.tex	Wed Aug  2 00:51:44 2006
@@ -270,10 +270,10 @@
 environmental proxy settings will be used if present, as discussed in
 the definition of \function{urlopen()}, above.
 
-Additional keyword parameters, collected in \var{x509}, are used for
-authentication with the \file{https:} scheme.  The keywords
-\var{key_file} and \var{cert_file} are supported; both are needed to
-actually retrieve a resource at an \file{https:} URL.
+Additional keyword parameters, collected in \var{x509}, may be used for
+authentication of the client when using the \file{https:} scheme.  The keywords
+\var{key_file} and \var{cert_file} are supported to provide an 
+SSL key and certificate; both are needed to support client authentication.
 
 \class{URLopener} objects will raise an \exception{IOError} exception
 if the server returns an error code.

Modified: python/branches/bcannon-sandboxing/Doc/lib/liburllib2.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/liburllib2.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/liburllib2.tex	Wed Aug  2 00:51:44 2006
@@ -19,7 +19,8 @@
 object.
 
 \var{data} may be a string specifying additional data to send to the
-server. Currently HTTP requests are the only ones that use \var{data};
+server, or \code{None} if no such data is needed. 
+Currently HTTP requests are the only ones that use \var{data};
 the HTTP request will be a POST instead of a GET when the \var{data}
 parameter is provided.  \var{data} should be a buffer in the standard
 \mimetype{application/x-www-form-urlencoded} format.  The
@@ -97,8 +98,17 @@
     \optional{, origin_req_host}\optional{, unverifiable}}
 This class is an abstraction of a URL request.
 
-\var{url} should be a string which is a valid URL.  For a description
-of \var{data} see the \method{add_data()} description.
+\var{url} should be a string containing a valid URL.  
+
+\var{data} may be a string specifying additional data to send to the
+server, or \code{None} if no such data is needed. 
+Currently HTTP requests are the only ones that use \var{data};
+the HTTP request will be a POST instead of a GET when the \var{data}
+parameter is provided.  \var{data} should be a buffer in the standard
+\mimetype{application/x-www-form-urlencoded} format.  The
+\function{urllib.urlencode()} function takes a mapping or sequence of
+2-tuples and returns a string in this format.
+
 \var{headers} should be a dictionary, and will be treated as if
 \method{add_header()} was called with each key and value as arguments.
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libuuid.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libuuid.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libuuid.tex	Wed Aug  2 00:51:44 2006
@@ -32,7 +32,7 @@
 
 Create a UUID from either a string of 32 hexadecimal digits,
 a string of 16 bytes as the \var{bytes} argument, a tuple of six
-integers (32-bit \var{time_low}, 16-bit \var{time_mid}, 
+integers (32-bit \var{time_low}, 16-bit \var{time_mid},
 16-bit \var{time_hi_version},
 8-bit \var{clock_seq_hi_variant}, 8-bit \var{clock_seq_low}, 48-bit \var{node})
 as the \var{fields} argument, or a single 128-bit integer as the \var{int}
@@ -109,10 +109,13 @@
 The \module{uuid} module defines the following functions
 
 \begin{funcdesc}{getnode}{}
-Get the hardware address as a 48-bit integer.  The first time this runs,
-it may launch a separate program, which could be quite slow.  If all
+Get the hardware address as a 48-bit positive integer.  The first time this
+runs, it may launch a separate program, which could be quite slow.  If all
 attempts to obtain the hardware address fail, we choose a random 48-bit
-number with its eighth bit set to 1 as recommended in RFC 4122.
+number with its eighth bit set to 1 as recommended in RFC 4122.  "Hardware
+address" means the MAC address of a network interface, and on a machine
+with multiple network interfaces the MAC address of any one of them may
+be returned.
 \end{funcdesc}
 \index{getnode}
 
@@ -126,10 +129,10 @@
 \index{uuid1}
 
 \begin{funcdesc}{uuid3}{namespace, name}
-Generate a UUID based upon a MD5 hash of the \var{name} string value 
-drawn from a specified namespace.   \var{namespace} 
+Generate a UUID based upon a MD5 hash of the \var{name} string value
+drawn from a specified namespace.   \var{namespace}
 must be one of \constant{NAMESPACE_DNS},
-\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID}, 
+\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID},
 or \constant{NAMESPACE_X500}.
 \end{funcdesc}
 \index{uuid3}
@@ -140,15 +143,15 @@
 \index{uuid4}
 
 \begin{funcdesc}{uuid5}{namespace, name}
-Generate a UUID based upon a SHA-1 hash of the \var{name} string value 
-drawn from a specified namespace.   \var{namespace} 
+Generate a UUID based upon a SHA-1 hash of the \var{name} string value
+drawn from a specified namespace.   \var{namespace}
 must be one of \constant{NAMESPACE_DNS},
-\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID}, 
+\constant{NAMESPACE_URL}, \constant{NAMESPACE_OID},
 or \constant{NAMESPACE_X500}.
 \end{funcdesc}
 \index{uuid5}
 
-The \module{uuid} module defines the following namespace constants 
+The \module{uuid} module defines the following namespace constants
 for use with \function{uuid3()} or \function{uuid5()}.
 
 \begin{datadesc}{NAMESPACE_DNS}
@@ -167,7 +170,7 @@
 X.500 DN namespace UUID.
 \end{datadesc}
 
-The \module{uuid} module defines the following constants 
+The \module{uuid} module defines the following constants
 for the possible values of the \member{variant} attribute:
 
 \begin{datadesc}{RESERVED_NCS}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libwarnings.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libwarnings.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libwarnings.tex	Wed Aug  2 00:51:44 2006
@@ -71,6 +71,11 @@
 \lineii{FutureWarning}{Base category for warnings about constructs
 that will change semantically in the future.}
 
+\lineii{PendingDeprecationWarning}{Base category for warnings about
+features that will be deprecated in the future (ignored by default).}
+
+\lineii{ImportWarning}{Base category for warnings triggered during the
+process of importing a module (ignored by default).}
 \end{tableii}
 
 While these are technically built-in exceptions, they are documented
@@ -143,6 +148,17 @@
 it is first imported (invalid options are ignored, after printing a
 message to \code{sys.stderr}).
 
+The warnings that are ignored by default may be enabled by passing
+ \programopt{-Wd} to the interpreter. This enables default handling
+for all warnings, including those that are normally ignored by
+default. This is particular useful for enabling ImportWarning when
+debugging problems importing a developed package. ImportWarning can
+also be enabled explicitly in Python code using:
+
+\begin{verbatim}
+    warnings.simplefilter('default', ImportWarning)
+\end{verbatim}
+
 
 \subsection{Available Functions \label{warning-functions}}
 
@@ -209,14 +225,26 @@
 inserted at the front by default; if \var{append} is true, it is
 inserted at the end.
 This checks the types of the arguments, compiles the message and
-module regular expressions, and inserts them as a tuple in front
-of the warnings filter.  Entries inserted later override entries
-inserted earlier, if both match a particular warning.  Omitted
-arguments default to a value that matches everything.
+module regular expressions, and inserts them as a tuple in the 
+list of warnings filters.  Entries closer to the front of the list
+override entries later in the list, if both match a particular
+warning.  Omitted arguments default to a value that matches
+everything.
+\end{funcdesc}
+
+\begin{funcdesc}{simplefilter}{action\optional{,
+                 category\optional{,
+                 lineno\optional{, append}}}}
+Insert a simple entry into the list of warnings filters. The meaning
+of the function parameters is as for \function{filterwarnings()}, but
+regular expressions are not needed as the filter inserted always
+matches any message in any module as long as the category and line
+number match.
 \end{funcdesc}
 
 \begin{funcdesc}{resetwarnings}{}
 Reset the warnings filter.  This discards the effect of all previous
 calls to \function{filterwarnings()}, including that of the
-\programopt{-W} command line options.
+\programopt{-W} command line options and calls to
+\function{simplefilter()}.
 \end{funcdesc}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libweakref.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libweakref.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libweakref.tex	Wed Aug  2 00:51:44 2006
@@ -65,10 +65,14 @@
 obj = Dict(red=1, green=2, blue=3)   # this object is weak referencable
 \end{verbatim}
 
-Extension types can easily be made to support weak references; see section
-\ref{weakref-extension}, ``Weak References in Extension Types,'' for more
-information.
-
+Extension types can easily be made to support weak references; see
+``\ulink{Weak Reference Support}{../ext/weakref-support.html}'' in
+\citetitle[../ext/ext.html]{Extending and Embedding the Python
+Interpreter}.
+% The referenced section used to appear in this document with the
+% \label weakref-extension.  It would be good to be able to generate a
+% redirect for the corresponding HTML page (weakref-extension.html)
+% for on-line versions of this document.
 
 \begin{classdesc}{ref}{object\optional{, callback}}
   Return a weak reference to \var{object}.  The original object can be
@@ -330,83 +334,3 @@
 def id2obj(oid):
     return _id2obj_dict[oid]
 \end{verbatim}
-
-
-\subsection{Weak References in Extension Types
-            \label{weakref-extension}}
-
-One of the goals of the implementation is to allow any type to
-participate in the weak reference mechanism without incurring the
-overhead on those objects which do not benefit by weak referencing
-(such as numbers).
-
-For an object to be weakly referencable, the extension must include a
-\ctype{PyObject*} field in the instance structure for the use of the
-weak reference mechanism; it must be initialized to \NULL{} by the
-object's constructor.  It must also set the \member{tp_weaklistoffset}
-field of the corresponding type object to the offset of the field.
-Also, it needs to add \constant{Py_TPFLAGS_HAVE_WEAKREFS} to the
-tp_flags slot.  For example, the instance type is defined with the
-following structure:
-
-\begin{verbatim}
-typedef struct {
-    PyObject_HEAD
-    PyClassObject *in_class;       /* The class object */
-    PyObject      *in_dict;        /* A dictionary */
-    PyObject      *in_weakreflist; /* List of weak references */
-} PyInstanceObject;
-\end{verbatim}
-
-The statically-declared type object for instances is defined this way:
-
-\begin{verbatim}
-PyTypeObject PyInstance_Type = {
-    PyObject_HEAD_INIT(&PyType_Type)
-    0,
-    "module.instance",
-
-    /* Lots of stuff omitted for brevity... */
-
-    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_WEAKREFS   /* tp_flags */
-    0,                                          /* tp_doc */
-    0,                                          /* tp_traverse */
-    0,                                          /* tp_clear */
-    0,                                          /* tp_richcompare */
-    offsetof(PyInstanceObject, in_weakreflist), /* tp_weaklistoffset */
-};
-\end{verbatim}
-
-The type constructor is responsible for initializing the weak reference
-list to \NULL:
-
-\begin{verbatim}
-static PyObject *
-instance_new() {
-    /* Other initialization stuff omitted for brevity */
-
-    self->in_weakreflist = NULL;
-
-    return (PyObject *) self;
-}
-\end{verbatim}
-
-The only further addition is that the destructor needs to call the
-weak reference manager to clear any weak references.  This should be
-done before any other parts of the destruction have occurred, but is
-only required if the weak reference list is non-\NULL:
-
-\begin{verbatim}
-static void
-instance_dealloc(PyInstanceObject *inst)
-{
-    /* Allocate temporaries if needed, but do not begin
-       destruction just yet.
-     */
-
-    if (inst->in_weakreflist != NULL)
-        PyObject_ClearWeakRefs((PyObject *) inst);
-
-    /* Proceed with object destruction normally. */
-}
-\end{verbatim}

Modified: python/branches/bcannon-sandboxing/Doc/lib/libwebbrowser.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libwebbrowser.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libwebbrowser.tex	Wed Aug  2 00:51:44 2006
@@ -136,6 +136,18 @@
 Only on MacOS X platform.
 \end{description}
 
+Here are some simple examples:
+
+\begin{verbatim}
+url = 'http://www.python.org'
+
+# Open URL in a new tab, if a browser window is already open. 
+webbrowser.open_new_tab(url + '/doc')
+
+# Open URL in new window, raising the window if possible.
+webbrowser.open_new(url)
+\end{verbatim}
+
 
 \subsection{Browser Controller Objects \label{browser-controllers}}
 

Modified: python/branches/bcannon-sandboxing/Doc/lib/libzipfile.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/libzipfile.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/libzipfile.tex	Wed Aug  2 00:51:44 2006
@@ -106,12 +106,12 @@
   is specified but the \refmodule{zlib} module is not available,
   \exception{RuntimeError} is also raised.  The default is
   \constant{ZIP_STORED}. 
-  If \var{allowZip64} is \code{True} zipfile will create zipfiles that use
-  the ZIP64 extensions when the zipfile is larger than 2GBytes. If it is 
-  false (the default) zipfile will raise an exception when the zipfile would
-  require ZIP64 extensions. ZIP64 extensions are disabled by default because
-  the default zip and unzip commands on Unix (the InfoZIP utilities) don't 
-  support these extensions.
+  If \var{allowZip64} is \code{True} zipfile will create ZIP files that use
+  the ZIP64 extensions when the zipfile is larger than 2 GB. If it is 
+  false (the default) \module{zipfile} will raise an exception when the
+  ZIP file would require ZIP64 extensions. ZIP64 extensions are disabled by
+  default because the default \program{zip} and \program{unzip} commands on
+  \UNIX{} (the InfoZIP utilities) don't support these extensions.
 \end{classdesc}
 
 \begin{methoddesc}{close}{}

Modified: python/branches/bcannon-sandboxing/Doc/lib/sqlite3/complete_statement.py
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/sqlite3/complete_statement.py	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/sqlite3/complete_statement.py	Wed Aug  2 00:51:44 2006
@@ -24,7 +24,7 @@
             if buffer.lstrip().upper().startswith("SELECT"):
                 print cur.fetchall()
         except sqlite3.Error, e:
-            print "An error occured:", e.args[0]
+            print "An error occurred:", e.args[0]
         buffer = ""
 
 con.close()

Modified: python/branches/bcannon-sandboxing/Doc/lib/tkinter.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/lib/tkinter.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/lib/tkinter.tex	Wed Aug  2 00:51:44 2006
@@ -18,10 +18,9 @@
 module \module{\_tkinter} provides a threadsafe mechanism which allows
 Python and Tcl to interact.
 
-Tk is not the only GUI for Python, but is however the most commonly
-used one; see section~\ref{other-gui-modules}, ``Other User Interface
-Modules and Packages,'' for more information on other GUI toolkits for
-Python.
+Tk is not the only GUI for Python; see
+section~\ref{other-gui-packages}, ``Other User Interface Modules and
+Packages,'' for more information on other GUI toolkits for Python.
 
 % Other sections I have in mind are
 % Tkinter internals
@@ -103,14 +102,14 @@
 \end{classdesc}
 
 \begin{funcdesc}{Tcl}{screenName=None, baseName=None, className='Tk', useTk=0}
-The \function{Tcl} function is a factory function which creates an object
-much like that created by the \class{Tk} class, except that it does not
-initialize the Tk subsystem.  This is most often useful when driving the Tcl
-interpreter in an environment where one doesn't want to create extraneous
-toplevel windows, or where one cannot (i.e. Unix/Linux systems without an X
-server).  An object created by the \function{Tcl} object can have a Toplevel
-window created (and the Tk subsystem initialized) by calling its
-\method{loadtk} method.
+The \function{Tcl} function is a factory function which creates an
+object much like that created by the \class{Tk} class, except that it
+does not initialize the Tk subsystem.  This is most often useful when
+driving the Tcl interpreter in an environment where one doesn't want
+to create extraneous toplevel windows, or where one cannot (such as
+\UNIX/Linux systems without an X server).  An object created by the
+\function{Tcl} object can have a Toplevel window created (and the Tk
+subsystem initialized) by calling its \method{loadtk} method.
 \versionadded{2.4}
 \end{funcdesc}
 
@@ -316,10 +315,10 @@
 periods.  For example, \code{.myApp.controlPanel.okButton} might be
 the name of a widget.
 
-\item[\var{options} ]
+\item[\var{options}]
 configure the widget's appearance and in some cases, its
 behavior.  The options come in the form of a list of flags and values.
-Flags are proceeded by a `-', like unix shell command flags, and
+Flags are proceeded by a `-', like \UNIX{} shell command flags, and
 values are put in quotes if they are more than one word.
 \end{description}
 
@@ -1806,24 +1805,29 @@
 through the Tk/Tcl layer.}
 \end{seealso*}
 
-
-Tk is not the only GUI for Python, but is however the
-most commonly used one.
+Other GUI packages are also available for Python:
 
 \begin{seealso*}
-\seetitle[http://www.wxwindows.org]{wxWindows}{
-is a GUI toolkit that combines the most attractive attributes of Qt,
-Tk, Motif, and GTK+ in one powerful and efficient package. It is
-implemented in \Cpp. wxWindows supports two flavors of \UNIX{}
-implementation: GTK+ and Motif, and under Windows, it has a standard
-Microsoft Foundation Classes (MFC) appearance, because it uses Win32
-widgets.  There is a Python class wrapper, independent of Tkinter.
-
-wxWindows is much richer in widgets than \refmodule{Tkinter}, with its
-help system, sophisticated HTML and image viewers, and other
-specialized widgets, extensive documentation, and printing capabilities.
+\seetitle[http://www.wxpython.org]{wxPython}{
+wxPython is a cross-platform GUI toolkit for Python that is built
+around the popular \ulink{wxWidgets}{http://www.wxwidgets.org/} \Cpp{}
+toolkit.  It provides a native look and feel for applications on
+Windows, Mac OS X, and \UNIX{} systems by using each platform's native
+widgets where ever possible, (GTK+ on \UNIX-like systems).  In
+addition to an extensive set of widgets, wxPython provides classes for
+online documentation and context sensitive help, printing, HTML
+viewing, low-level device context drawing, drag and drop, system
+clipboard access, an XML-based resource format and more, including an
+ever growing library of user-contributed modules.  Both the wxWidgets
+and wxPython projects are under active development and continuous
+improvement, and have active and helpful user and developer
+communities.
+}
+\seetitle[http://www.amazon.com/exec/obidos/ASIN/1932394621]
+{wxPython in Action}{
+The wxPython book, by Noel Rappin and Robin Dunn.
 }
-\seetitle[]{PyQt}{
+\seetitle{PyQt}{
 PyQt is a \program{sip}-wrapped binding to the Qt toolkit.  Qt is an
 extensive \Cpp{} GUI toolkit that is available for \UNIX, Windows and
 Mac OS X.  \program{sip} is a tool for generating bindings for \Cpp{}

Modified: python/branches/bcannon-sandboxing/Doc/mac/libmacfs.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/mac/libmacfs.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/mac/libmacfs.tex	Wed Aug  2 00:51:44 2006
@@ -22,10 +22,10 @@
 argument can be one of three things:\ (1) a full or partial Macintosh
 pathname, (2) an \class{FSSpec} object or (3) a 3-tuple
 \code{(\var{wdRefNum}, \var{parID}, \var{name})} as described in
-\citetitle{Inside Macintosh:\ Files}. An \class{FSSpec} can point to
+\citetitle{Inside Macintosh:\ Files}.  An \class{FSSpec} can point to
 a non-existing file, as long as the folder containing the file exists.
-Under MacPython the same is true for a pathname, but not under unix-Pyton
-because of the way pathnames and FSRefs works. See Apple's documentation
+Under MacPython the same is true for a pathname, but not under \UNIX-Python
+because of the way pathnames and FSRefs works.  See Apple's documentation
 for details.
 
 A description of aliases and the

Modified: python/branches/bcannon-sandboxing/Doc/mac/libmacos.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/mac/libmacos.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/mac/libmacos.tex	Wed Aug  2 00:51:44 2006
@@ -25,7 +25,7 @@
 incompatible between linking models, packages could use this information to give
 more decent error messages. The value is one of \code{'static'} for a
 statically linked Python, \code{'framework'} for Python in a Mac OS X framework,
-\code{'shared'} for Python in a standard unix shared library.
+\code{'shared'} for Python in a standard \UNIX{} shared library.
 Older Pythons could also have the value
 \code{'cfm'} for Mac OS 9-compatible Python.
 \end{datadesc}

Modified: python/branches/bcannon-sandboxing/Doc/mac/using.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/mac/using.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/mac/using.tex	Wed Aug  2 00:51:44 2006
@@ -6,7 +6,7 @@
 features such as the IDE and the Package Manager that are worth pointing out.
 
 Python on Mac OS 9 or earlier can be quite different from Python on
-Unix or Windows, but is beyond the scope of this manual, as that platform
+\UNIX{} or Windows, but is beyond the scope of this manual, as that platform
 is no longer supported, starting with Python 2.4. See
 \url{http://www.cwi.nl/\textasciitilde jack/macpython} for installers
 for the latest 2.3 release for Mac OS 9 and related documentation.

Modified: python/branches/bcannon-sandboxing/Doc/ref/ref3.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/ref/ref3.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/ref/ref3.tex	Wed Aug  2 00:51:44 2006
@@ -1886,6 +1886,9 @@
 \method{__pow__()} should be defined to accept an optional third
 argument if the ternary version of the built-in
 \function{pow()}\bifuncindex{pow} function is to be supported.
+
+If one of those methods does not support the operation with the
+supplied arguments, it should return \code{NotImplemented}.
 \end{methoddesc}
 
 \begin{methoddesc}[numeric object]{__div__}{self, other}
@@ -1937,7 +1940,7 @@
 
 \note{If the right operand's type is a subclass of the left operand's
       type and that subclass provides the reflected method for the
-      operation, this method will be called before the right operand's
+      operation, this method will be called before the left operand's
       non-reflected method.  This behavior allows subclasses to
       override their ancestors' operations.}
 \end{methoddesc}

Modified: python/branches/bcannon-sandboxing/Doc/tut/tut.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/tut/tut.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/tut/tut.tex	Wed Aug  2 00:51:44 2006
@@ -2919,14 +2919,13 @@
 
 The submodules often need to refer to each other.  For example, the
 \module{surround} module might use the \module{echo} module.  In fact,
-such references
-are so common that the \keyword{import} statement first looks in the
-containing package before looking in the standard module search path.
-Thus, the surround module can simply use \code{import echo} or
-\code{from echo import echofilter}.  If the imported module is not
-found in the current package (the package of which the current module
-is a submodule), the \keyword{import} statement looks for a top-level
-module with the given name.
+such references are so common that the \keyword{import} statement
+first looks in the containing package before looking in the standard
+module search path. Thus, the \module{surround} module can simply use
+\code{import echo} or \code{from echo import echofilter}.  If the
+imported module is not found in the current package (the package of
+which the current module is a submodule), the \keyword{import}
+statement looks for a top-level module with the given name.
 
 When packages are structured into subpackages (as with the
 \module{Sound} package in the example), there's no shortcut to refer
@@ -2936,6 +2935,24 @@
 in the \module{Sound.Effects} package, it can use \code{from
 Sound.Effects import echo}.
 
+Starting with Python 2.5, in addition to the implicit relative imports
+described above, you can write explicit relative imports with the
+\code{from module import name} form of import statement. These explicit
+relative imports use leading dots to indicate the current and parent
+packages involved in the relative import. From the \module{surround}
+module for example, you might use:
+
+\begin{verbatim}
+from . import echo
+from .. import Formats
+from ..Filters import equalizer
+\end{verbatim}
+
+Note that both explicit and implicit relative imports are based on the
+name of the current module. Since the name of the main module is always
+\code{"__main__"}, modules intended for use as the main module of a
+Python application should always use absolute imports.
+
 \subsection{Packages in Multiple Directories}
 
 Packages support one more special attribute, \member{__path__}.  This

Modified: python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew20.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew20.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew20.tex	Wed Aug  2 00:51:44 2006
@@ -216,7 +216,7 @@
 character properties.  For example, \code{unicodedata.category(u'A')}
 returns the 2-character string 'Lu', the 'L' denoting it's a letter,
 and 'u' meaning that it's uppercase.
-\code{u.bidirectional(u'\e x0660')} returns 'AN', meaning that U+0660 is
+\code{unicodedata.bidirectional(u'\e u0660')} returns 'AN', meaning that U+0660 is
 an Arabic number.
 
 The \module{codecs} module contains functions to look up existing encodings
@@ -571,7 +571,7 @@
 
 The \keyword{print} statement can now have its output directed to a
 file-like object by following the \keyword{print} with 
-\verb|>> file|, similar to the redirection operator in Unix shells.
+\verb|>> file|, similar to the redirection operator in \UNIX{} shells.
 Previously you'd either have to use the \method{write()} method of the
 file-like object, which lacks the convenience and simplicity of
 \keyword{print}, or you could assign a new value to 
@@ -894,7 +894,7 @@
 name.  This third argument is, respectively, a Python object, a C
 long, or a C string.
 
-A wrapper API was added for Unix-style signal handlers.
+A wrapper API was added for \UNIX-style signal handlers.
 \function{PyOS_getsig()} gets a signal handler and
 \function{PyOS_setsig()} will set a new handler.
 
@@ -905,7 +905,7 @@
 was no way to figure out automatically where Python is installed, or
 what compiler options to use for extension modules.  Software authors
 had to go through an arduous ritual of editing Makefiles and
-configuration files, which only really work on Unix and leave Windows
+configuration files, which only really work on \UNIX{} and leave Windows
 and MacOS unsupported.  Python users faced wildly differing
 installation instructions which varied between different extension
 packages, which made administering a Python installation something of 
@@ -1222,7 +1222,7 @@
 (Contributed by Peter Bosch, with fixes by Jeremy Hylton.)
 
 \item{\module{mmap}:} An interface to memory-mapped files on both
-Windows and Unix.  A file's contents can be mapped directly into
+Windows and \UNIX.  A file's contents can be mapped directly into
 memory, at which point it behaves like a mutable string, so its
 contents can be read and modified.  They can even be passed to
 functions that expect ordinary strings, such as the \module{re}
@@ -1262,7 +1262,7 @@
 
 \item{\module{zipfile}:} A module for reading and writing ZIP-format
 archives.  These are archives produced by \program{PKZIP} on
-DOS/Windows or \program{zip} on Unix, not to be confused with
+DOS/Windows or \program{zip} on \UNIX, not to be confused with
 \program{gzip}-format files (which are supported by the \module{gzip}
 module)
 (Contributed by James C. Ahlstrom.)

Modified: python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew21.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew21.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew21.tex	Wed Aug  2 00:51:44 2006
@@ -325,7 +325,7 @@
 When compiling Python, the user had to go in and edit the
 \file{Modules/Setup} file in order to enable various additional
 modules; the default set is relatively small and limited to modules
-that compile on most Unix platforms.  This means that on Unix
+that compile on most \UNIX{} platforms.  This means that on \Unix{}
 platforms with many more features, most notably Linux, Python
 installations often don't contain all useful modules they could.
 
@@ -661,7 +661,7 @@
 \item The \module{difflib} module contains a class,
 \class{SequenceMatcher}, which compares two sequences and computes the
 changes required to transform one sequence into the other.  For
-example, this module can be used to write a tool similar to the Unix
+example, this module can be used to write a tool similar to the \UNIX{}
 \program{diff} program, and in fact the sample program
 \file{Tools/scripts/ndiff.py} demonstrates how to write such a script.  
 

Modified: python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew23.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew23.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew23.tex	Wed Aug  2 00:51:44 2006
@@ -1979,7 +1979,7 @@
 
 The \module{getopt} module provides simple parsing of command-line
 arguments.  The new \module{optparse} module (originally named Optik)
-provides more elaborate command-line parsing that follows the Unix
+provides more elaborate command-line parsing that follows the \UNIX{}
 conventions, automatically creates the output for \longprogramopt{help},
 and can perform different actions for different options.
 

Modified: python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew24.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew24.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew24.tex	Wed Aug  2 00:51:44 2006
@@ -162,7 +162,7 @@
 
 Generator expressions always have to be written inside parentheses, as
 in the above example.  The parentheses signalling a function call also
-count, so if you want to create a iterator that will be immediately
+count, so if you want to create an iterator that will be immediately
 passed to a function you could write:
 
 \begin{verbatim}

Modified: python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew25.tex
==============================================================================
--- python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew25.tex	(original)
+++ python/branches/bcannon-sandboxing/Doc/whatsnew/whatsnew25.tex	Wed Aug  2 00:51:44 2006
@@ -6,7 +6,7 @@
 % Count up the patches and bugs
 
 \title{What's New in Python 2.5}
-\release{0.3}
+\release{0.4}
 \author{A.M. Kuchling}
 \authoraddress{\email{amk at amk.ca}}
 
@@ -74,7 +74,7 @@
 Candidates included C's \code{cond ? true_v : false_v},
 \code{if cond then true_v else false_v}, and 16 other variations.
 
-GvR eventually chose a surprising syntax:
+Guido van~Rossum eventually chose a surprising syntax:
 
 \begin{verbatim}
 x = true_value if condition else false_value
@@ -407,7 +407,7 @@
 combined version was complicated and it wasn't clear what the
 semantics of the combined should be.  
 
-GvR spent some time working with Java, which does support the
+Guido van~Rossum spent some time working with Java, which does support the
 equivalent of combining \keyword{except} blocks and a
 \keyword{finally} block, and this clarified what the statement should
 mean.  In Python 2.5, you can now write:
@@ -600,7 +600,11 @@
 \seepep{342}{Coroutines via Enhanced Generators}{PEP written by 
 Guido van~Rossum and Phillip J. Eby;
 implemented by Phillip J. Eby.  Includes examples of 
-some fancier uses of generators as coroutines.}
+some fancier uses of generators as coroutines.
+
+Earlier versions of these features were proposed in 
+\pep{288} by Raymond Hettinger and \pep{325} by Samuele Pedroni.
+}
 
 \seeurl{http://en.wikipedia.org/wiki/Coroutine}{The Wikipedia entry for 
 coroutines.}
@@ -1152,8 +1156,8 @@
 false values.  \function{any()} returns \constant{True} if any value
 returned by the iterator is true; otherwise it will return
 \constant{False}.  \function{all()} returns \constant{True} only if
-all of the values returned by the iterator evaluate as being true.
-(Suggested by GvR, and implemented by Raymond Hettinger.)
+all of the values returned by the iterator evaluate as true.
+(Suggested by Guido van~Rossum, and implemented by Raymond Hettinger.)
 
 \item ASCII is now the default encoding for modules.  It's now 
 a syntax error if a module contains string literals with 8-bit
@@ -1170,19 +1174,12 @@
 to include an \file{__init__.py} module in a package directory.
 Debugging this mistake can be confusing, and usually requires running
 Python with the \programopt{-v} switch to log all the paths searched.
-In Python 2.5, a new \exception{ImportWarning} warning is raised when
+In Python 2.5, a new \exception{ImportWarning} warning is triggered when
 an import would have picked up a directory as a package but no
-\file{__init__.py} was found.  (Implemented by Thomas Wouters.)
-
-To suppress these warnings, you can either supply 
-\code{\programopt{-W}'ignore:Not importing directory'} when running the Python
-interpreter, or use the \module{warnings} module to suppress the
-message:
-
-\begin{verbatim}
-warnings.filterwarnings('ignore', 'Not importing directory',
-                        ImportWarning)
-\end{verbatim}
+\file{__init__.py} was found.  This warning is silently ignored by default;
+provide the \programopt{-Wd} option when running the Python executable
+to display the warning message.
+(Implemented by Thomas Wouters.)
 
 \item The list of base classes in a class definition can now be empty.  
 As an example, this is now legal:
@@ -1213,6 +1210,11 @@
 Newbies who try \code{quit()} or \code{exit()} will now exit the
 interpreter as they expect.  (Implemented by Georg Brandl.)
 
+The Python executable now accepts the standard long options 
+\longprogramopt{help} and \longprogramopt{version}; on Windows, 
+it also accepts the \programopt{/?} option for displaying a help message.
+(Implemented by Georg Brandl.)
+
 
 %======================================================================
 \subsection{Optimizations\label{opts}}
@@ -1261,7 +1263,8 @@
 \item The code generator's peephole optimizer now performs
 simple constant folding in expressions.  If you write something like
 \code{a = 2+3}, the code generator will do the arithmetic and produce
-code corresponding to \code{a = 5}.
+code corresponding to \code{a = 5}.  (Proposed and implemented 
+by Raymond Hettinger.)
 
 \item Function calls are now faster because code objects now keep 
 the most recently finished frame (a ``zombie frame'') in an internal
@@ -1355,10 +1358,13 @@
         'r': ['ritrovai'], 'u': ['una'], 'v': ['vita', 'via']}
 \end{verbatim}
 
-The \class{deque} double-ended queue type supplied by the
+(Contributed by Guido van~Rossum.)
+
+\item The \class{deque} double-ended queue type supplied by the
 \module{collections} module now has a \method{remove(\var{value})}
 method that removes the first occurrence of \var{value} in the queue,
 raising \exception{ValueError} if the value isn't found.
+(Contributed by Raymond Hettinger.)
 
 \item New module: The \module{contextlib} module contains helper functions for use 
 with the new '\keyword{with}' statement.  See
@@ -1387,6 +1393,17 @@
 \member{line_num} attribute that counts the number of physical lines
 read from the source; records can span multiple physical lines, so
 \member{line_num} is not the same as the number of records read.
+
+The CSV parser is now stricter about multi-line quoted
+fields. Previously, if a line ended within a quoted field without a
+terminating newline character, a newline would be inserted into the
+returned field. This behavior caused problems when reading files that
+contained carriage return characters within fields, so the code was
+changed to return the field without inserting newlines. As a
+consequence, if newlines embedded within fields are important, the
+input should be split into lines in a manner that preserves the
+newline characters.
+
 (Contributed by Skip Montanaro and Andrew McNamara.)
 
 \item The \class{datetime} class in the \module{datetime} 
@@ -1647,7 +1664,7 @@
 \end{verbatim}
 
 You can also pack and unpack data to and from buffer objects directly
-using the \method{pack_to(\var{buffer}, \var{offset}, \var{v1},
+using the \method{pack_into(\var{buffer}, \var{offset}, \var{v1},
 \var{v2}, ...)} and \method{unpack_from(\var{buffer}, \var{offset})}
 methods.  This lets you store data directly into an array or a
 memory-mapped file.
@@ -1669,14 +1686,20 @@
 \code{"trunk:45355:45356M, Apr 13 2006, 07:42:19"}.  
 (Contributed by Barry Warsaw.)
 
+\item Another new function, \function{sys._current_frames()}, returns
+the current stack frames for all running threads as a dictionary
+mapping thread identifiers to the topmost stack frame currently active
+in that thread at the time the function is called.  (Contributed by
+Tim Peters.)
+
 \item The \class{TarFile} class in the \module{tarfile} module now has
 an \method{extractall()} method that extracts all members from the
 archive into the current working directory.  It's also possible to set
 a different directory as the extraction target, and to unpack only a
-subset of the archive's members.  
+subset of the archive's members.
 
-A tarfile's compression can be autodetected by 
-using the mode \code{'r|*'}.
+The compression used for a tarfile opened in stream mode can now be
+autodetected using the mode \code{'r|*'}.
 % patch 918101
 (Contributed by Lars Gust\"abel.)
 
@@ -1748,13 +1771,6 @@
 Brandl.)
 % Patch #754022
 
-\item The standard library's XML-related package
-has been renamed to \module{xmlcore}.  The \module{xml} module will
-now import either the \module{xmlcore} or PyXML version of subpackages
-such as \module{xml.dom}.  The renaming means it will always be
-possible to import the standard library's XML support whether or not
-the PyXML package is installed.
-
 \item The \module{xmlrpclib} module now supports returning 
       \class{datetime} objects for the XML-RPC date type.  Supply 
       \code{use_datetime=True} to the \function{loads()} function
@@ -2193,6 +2209,11 @@
 
 \begin{itemize}
 
+\item The Python source tree was converted from CVS to Subversion, 
+in a complex migration procedure that was supervised and flawlessly
+carried out by Martin von~L\"owis.  The procedure was developed as
+\pep{347}.
+
 \item The largest change to the C API came from \pep{353},
 which modifies the interpreter to use a \ctype{Py_ssize_t} type
 definition instead of \ctype{int}.  See the earlier
@@ -2270,6 +2291,13 @@
 \var{dict})} can now accept a tuple of base classes as its \var{base}
 argument.  (Contributed by Georg Brandl.)
 
+\item The \cfunction{PyErr_Warn()} function for issuing warnings
+is now deprecated in favour of \cfunction{PyErr_WarnEx(category,
+message, stacklevel)} which lets you specify the number of stack
+frames separating this function and the caller.  A \var{stacklevel} of
+1 is the function calling \cfunction{PyErr_WarnEx()}, 2 is the
+function above that, and so forth.  (Added by Neal Norwitz.)
+
 \item The CPython interpreter is still written in C, but 
 the code can now be compiled with a {\Cpp} compiler without errors.  
 (Implemented by Anthony Baxter, Martin von~L\"owis, Skip Montanaro.)
@@ -2312,7 +2340,7 @@
 
 As usual, there were a bunch of other improvements and bugfixes
 scattered throughout the source tree.  A search through the SVN change
-logs finds there were XXX patches applied and YYY bugs fixed between
+logs finds there were 334 patches applied and 443 bugs fixed between
 Python 2.4 and 2.5.  Both figures are likely to be underestimates.
 
 Some of the more notable changes are:
@@ -2373,6 +2401,10 @@
 described in section~\ref{pep-342}, it's now possible
 for \member{gi_frame} to be \code{None}.
 
+\item Library: the \module{csv} module is now stricter about multi-line quoted
+fields.  If your files contain newlines embedded within fields, the
+input should be split into lines in a manner which preserves the
+newline characters.
 
 \item Library: The \module{pickle} and \module{cPickle} modules no
 longer accept a return value of \code{None} from the
@@ -2387,10 +2419,6 @@
 \member{rpc_paths} to \code{None} or an empty tuple disables 
 this path checking.
 
-\item Library: the \module{xml} package has been renamed to \module{xmlcore}.
-The PyXML package will therefore be \module{xml}, and the Python
-distribution's code will always be accessible as \module{xmlcore}.
-
 \item C API: Many functions now use \ctype{Py_ssize_t} 
 instead of \ctype{int} to allow processing more data on 64-bit
 machines.  Extension code may need to make the same change to avoid
@@ -2413,8 +2441,10 @@
 
 The author would like to thank the following people for offering
 suggestions, corrections and assistance with various drafts of this
-article: Nick Coghlan, Phillip J. Eby, Ralf W. Grosse-Kunstleve, Kent
-Johnson, Martin von~L\"owis, Fredrik Lundh, Gustavo Niemeyer, James
-Pryor, Mike Rovner, Scott Weikart, Barry Warsaw, Thomas Wouters.
+article: Nick Coghlan, Phillip J. Eby, Lars Gust\"abel, Raymond Hettinger, Ralf
+W. Grosse-Kunstleve, Kent Johnson, Martin von~L\"owis, Fredrik Lundh,
+Andrew McNamara, Skip Montanaro,
+Gustavo Niemeyer, James Pryor, Mike Rovner, Scott Weikart, Barry
+Warsaw, Thomas Wouters.
 
 \end{document}

Modified: python/branches/bcannon-sandboxing/Include/patchlevel.h
==============================================================================
--- python/branches/bcannon-sandboxing/Include/patchlevel.h	(original)
+++ python/branches/bcannon-sandboxing/Include/patchlevel.h	Wed Aug  2 00:51:44 2006
@@ -23,10 +23,10 @@
 #define PY_MINOR_VERSION	5
 #define PY_MICRO_VERSION	0
 #define PY_RELEASE_LEVEL	PY_RELEASE_LEVEL_BETA
-#define PY_RELEASE_SERIAL	1
+#define PY_RELEASE_SERIAL	2
 
 /* Version as a string */
-#define PY_VERSION		"2.5b1"
+#define PY_VERSION		"2.5b2"
 
 /* Subversion Revision number of this file (not of the repository) */
 #define PY_PATCHLEVEL_REVISION  "$Revision$"

Modified: python/branches/bcannon-sandboxing/Include/pyerrors.h
==============================================================================
--- python/branches/bcannon-sandboxing/Include/pyerrors.h	(original)
+++ python/branches/bcannon-sandboxing/Include/pyerrors.h	Wed Aug  2 00:51:44 2006
@@ -225,10 +225,14 @@
 PyAPI_FUNC(void) PyErr_WriteUnraisable(PyObject *);
 
 /* Issue a warning or exception */
-PyAPI_FUNC(int) PyErr_Warn(PyObject *, char *);
+PyAPI_FUNC(int) PyErr_WarnEx(PyObject *category, const char *msg,
+			     Py_ssize_t stack_level);
 PyAPI_FUNC(int) PyErr_WarnExplicit(PyObject *, const char *,
 				   const char *, int, 
 				   const char *, PyObject *);
+/* PyErr_Warn is only for backwards compatability and will be removed.
+   Use PyErr_WarnEx instead. */
+#define PyErr_Warn(category, msg) PyErr_WarnEx(category, msg, 1)
 
 /* In sigcheck.c or signalmodule.c */
 PyAPI_FUNC(int) PyErr_CheckSignals(void);

Modified: python/branches/bcannon-sandboxing/Include/pystate.h
==============================================================================
--- python/branches/bcannon-sandboxing/Include/pystate.h	(original)
+++ python/branches/bcannon-sandboxing/Include/pystate.h	Wed Aug  2 00:51:44 2006
@@ -180,6 +180,11 @@
 */
 PyAPI_FUNC(PyThreadState *) PyGILState_GetThisThreadState(void);
 
+/* The implementation of sys._current_frames()  Returns a dict mapping
+   thread id to that thread's current frame.
+*/
+PyAPI_FUNC(PyObject *) _PyThread_CurrentFrames(void);
+
 /* Routines for advanced debuggers, requested by David Beazley.
    Don't use unless you know what you are doing! */
 PyAPI_FUNC(PyInterpreterState *) PyInterpreterState_Head(void);

Modified: python/branches/bcannon-sandboxing/Lib/binhex.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/binhex.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/binhex.py	Wed Aug  2 00:51:44 2006
@@ -44,22 +44,14 @@
 
 #
 # Workarounds for non-mac machines.
-if os.name == 'mac':
-    import macfs
-    import MacOS
-    try:
-        openrf = MacOS.openrf
-    except AttributeError:
-        # Backward compatibility
-        openrf = open
-
-    def FInfo():
-        return macfs.FInfo()
+try:
+    from Carbon.File import FSSpec, FInfo
+    from MacOS import openrf
 
     def getfileinfo(name):
-        finfo = macfs.FSSpec(name).GetFInfo()
+        finfo = FSSpec(name).FSpGetFInfo()
         dir, file = os.path.split(name)
-        # XXXX Get resource/data sizes
+        # XXX Get resource/data sizes
         fp = open(name, 'rb')
         fp.seek(0, 2)
         dlen = fp.tell()
@@ -75,7 +67,7 @@
             mode = '*' + mode[0]
         return openrf(name, mode)
 
-else:
+except ImportError:
     #
     # Glue code for non-macintosh usage
     #
@@ -183,7 +175,7 @@
             ofname = ofp
             ofp = open(ofname, 'w')
             if os.name == 'mac':
-                fss = macfs.FSSpec(ofname)
+                fss = FSSpec(ofname)
                 fss.SetCreatorType('BnHq', 'TEXT')
         ofp.write('(This file must be converted with BinHex 4.0)\n\n:')
         hqxer = _Hqxcoderengine(ofp)
@@ -486,7 +478,7 @@
     if not out:
         out = ifp.FName
     if os.name == 'mac':
-        ofss = macfs.FSSpec(out)
+        ofss = FSSpec(out)
         out = ofss.as_pathname()
 
     ofp = open(out, 'wb')
@@ -519,6 +511,7 @@
 
 def _test():
     if os.name == 'mac':
+        import macfs
         fss, ok = macfs.PromptGetFile('File to convert:')
         if not ok:
             sys.exit(0)

Modified: python/branches/bcannon-sandboxing/Lib/bsddb/test/test_basics.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/bsddb/test/test_basics.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/bsddb/test/test_basics.py	Wed Aug  2 00:51:44 2006
@@ -562,6 +562,9 @@
         num = d.truncate()
         assert num == 0, "truncate on empty DB returned nonzero (%r)" % (num,)
 
+    #----------------------------------------
+
+
 #----------------------------------------------------------------------
 
 
@@ -583,18 +586,40 @@
     dbopenflags = db.DB_THREAD
 
 
-class BasicBTreeWithEnvTestCase(BasicTestCase):
-    dbtype = db.DB_BTREE
+class BasicWithEnvTestCase(BasicTestCase):
     dbopenflags = db.DB_THREAD
     useEnv = 1
     envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
 
+    #----------------------------------------
+
+    def test07_EnvRemoveAndRename(self):
+        if not self.env:
+            return
+
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test07_EnvRemoveAndRename..." % self.__class__.__name__
+
+        # can't rename or remove an open DB
+        self.d.close()
+
+        newname = self.filename + '.renamed'
+        self.env.dbrename(self.filename, None, newname)
+        self.env.dbremove(newname)
+
+    # dbremove and dbrename are in 4.1 and later
+    if db.version() < (4,1):
+        del test07_EnvRemoveAndRename
+
+    #----------------------------------------
+
+class BasicBTreeWithEnvTestCase(BasicWithEnvTestCase):
+    dbtype = db.DB_BTREE
+
 
-class BasicHashWithEnvTestCase(BasicTestCase):
+class BasicHashWithEnvTestCase(BasicWithEnvTestCase):
     dbtype = db.DB_HASH
-    dbopenflags = db.DB_THREAD
-    useEnv = 1
-    envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
 
 
 #----------------------------------------------------------------------

Modified: python/branches/bcannon-sandboxing/Lib/compiler/future.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/compiler/future.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/compiler/future.py	Wed Aug  2 00:51:44 2006
@@ -23,14 +23,7 @@
 
     def visitModule(self, node):
         stmt = node.node
-        found_docstring = False
         for s in stmt.nodes:
-            # Skip over docstrings
-            if not found_docstring and isinstance(s, ast.Discard) \
-               and isinstance(s.expr, ast.Const) \
-               and isinstance(s.expr.value, str):
-                found_docstring = True
-                continue
             if not self.check_stmt(s):
                 break
 

Modified: python/branches/bcannon-sandboxing/Lib/compiler/transformer.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/compiler/transformer.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/compiler/transformer.py	Wed Aug  2 00:51:44 2006
@@ -1382,6 +1382,7 @@
     symbol.testlist,
     symbol.testlist_safe,
     symbol.test,
+    symbol.or_test,
     symbol.and_test,
     symbol.not_test,
     symbol.comparison,

Modified: python/branches/bcannon-sandboxing/Lib/ctypes/__init__.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/ctypes/__init__.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/ctypes/__init__.py	Wed Aug  2 00:51:44 2006
@@ -5,7 +5,7 @@
 
 import os as _os, sys as _sys
 
-__version__ = "0.9.9.7"
+__version__ = "1.0.0"
 
 from _ctypes import Union, Structure, Array
 from _ctypes import _Pointer
@@ -22,6 +22,23 @@
 if _os.name in ("nt", "ce"):
     from _ctypes import FormatError
 
+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.
+
+    if gestalt.gestalt("sysv") < 0x1040:
+        DEFAULT_MODE = RTLD_GLOBAL
+
 from _ctypes import FUNCFLAG_CDECL as _FUNCFLAG_CDECL, \
      FUNCFLAG_PYTHONAPI as _FUNCFLAG_PYTHONAPI
 
@@ -284,7 +301,7 @@
         _flags_ = _FUNCFLAG_CDECL
         _restype_ = c_int # default, can be overridden in instances
 
-    def __init__(self, name, mode=RTLD_LOCAL, handle=None):
+    def __init__(self, name, mode=DEFAULT_MODE, handle=None):
         self._name = name
         if handle is None:
             self._handle = _dlopen(self._name, mode)
@@ -300,13 +317,14 @@
     def __getattr__(self, name):
         if name.startswith('__') and name.endswith('__'):
             raise AttributeError, name
-        return self.__getitem__(name)
+        func = self.__getitem__(name)
+        setattr(self, name, func)
+        return func
 
     def __getitem__(self, name_or_ordinal):
         func = self._FuncPtr((name_or_ordinal, self))
         if not isinstance(name_or_ordinal, (int, long)):
             func.__name__ = name_or_ordinal
-            setattr(self, name_or_ordinal, func)
         return func
 
 class PyDLL(CDLL):
@@ -446,52 +464,21 @@
         return _wstring_at(ptr, size)
 
 
-if _os.name == "nt": # COM stuff
+if _os.name in ("nt", "ce"): # COM stuff
     def DllGetClassObject(rclsid, riid, ppv):
-        # First ask ctypes.com.server than comtypes.server for the
-        # class object.
-
-        # trick py2exe by doing dynamic imports
-        result = -2147221231 # CLASS_E_CLASSNOTAVAILABLE
         try:
-            ctcom = __import__("ctypes.com.server", globals(), locals(), ['*'])
+            ccom = __import__("comtypes.server.inprocserver", globals(), locals(), ['*'])
         except ImportError:
-            pass
+            return -2147221231 # CLASS_E_CLASSNOTAVAILABLE
         else:
-            result = ctcom.DllGetClassObject(rclsid, riid, ppv)
-
-        if result == -2147221231: # CLASS_E_CLASSNOTAVAILABLE
-            try:
-                ccom = __import__("comtypes.server", globals(), locals(), ['*'])
-            except ImportError:
-                pass
-            else:
-                result = ccom.DllGetClassObject(rclsid, riid, ppv)
-
-        return result
+            return ccom.DllGetClassObject(rclsid, riid, ppv)
 
     def DllCanUnloadNow():
-        # First ask ctypes.com.server than comtypes.server if we can unload or not.
-        # trick py2exe by doing dynamic imports
-        result = 0 # S_OK
         try:
-            ctcom = __import__("ctypes.com.server", globals(), locals(), ['*'])
+            ccom = __import__("comtypes.server.inprocserver", globals(), locals(), ['*'])
         except ImportError:
-            pass
-        else:
-            result = ctcom.DllCanUnloadNow()
-            if result != 0: # != S_OK
-                return result
-
-        try:
-            ccom = __import__("comtypes.server", globals(), locals(), ['*'])
-        except ImportError:
-            return result
-        try:
-            return ccom.DllCanUnloadNow()
-        except AttributeError:
-            pass
-        return result
+            return 0 # S_OK
+        return ccom.DllCanUnloadNow()
 
 from ctypes._endian import BigEndianStructure, LittleEndianStructure
 

Modified: python/branches/bcannon-sandboxing/Lib/ctypes/test/test_parameters.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/ctypes/test/test_parameters.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/ctypes/test/test_parameters.py	Wed Aug  2 00:51:44 2006
@@ -147,6 +147,41 @@
 ##    def test_performance(self):
 ##        check_perf()
 
+    def test_noctypes_argtype(self):
+        import _ctypes_test
+        from ctypes import CDLL, c_void_p, ArgumentError
+
+        func = CDLL(_ctypes_test.__file__)._testfunc_p_p
+        func.restype = c_void_p
+        # TypeError: has no from_param method
+        self.assertRaises(TypeError, setattr, func, "argtypes", (object,))
+
+        class Adapter(object):
+            def from_param(cls, obj):
+                return None
+
+        func.argtypes = (Adapter(),)
+        self.failUnlessEqual(func(None), None)
+        self.failUnlessEqual(func(object()), None)
+
+        class Adapter(object):
+            def from_param(cls, obj):
+                return obj
+
+        func.argtypes = (Adapter(),)
+        # don't know how to convert parameter 1
+        self.assertRaises(ArgumentError, func, object())
+        self.failUnlessEqual(func(c_void_p(42)), 42)
+
+        class Adapter(object):
+            def from_param(cls, obj):
+                raise ValueError(obj)
+
+        func.argtypes = (Adapter(),)
+        # ArgumentError: argument 1: ValueError: 99
+        self.assertRaises(ArgumentError, func, 99)
+
+
 ################################################################
 
 if __name__ == '__main__':

Modified: python/branches/bcannon-sandboxing/Lib/ctypes/test/test_pointers.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/ctypes/test/test_pointers.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/ctypes/test/test_pointers.py	Wed Aug  2 00:51:44 2006
@@ -157,6 +157,23 @@
         q = pointer(y)
         pp[0] = q         # <==
         self.failUnlessEqual(p[0], 6)
+    def test_c_void_p(self):
+        # http://sourceforge.net/tracker/?func=detail&aid=1518190&group_id=5470&atid=105470
+        if sizeof(c_void_p) == 4:
+            self.failUnlessEqual(c_void_p(0xFFFFFFFFL).value,
+                                 c_void_p(-1).value)
+            self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFL).value,
+                                 c_void_p(-1).value)
+        elif sizeof(c_void_p) == 8:
+            self.failUnlessEqual(c_void_p(0xFFFFFFFFL).value,
+                                 0xFFFFFFFFL)
+            self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFL).value,
+                                 c_void_p(-1).value)
+            self.failUnlessEqual(c_void_p(0xFFFFFFFFFFFFFFFFFFFFFFFFL).value,
+                                 c_void_p(-1).value)
+
+        self.assertRaises(TypeError, c_void_p, 3.14) # make sure floats are NOT accepted
+        self.assertRaises(TypeError, c_void_p, object()) # nor other objects
 
 if __name__ == '__main__':
     unittest.main()

Modified: python/branches/bcannon-sandboxing/Lib/ctypes/test/test_structures.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/ctypes/test/test_structures.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/ctypes/test/test_structures.py	Wed Aug  2 00:51:44 2006
@@ -371,5 +371,15 @@
         items = [s.array[i] for i in range(3)]
         self.failUnlessEqual(items, [1, 2, 3])
 
+    def test_none_to_pointer_fields(self):
+        class S(Structure):
+            _fields_ = [("x", c_int),
+                        ("p", POINTER(c_int))]
+
+        s = S()
+        s.x = 12345678
+        s.p = None
+        self.failUnlessEqual(s.x, 12345678)
+
 if __name__ == '__main__':
     unittest.main()

Modified: python/branches/bcannon-sandboxing/Lib/ctypes/test/test_varsize_struct.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/ctypes/test/test_varsize_struct.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/ctypes/test/test_varsize_struct.py	Wed Aug  2 00:51:44 2006
@@ -46,70 +46,5 @@
         self.failUnlessRaises(IndexError, array.__setitem__, -1, None)
         self.failUnlessRaises(IndexError, array.__getitem__, -1)
 
-    def test_varsized_array(self):
-        array = (c_int * 20)(20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
-
-        # no range checking is done on arrays with size == 1
-        varsize_array = (c_int * 1).from_address(addressof(array))
-
-        # __getitem__
-        self.failUnlessEqual(varsize_array[0], 20)
-        self.failUnlessEqual(varsize_array[1], 21)
-        self.failUnlessEqual(varsize_array[2], 22)
-        self.failUnlessEqual(varsize_array[3], 23)
-        self.failUnlessEqual(varsize_array[4], 24)
-        self.failUnlessEqual(varsize_array[5], 25)
-        self.failUnlessEqual(varsize_array[6], 26)
-        self.failUnlessEqual(varsize_array[7], 27)
-        self.failUnlessEqual(varsize_array[8], 28)
-        self.failUnlessEqual(varsize_array[9], 29)
-
-        # still, normal sequence of length one behaviour:
-        self.failUnlessEqual(varsize_array[-1], 20)
-        self.failUnlessRaises(IndexError, lambda: varsize_array[-2])
-        # except for this one, which will raise MemoryError
-        self.failUnlessRaises(MemoryError, lambda: varsize_array[:])
-
-        # __setitem__
-        varsize_array[0] = 100
-        varsize_array[1] = 101
-        varsize_array[2] = 102
-        varsize_array[3] = 103
-        varsize_array[4] = 104
-        varsize_array[5] = 105
-        varsize_array[6] = 106
-        varsize_array[7] = 107
-        varsize_array[8] = 108
-        varsize_array[9] = 109
-
-        for i in range(10):
-            self.failUnlessEqual(varsize_array[i], i + 100)
-            self.failUnlessEqual(array[i], i + 100)
-
-        # __getslice__
-        self.failUnlessEqual(varsize_array[0:10], range(100, 110))
-        self.failUnlessEqual(varsize_array[1:9], range(101, 109))
-        self.failUnlessEqual(varsize_array[1:-1], [])
-
-        # __setslice__
-        varsize_array[0:10] = range(1000, 1010)
-        self.failUnlessEqual(varsize_array[0:10], range(1000, 1010))
-
-        varsize_array[1:9] = range(1001, 1009)
-        self.failUnlessEqual(varsize_array[1:9], range(1001, 1009))
-
-    def test_vararray_is_sane(self):
-        array = (c_int * 15)(20, 21, 22, 23, 24, 25, 26, 27, 28, 29)
-
-        varsize_array = (c_int * 1).from_address(addressof(array))
-        varsize_array[:] = [1, 2, 3, 4, 5]
-
-        self.failUnlessEqual(array[:], [1, 2, 3, 4, 5, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0])
-        self.failUnlessEqual(varsize_array[0:10], [1, 2, 3, 4, 5, 25, 26, 27, 28, 29])
-
-        array[:5] = [10, 11, 12, 13, 14]
-        self.failUnlessEqual(array[:], [10, 11, 12, 13, 14, 25, 26, 27, 28, 29, 0, 0, 0, 0, 0])
-        self.failUnlessEqual(varsize_array[0:10], [10, 11, 12, 13, 14, 25, 26, 27, 28, 29])
-
 if __name__ == "__main__":
     unittest.main()

Modified: python/branches/bcannon-sandboxing/Lib/ctypes/test/test_win32.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/ctypes/test/test_win32.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/ctypes/test/test_win32.py	Wed Aug  2 00:51:44 2006
@@ -1,6 +1,7 @@
 # Windows specific tests
 
 from ctypes import *
+from ctypes.test import is_resource_enabled
 import unittest, sys
 
 import _ctypes_test
@@ -30,8 +31,7 @@
             # or wrong calling convention
             self.assertRaises(ValueError, IsWindow, None)
 
-        import _ctypes
-        if _ctypes.uses_seh():
+        if is_resource_enabled("SEH"):
             def test_SEH(self):
                 # Call functions with invalid arguments, and make sure that access violations
                 # are trapped and raise an exception.

Modified: python/branches/bcannon-sandboxing/Lib/ctypes/util.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/ctypes/util.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/ctypes/util.py	Wed Aug  2 00:51:44 2006
@@ -47,10 +47,13 @@
 
     def _findLib_gcc(name):
         expr = '[^\(\)\s]*lib%s\.[^\(\)\s]*' % name
+        fdout, ccout = tempfile.mkstemp()
+        os.close(fdout)
         cmd = 'if type gcc &>/dev/null; then CC=gcc; else CC=cc; fi;' \
-              '$CC -Wl,-t -o /dev/null 2>&1 -l' + name
+              '$CC -Wl,-t -o ' + ccout + ' 2>&1 -l' + name
         try:
             fdout, outfile =  tempfile.mkstemp()
+            os.close(fdout)
             fd = os.popen(cmd)
             trace = fd.read()
             err = fd.close()
@@ -60,6 +63,11 @@
             except OSError, e:
                 if e.errno != errno.ENOENT:
                     raise
+            try:
+                os.unlink(ccout)
+            except OSError, e:
+                if e.errno != errno.ENOENT:
+                    raise
         res = re.search(expr, trace)
         if not res:
             return None

Modified: python/branches/bcannon-sandboxing/Lib/distutils/__init__.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/distutils/__init__.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/distutils/__init__.py	Wed Aug  2 00:51:44 2006
@@ -12,4 +12,6 @@
 
 __revision__ = "$Id$"
 
-__version__ = "2.4.0"
+import sys
+__version__ = "%d.%d.%d" % sys.version_info[:3]
+del sys

Modified: python/branches/bcannon-sandboxing/Lib/distutils/command/upload.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/distutils/command/upload.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/distutils/command/upload.py	Wed Aug  2 00:51:44 2006
@@ -185,7 +185,7 @@
             http.endheaders()
             http.send(body)
         except socket.error, e:
-            self.announce(e.msg, log.ERROR)
+            self.announce(str(e), log.ERROR)
             return
 
         r = http.getresponse()

Modified: python/branches/bcannon-sandboxing/Lib/distutils/msvccompiler.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/distutils/msvccompiler.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/distutils/msvccompiler.py	Wed Aug  2 00:51:44 2006
@@ -131,8 +131,10 @@
                 self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
         except KeyError, exc: #
             raise DistutilsPlatformError, \
-                  ("The .NET Framework SDK needs to be installed before "
-                   "building extensions for Python.")
+                  ("""Python was built with Visual Studio 2003;
+extensions must be built with a compiler than can generate compatible binaries.
+Visual Studio 2003 was not found on this system. If you have Cygwin installed,
+you can try compiling with MingW32, by passing "-c mingw32" to setup.py.""")
 
         p = r"Software\Microsoft\NET Framework Setup\Product"
         for base in HKEYS:
@@ -237,7 +239,7 @@
 
     def initialize(self):
         self.__paths = []
-        if os.environ.has_key("MSSdk") and self.find_exe("cl.exe"):
+        if os.environ.has_key("DISTUTILS_USE_SDK") and os.environ.has_key("MSSdk") and self.find_exe("cl.exe"):
             # Assume that the SDK set up everything alright; don't try to be
             # smarter
             self.cc = "cl.exe"

Modified: python/branches/bcannon-sandboxing/Lib/doctest.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/doctest.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/doctest.py	Wed Aug  2 00:51:44 2006
@@ -821,6 +821,11 @@
         # Recursively expore `obj`, extracting DocTests.
         tests = []
         self._find(tests, obj, name, module, source_lines, globs, {})
+        # Sort the tests by alpha order of names, for consistency in
+        # verbose-mode output.  This was a feature of doctest in Pythons
+        # <= 2.3 that got lost by accident in 2.4.  It was repaired in
+        # 2.4.4 and 2.5.
+        tests.sort()
         return tests
 
     def _from_module(self, module, object):

Modified: python/branches/bcannon-sandboxing/Lib/email/__init__.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/email/__init__.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/email/__init__.py	Wed Aug  2 00:51:44 2006
@@ -4,7 +4,7 @@
 
 """A package for parsing, handling, and generating email messages."""
 
-__version__ = '4.0a2'
+__version__ = '4.0.1'
 
 __all__ = [
     # Old names

Modified: python/branches/bcannon-sandboxing/Lib/email/message.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/email/message.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/email/message.py	Wed Aug  2 00:51:44 2006
@@ -747,7 +747,18 @@
         if isinstance(charset, tuple):
             # RFC 2231 encoded, so decode it, and it better end up as ascii.
             pcharset = charset[0] or 'us-ascii'
-            charset = unicode(charset[2], pcharset).encode('us-ascii')
+            try:
+                # LookupError will be raised if the charset isn't known to
+                # Python.  UnicodeError will be raised if the encoded text
+                # contains a character not in the charset.
+                charset = unicode(charset[2], pcharset).encode('us-ascii')
+            except (LookupError, UnicodeError):
+                charset = charset[2]
+        # charset character must be in us-ascii range
+        try:
+            charset = unicode(charset, 'us-ascii').encode('us-ascii')
+        except UnicodeError:
+            return failobj
         # RFC 2046, $4.1.2 says charsets are not case sensitive
         return charset.lower()
 

Modified: python/branches/bcannon-sandboxing/Lib/email/test/test_email.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/email/test/test_email.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/email/test/test_email.py	Wed Aug  2 00:51:44 2006
@@ -3005,14 +3005,29 @@
 
 '''
         msg = email.message_from_string(m)
-        self.assertEqual(msg.get_param('NAME'),
-                         (None, None, 'file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm'))
+        param = msg.get_param('NAME')
+        self.failIf(isinstance(param, tuple))
+        self.assertEqual(
+            param,
+            'file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm')
 
     def test_rfc2231_no_language_or_charset_in_filename(self):
         m = '''\
 Content-Disposition: inline;
-\tfilename*0="This%20is%20even%20more%20";
-\tfilename*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*0*="''This%20is%20even%20more%20";
+\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2="is it not.pdf"
+
+'''
+        msg = email.message_from_string(m)
+        self.assertEqual(msg.get_filename(),
+                         'This is even more ***fun*** is it not.pdf')
+
+    def test_rfc2231_no_language_or_charset_in_filename_encoded(self):
+        m = '''\
+Content-Disposition: inline;
+\tfilename*0*="''This%20is%20even%20more%20";
+\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
 \tfilename*2="is it not.pdf"
 
 '''
@@ -3020,11 +3035,37 @@
         self.assertEqual(msg.get_filename(),
                          'This is even more ***fun*** is it not.pdf')
 
+    def test_rfc2231_partly_encoded(self):
+        m = '''\
+Content-Disposition: inline;
+\tfilename*0="''This%20is%20even%20more%20";
+\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2="is it not.pdf"
+
+'''
+        msg = email.message_from_string(m)
+        self.assertEqual(
+            msg.get_filename(),
+            'This%20is%20even%20more%20***fun*** is it not.pdf')
+
+    def test_rfc2231_partly_nonencoded(self):
+        m = '''\
+Content-Disposition: inline;
+\tfilename*0="This%20is%20even%20more%20";
+\tfilename*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2="is it not.pdf"
+
+'''
+        msg = email.message_from_string(m)
+        self.assertEqual(
+            msg.get_filename(),
+            'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20is it not.pdf')
+
     def test_rfc2231_no_language_or_charset_in_boundary(self):
         m = '''\
 Content-Type: multipart/alternative;
-\tboundary*0="This%20is%20even%20more%20";
-\tboundary*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tboundary*0*="''This%20is%20even%20more%20";
+\tboundary*1*="%2A%2A%2Afun%2A%2A%2A%20";
 \tboundary*2="is it not.pdf"
 
 '''
@@ -3036,8 +3077,8 @@
         # This is a nonsensical charset value, but tests the code anyway
         m = '''\
 Content-Type: text/plain;
-\tcharset*0="This%20is%20even%20more%20";
-\tcharset*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tcharset*0*="This%20is%20even%20more%20";
+\tcharset*1*="%2A%2A%2Afun%2A%2A%2A%20";
 \tcharset*2="is it not.pdf"
 
 '''
@@ -3045,15 +3086,145 @@
         self.assertEqual(msg.get_content_charset(),
                          'this is even more ***fun*** is it not.pdf')
 
+    def test_rfc2231_bad_encoding_in_filename(self):
+        m = '''\
+Content-Disposition: inline;
+\tfilename*0*="bogus'xx'This%20is%20even%20more%20";
+\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2="is it not.pdf"
+
+'''
+        msg = email.message_from_string(m)
+        self.assertEqual(msg.get_filename(),
+                         'This is even more ***fun*** is it not.pdf')
+
+    def test_rfc2231_bad_encoding_in_charset(self):
+        m = """\
+Content-Type: text/plain; charset*=bogus''utf-8%E2%80%9D
+
+"""
+        msg = email.message_from_string(m)
+        # This should return None because non-ascii characters in the charset
+        # are not allowed.
+        self.assertEqual(msg.get_content_charset(), None)
+
+    def test_rfc2231_bad_character_in_charset(self):
+        m = """\
+Content-Type: text/plain; charset*=ascii''utf-8%E2%80%9D
+
+"""
+        msg = email.message_from_string(m)
+        # This should return None because non-ascii characters in the charset
+        # are not allowed.
+        self.assertEqual(msg.get_content_charset(), None)
+
+    def test_rfc2231_bad_character_in_filename(self):
+        m = '''\
+Content-Disposition: inline;
+\tfilename*0*="ascii'xx'This%20is%20even%20more%20";
+\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2*="is it not.pdf%E2"
+
+'''
+        msg = email.message_from_string(m)
+        self.assertEqual(msg.get_filename(),
+                         u'This is even more ***fun*** is it not.pdf\ufffd')
+
     def test_rfc2231_unknown_encoding(self):
         m = """\
 Content-Transfer-Encoding: 8bit
-Content-Disposition: inline; filename*0=X-UNKNOWN''myfile.txt
+Content-Disposition: inline; filename*=X-UNKNOWN''myfile.txt
 
 """
         msg = email.message_from_string(m)
         self.assertEqual(msg.get_filename(), 'myfile.txt')
 
+    def test_rfc2231_single_tick_in_filename_extended(self):
+        eq = self.assertEqual
+        m = """\
+Content-Type: application/x-foo;
+\tname*0*=\"Frank's\"; name*1*=\" Document\"
+
+"""
+        msg = email.message_from_string(m)
+        charset, language, s = msg.get_param('name')
+        eq(charset, None)
+        eq(language, None)
+        eq(s, "Frank's Document")
+
+    def test_rfc2231_single_tick_in_filename(self):
+        m = """\
+Content-Type: application/x-foo; name*0=\"Frank's\"; name*1=\" Document\"
+
+"""
+        msg = email.message_from_string(m)
+        param = msg.get_param('name')
+        self.failIf(isinstance(param, tuple))
+        self.assertEqual(param, "Frank's Document")
+
+    def test_rfc2231_tick_attack_extended(self):
+        eq = self.assertEqual
+        m = """\
+Content-Type: application/x-foo;
+\tname*0*=\"us-ascii'en-us'Frank's\"; name*1*=\" Document\"
+
+"""
+        msg = email.message_from_string(m)
+        charset, language, s = msg.get_param('name')
+        eq(charset, 'us-ascii')
+        eq(language, 'en-us')
+        eq(s, "Frank's Document")
+
+    def test_rfc2231_tick_attack(self):
+        m = """\
+Content-Type: application/x-foo;
+\tname*0=\"us-ascii'en-us'Frank's\"; name*1=\" Document\"
+
+"""
+        msg = email.message_from_string(m)
+        param = msg.get_param('name')
+        self.failIf(isinstance(param, tuple))
+        self.assertEqual(param, "us-ascii'en-us'Frank's Document")
+
+    def test_rfc2231_no_extended_values(self):
+        eq = self.assertEqual
+        m = """\
+Content-Type: application/x-foo; name=\"Frank's Document\"
+
+"""
+        msg = email.message_from_string(m)
+        eq(msg.get_param('name'), "Frank's Document")
+
+    def test_rfc2231_encoded_then_unencoded_segments(self):
+        eq = self.assertEqual
+        m = """\
+Content-Type: application/x-foo;
+\tname*0*=\"us-ascii'en-us'My\";
+\tname*1=\" Document\";
+\tname*2*=\" For You\"
+
+"""
+        msg = email.message_from_string(m)
+        charset, language, s = msg.get_param('name')
+        eq(charset, 'us-ascii')
+        eq(language, 'en-us')
+        eq(s, 'My Document For You')
+
+    def test_rfc2231_unencoded_then_encoded_segments(self):
+        eq = self.assertEqual
+        m = """\
+Content-Type: application/x-foo;
+\tname*0=\"us-ascii'en-us'My\";
+\tname*1*=\" Document\";
+\tname*2*=\" For You\"
+
+"""
+        msg = email.message_from_string(m)
+        charset, language, s = msg.get_param('name')
+        eq(charset, 'us-ascii')
+        eq(language, 'en-us')
+        eq(s, 'My Document For You')
+
 
 
 def _testclasses():

Modified: python/branches/bcannon-sandboxing/Lib/email/test/test_email_renamed.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/email/test/test_email_renamed.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/email/test/test_email_renamed.py	Wed Aug  2 00:51:44 2006
@@ -3011,14 +3011,29 @@
 
 '''
         msg = email.message_from_string(m)
-        self.assertEqual(msg.get_param('NAME'),
-                         (None, None, 'file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm'))
+        param = msg.get_param('NAME')
+        self.failIf(isinstance(param, tuple))
+        self.assertEqual(
+            param,
+            'file____C__DOCUMENTS_20AND_20SETTINGS_FABIEN_LOCAL_20SETTINGS_TEMP_nsmail.htm')
 
     def test_rfc2231_no_language_or_charset_in_filename(self):
         m = '''\
 Content-Disposition: inline;
-\tfilename*0="This%20is%20even%20more%20";
-\tfilename*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*0*="''This%20is%20even%20more%20";
+\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2="is it not.pdf"
+
+'''
+        msg = email.message_from_string(m)
+        self.assertEqual(msg.get_filename(),
+                         'This is even more ***fun*** is it not.pdf')
+
+    def test_rfc2231_no_language_or_charset_in_filename_encoded(self):
+        m = '''\
+Content-Disposition: inline;
+\tfilename*0*="''This%20is%20even%20more%20";
+\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
 \tfilename*2="is it not.pdf"
 
 '''
@@ -3026,11 +3041,37 @@
         self.assertEqual(msg.get_filename(),
                          'This is even more ***fun*** is it not.pdf')
 
+    def test_rfc2231_partly_encoded(self):
+        m = '''\
+Content-Disposition: inline;
+\tfilename*0="''This%20is%20even%20more%20";
+\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2="is it not.pdf"
+
+'''
+        msg = email.message_from_string(m)
+        self.assertEqual(
+            msg.get_filename(),
+            'This%20is%20even%20more%20***fun*** is it not.pdf')
+
+    def test_rfc2231_partly_nonencoded(self):
+        m = '''\
+Content-Disposition: inline;
+\tfilename*0="This%20is%20even%20more%20";
+\tfilename*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2="is it not.pdf"
+
+'''
+        msg = email.message_from_string(m)
+        self.assertEqual(
+            msg.get_filename(),
+            'This%20is%20even%20more%20%2A%2A%2Afun%2A%2A%2A%20is it not.pdf')
+
     def test_rfc2231_no_language_or_charset_in_boundary(self):
         m = '''\
 Content-Type: multipart/alternative;
-\tboundary*0="This%20is%20even%20more%20";
-\tboundary*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tboundary*0*="''This%20is%20even%20more%20";
+\tboundary*1*="%2A%2A%2Afun%2A%2A%2A%20";
 \tboundary*2="is it not.pdf"
 
 '''
@@ -3042,8 +3083,8 @@
         # This is a nonsensical charset value, but tests the code anyway
         m = '''\
 Content-Type: text/plain;
-\tcharset*0="This%20is%20even%20more%20";
-\tcharset*1="%2A%2A%2Afun%2A%2A%2A%20";
+\tcharset*0*="This%20is%20even%20more%20";
+\tcharset*1*="%2A%2A%2Afun%2A%2A%2A%20";
 \tcharset*2="is it not.pdf"
 
 '''
@@ -3051,15 +3092,145 @@
         self.assertEqual(msg.get_content_charset(),
                          'this is even more ***fun*** is it not.pdf')
 
+    def test_rfc2231_bad_encoding_in_filename(self):
+        m = '''\
+Content-Disposition: inline;
+\tfilename*0*="bogus'xx'This%20is%20even%20more%20";
+\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2="is it not.pdf"
+
+'''
+        msg = email.message_from_string(m)
+        self.assertEqual(msg.get_filename(),
+                         'This is even more ***fun*** is it not.pdf')
+
+    def test_rfc2231_bad_encoding_in_charset(self):
+        m = """\
+Content-Type: text/plain; charset*=bogus''utf-8%E2%80%9D
+
+"""
+        msg = email.message_from_string(m)
+        # This should return None because non-ascii characters in the charset
+        # are not allowed.
+        self.assertEqual(msg.get_content_charset(), None)
+
+    def test_rfc2231_bad_character_in_charset(self):
+        m = """\
+Content-Type: text/plain; charset*=ascii''utf-8%E2%80%9D
+
+"""
+        msg = email.message_from_string(m)
+        # This should return None because non-ascii characters in the charset
+        # are not allowed.
+        self.assertEqual(msg.get_content_charset(), None)
+
+    def test_rfc2231_bad_character_in_filename(self):
+        m = '''\
+Content-Disposition: inline;
+\tfilename*0*="ascii'xx'This%20is%20even%20more%20";
+\tfilename*1*="%2A%2A%2Afun%2A%2A%2A%20";
+\tfilename*2*="is it not.pdf%E2"
+
+'''
+        msg = email.message_from_string(m)
+        self.assertEqual(msg.get_filename(),
+                         u'This is even more ***fun*** is it not.pdf\ufffd')
+
     def test_rfc2231_unknown_encoding(self):
         m = """\
 Content-Transfer-Encoding: 8bit
-Content-Disposition: inline; filename*0=X-UNKNOWN''myfile.txt
+Content-Disposition: inline; filename*=X-UNKNOWN''myfile.txt
 
 """
         msg = email.message_from_string(m)
         self.assertEqual(msg.get_filename(), 'myfile.txt')
 
+    def test_rfc2231_single_tick_in_filename_extended(self):
+        eq = self.assertEqual
+        m = """\
+Content-Type: application/x-foo;
+\tname*0*=\"Frank's\"; name*1*=\" Document\"
+
+"""
+        msg = email.message_from_string(m)
+        charset, language, s = msg.get_param('name')
+        eq(charset, None)
+        eq(language, None)
+        eq(s, "Frank's Document")
+
+    def test_rfc2231_single_tick_in_filename(self):
+        m = """\
+Content-Type: application/x-foo; name*0=\"Frank's\"; name*1=\" Document\"
+
+"""
+        msg = email.message_from_string(m)
+        param = msg.get_param('name')
+        self.failIf(isinstance(param, tuple))
+        self.assertEqual(param, "Frank's Document")
+
+    def test_rfc2231_tick_attack_extended(self):
+        eq = self.assertEqual
+        m = """\
+Content-Type: application/x-foo;
+\tname*0*=\"us-ascii'en-us'Frank's\"; name*1*=\" Document\"
+
+"""
+        msg = email.message_from_string(m)
+        charset, language, s = msg.get_param('name')
+        eq(charset, 'us-ascii')
+        eq(language, 'en-us')
+        eq(s, "Frank's Document")
+
+    def test_rfc2231_tick_attack(self):
+        m = """\
+Content-Type: application/x-foo;
+\tname*0=\"us-ascii'en-us'Frank's\"; name*1=\" Document\"
+
+"""
+        msg = email.message_from_string(m)
+        param = msg.get_param('name')
+        self.failIf(isinstance(param, tuple))
+        self.assertEqual(param, "us-ascii'en-us'Frank's Document")
+
+    def test_rfc2231_no_extended_values(self):
+        eq = self.assertEqual
+        m = """\
+Content-Type: application/x-foo; name=\"Frank's Document\"
+
+"""
+        msg = email.message_from_string(m)
+        eq(msg.get_param('name'), "Frank's Document")
+
+    def test_rfc2231_encoded_then_unencoded_segments(self):
+        eq = self.assertEqual
+        m = """\
+Content-Type: application/x-foo;
+\tname*0*=\"us-ascii'en-us'My\";
+\tname*1=\" Document\";
+\tname*2*=\" For You\"
+
+"""
+        msg = email.message_from_string(m)
+        charset, language, s = msg.get_param('name')
+        eq(charset, 'us-ascii')
+        eq(language, 'en-us')
+        eq(s, 'My Document For You')
+
+    def test_rfc2231_unencoded_then_encoded_segments(self):
+        eq = self.assertEqual
+        m = """\
+Content-Type: application/x-foo;
+\tname*0=\"us-ascii'en-us'My\";
+\tname*1*=\" Document\";
+\tname*2*=\" For You\"
+
+"""
+        msg = email.message_from_string(m)
+        charset, language, s = msg.get_param('name')
+        eq(charset, 'us-ascii')
+        eq(language, 'en-us')
+        eq(s, 'My Document For You')
+
 
 
 def _testclasses():

Modified: python/branches/bcannon-sandboxing/Lib/email/utils.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/email/utils.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/email/utils.py	Wed Aug  2 00:51:44 2006
@@ -25,6 +25,7 @@
 import base64
 import random
 import socket
+import urllib
 import warnings
 from cStringIO import StringIO
 
@@ -45,6 +46,7 @@
 EMPTYSTRING = ''
 UEMPTYSTRING = u''
 CRLF = '\r\n'
+TICK = "'"
 
 specialsre = re.compile(r'[][\\()<>@,:;".]')
 escapesre = re.compile(r'[][\\()"]')
@@ -230,12 +232,14 @@
 # RFC2231-related functions - parameter encoding and decoding
 def decode_rfc2231(s):
     """Decode string according to RFC 2231"""
-    import urllib
-    parts = s.split("'", 2)
-    if len(parts) == 1:
-        return None, None, urllib.unquote(s)
-    charset, language, s = parts
-    return charset, language, urllib.unquote(s)
+    parts = s.split(TICK, 2)
+    if len(parts) <= 2:
+        return None, None, s
+    if len(parts) > 3:
+        charset, language = parts[:2]
+        s = TICK.join(parts[2:])
+        return charset, language, s
+    return parts
 
 
 def encode_rfc2231(s, charset=None, language=None):
@@ -259,37 +263,54 @@
 def decode_params(params):
     """Decode parameters list according to RFC 2231.
 
-    params is a sequence of 2-tuples containing (content type, string value).
+    params is a sequence of 2-tuples containing (param name, string value).
     """
+    # Copy params so we don't mess with the original
+    params = params[:]
     new_params = []
-    # maps parameter's name to a list of continuations
+    # Map parameter's name to a list of continuations.  The values are a
+    # 3-tuple of the continuation number, the string value, and a flag
+    # specifying whether a particular segment is %-encoded.
     rfc2231_params = {}
-    # params is a sequence of 2-tuples containing (content_type, string value)
-    name, value = params[0]
+    name, value = params.pop(0)
     new_params.append((name, value))
-    # Cycle through each of the rest of the parameters.
-    for name, value in params[1:]:
+    while params:
+        name, value = params.pop(0)
+        if name.endswith('*'):
+            encoded = True
+        else:
+            encoded = False
         value = unquote(value)
         mo = rfc2231_continuation.match(name)
         if mo:
             name, num = mo.group('name', 'num')
             if num is not None:
                 num = int(num)
-            rfc2231_param1 = rfc2231_params.setdefault(name, [])
-            rfc2231_param1.append((num, value))
+            rfc2231_params.setdefault(name, []).append((num, value, encoded))
         else:
             new_params.append((name, '"%s"' % quote(value)))
     if rfc2231_params:
         for name, continuations in rfc2231_params.items():
             value = []
+            extended = False
             # Sort by number
             continuations.sort()
-            # And now append all values in num order
-            for num, continuation in continuations:
-                value.append(continuation)
-            charset, language, value = decode_rfc2231(EMPTYSTRING.join(value))
-            new_params.append(
-                (name, (charset, language, '"%s"' % quote(value))))
+            # And now append all values in numerical order, converting
+            # %-encodings for the encoded segments.  If any of the
+            # continuation names ends in a *, then the entire string, after
+            # decoding segments and concatenating, must have the charset and
+            # language specifiers at the beginning of the string.
+            for num, s, encoded in continuations:
+                if encoded:
+                    s = urllib.unquote(s)
+                    extended = True
+                value.append(s)
+            value = quote(EMPTYSTRING.join(value))
+            if extended:
+                charset, language, value = decode_rfc2231(value)
+                new_params.append((name, (charset, language, '"%s"' % value)))
+            else:
+                new_params.append((name, '"%s"' % value))
     return new_params
 
 def collapse_rfc2231_value(value, errors='replace',

Modified: python/branches/bcannon-sandboxing/Lib/httplib.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/httplib.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/httplib.py	Wed Aug  2 00:51:44 2006
@@ -3,7 +3,7 @@
 <intro stuff goes here>
 <other stuff, too>
 
-HTTPConnection go through a number of "states", which defines when a client
+HTTPConnection goes through a number of "states", which define when a client
 may legally make another request or fetch the response for a particular
 request. This diagram details these state transitions:
 
@@ -926,15 +926,15 @@
         self.__state = _CS_IDLE
 
         if response.will_close:
-            # this effectively passes the connection to the response
-            self.close()
+            # Pass the socket to the response
+            self.sock = None
         else:
             # remember this, so we can tell when it is complete
             self.__response = response
 
         return response
 
-# The next several classes are used to define FakeSocket,a socket-like
+# The next several classes are used to define FakeSocket, a socket-like
 # interface to an SSL connection.
 
 # The primary complexity comes from faking a makefile() method.  The

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/CREDITS.txt
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/CREDITS.txt	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/CREDITS.txt	Wed Aug  2 00:51:44 2006
@@ -19,17 +19,18 @@
 subprocess, and made a number of usability enhancements.
 
 Other contributors include Raymond Hettinger, Tony Lownds (Mac integration),
-Neal Norwitz (code check and clean-up), and Chui Tey (RPC integration, debugger
-integration and persistent breakpoints).
-
-Scott David Daniels, Hernan Foffani, Christos Georgiou, Martin v. Löwis, 
-Jason Orendorff, Noam Raphael, Josh Robb, Nigel Rowe, Bruce Sherwood, and
-Jeff Shute have submitted useful patches.  Thanks, guys!
+Neal Norwitz (code check and clean-up), Noam Raphael (Code Context, Call Tips,
+many other patches), and Chui Tey (RPC integration, debugger integration and
+persistent breakpoints).
+
+Scott David Daniels, Tal Einat, Hernan Foffani, Christos Georgiou,
+Martin v. Löwis, Jason Orendorff, Josh Robb, Nigel Rowe, Bruce Sherwood,
+and Jeff Shute have submitted useful patches.  Thanks, guys!
 
 For additional details refer to NEWS.txt and Changelog.
 
-Please contact the IDLE maintainer to have yourself included here if you
-are one of those we missed! 
+Please contact the IDLE maintainer (kbk at shore.net) to have yourself included
+here if you are one of those we missed!
 
 
 

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/CallTipWindow.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/CallTipWindow.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/CallTipWindow.py	Wed Aug  2 00:51:44 2006
@@ -49,7 +49,11 @@
         """
         # truncate overly long calltip
         if len(text) >= 79:
-            text = text[:75] + ' ...'
+            textlines = text.splitlines()
+            for i, line in enumerate(textlines):
+                if len(line) > 79:
+                    textlines[i] = line[:75] + ' ...'
+            text = '\n'.join(textlines)
         self.text = text
         if self.tipwindow or not self.text:
             return

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/CallTips.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/CallTips.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/CallTips.py	Wed Aug  2 00:51:44 2006
@@ -127,7 +127,7 @@
     argText = ""
     if ob is not None:
         argOffset = 0
-        if type(ob)==types.ClassType:
+        if type(ob) in (types.ClassType, types.TypeType):
             # Look for the highest __init__ in the class chain.
             fob = _find_constructor(ob)
             if fob is None:

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/CodeContext.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/CodeContext.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/CodeContext.py	Wed Aug  2 00:51:44 2006
@@ -11,11 +11,10 @@
 """
 import Tkinter
 from configHandler import idleConf
-from sets import Set
 import re
 from sys import maxint as INFINITY
 
-BLOCKOPENERS = Set(["class", "def", "elif", "else", "except", "finally", "for",
+BLOCKOPENERS = set(["class", "def", "elif", "else", "except", "finally", "for",
                     "if", "try", "while"])
 UPDATEINTERVAL = 100 # millisec
 FONTUPDATEINTERVAL = 1000 # millisec

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/ColorDelegator.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/ColorDelegator.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/ColorDelegator.py	Wed Aug  2 00:51:44 2006
@@ -8,28 +8,29 @@
 
 DEBUG = False
 
-def any(name, list):
-    return "(?P<%s>" % name + "|".join(list) + ")"
+def any(name, alternates):
+    "Return a named group pattern matching list of alternates."
+    return "(?P<%s>" % name + "|".join(alternates) + ")"
 
 def make_pat():
     kw = r"\b" + any("KEYWORD", keyword.kwlist) + r"\b"
     builtinlist = [str(name) for name in dir(__builtin__)
                                         if not name.startswith('_')]
     # self.file = file("file") :
-    # 1st 'file' colorized normal, 2nd as builtin, 3rd as comment
-    builtin = r"([^.'\"\\]\b|^)" + any("BUILTIN", builtinlist) + r"\b"
+    # 1st 'file' colorized normal, 2nd as builtin, 3rd as string
+    builtin = r"([^.'\"\\#]\b|^)" + any("BUILTIN", builtinlist) + r"\b"
     comment = any("COMMENT", [r"#[^\n]*"])
-    sqstring = r"(\b[rR])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
-    dqstring = r'(\b[rR])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
-    sq3string = r"(\b[rR])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
-    dq3string = r'(\b[rR])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
+    sqstring = r"(\b[rRuU])?'[^'\\\n]*(\\.[^'\\\n]*)*'?"
+    dqstring = r'(\b[rRuU])?"[^"\\\n]*(\\.[^"\\\n]*)*"?'
+    sq3string = r"(\b[rRuU])?'''[^'\\]*((\\.|'(?!''))[^'\\]*)*(''')?"
+    dq3string = r'(\b[rRuU])?"""[^"\\]*((\\.|"(?!""))[^"\\]*)*(""")?'
     string = any("STRING", [sq3string, dq3string, sqstring, dqstring])
     return kw + "|" + builtin + "|" + comment + "|" + string +\
            "|" + any("SYNC", [r"\n"])
 
 prog = re.compile(make_pat(), re.S)
 idprog = re.compile(r"\s+(\w+)", re.S)
-asprog = re.compile(r".*?\b(as)\b", re.S)
+asprog = re.compile(r".*?\b(as)\b")
 
 class ColorDelegator(Delegator):
 
@@ -208,10 +209,15 @@
                                                  head + "+%dc" % a,
                                                  head + "+%dc" % b)
                             elif value == "import":
-                                # color all the "as" words on same line;
-                                # cheap approximation to the truth
+                                # color all the "as" words on same line, except
+                                # if in a comment; cheap approximation to the
+                                # truth
+                                if '#' in chars:
+                                    endpos = chars.index('#')
+                                else:
+                                    endpos = len(chars)
                                 while True:
-                                    m1 = self.asprog.match(chars, b)
+                                    m1 = self.asprog.match(chars, b, endpos)
                                     if not m1:
                                         break
                                     a, b = m1.span(1)

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/EditorWindow.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/EditorWindow.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/EditorWindow.py	Wed Aug  2 00:51:44 2006
@@ -85,17 +85,22 @@
         self.flist = flist
         root = root or flist.root
         self.root = root
+        try:
+            sys.ps1
+        except AttributeError:
+            sys.ps1 = '>>> '
         self.menubar = Menu(root)
         self.top = top = WindowList.ListedToplevel(root, menu=self.menubar)
         if flist:
             self.tkinter_vars = flist.vars
             #self.top.instance_dict makes flist.inversedict avalable to
             #configDialog.py so it can access all EditorWindow instaces
-            self.top.instance_dict=flist.inversedict
+            self.top.instance_dict = flist.inversedict
         else:
             self.tkinter_vars = {}  # keys: Tkinter event names
                                     # values: Tkinter variable instances
-        self.recent_files_path=os.path.join(idleConf.GetUserCfgDir(),
+            self.top.instance_dict = {}
+        self.recent_files_path = os.path.join(idleConf.GetUserCfgDir(),
                 'recent-files.lst')
         self.vbar = vbar = Scrollbar(top, name='vbar')
         self.text_frame = text_frame = Frame(top)
@@ -121,6 +126,9 @@
 
         self.top.protocol("WM_DELETE_WINDOW", self.close)
         self.top.bind("<<close-window>>", self.close_event)
+        if macosxSupport.runningAsOSXApp():
+            # Command-W on editorwindows doesn't work without this.
+            text.bind('<<close-window>>', self.close_event)
         text.bind("<<cut>>", self.cut)
         text.bind("<<copy>>", self.copy)
         text.bind("<<paste>>", self.paste)

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/NEWS.txt
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/NEWS.txt	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/NEWS.txt	Wed Aug  2 00:51:44 2006
@@ -1,3 +1,29 @@
+What's New in IDLE 1.2c1?
+=========================
+
+*Release date: XX-XXX-2006*
+
+- EditorWindow.test() was failing.  Bug 1417598
+
+- EditorWindow failed when used stand-alone if sys.ps1 not set.
+  Bug 1010370 Dave Florek
+
+- Tooltips failed on new-syle class __init__ args.  Bug 1027566 Loren Guthrie
+
+- Avoid occasional failure to detect closing paren properly.
+  Patch 1407280 Tal Einat
+
+- Rebinding Tab key was inserting 'tab' instead of 'Tab'.  Bug 1179168.
+
+- Colorizer now handles #<builtin> correctly, also unicode strings and
+  'as' keyword in comment directly following import command. Closes 1325071.
+  Patch 1479219 Tal Einat
+
+What's New in IDLE 1.2b2?
+=========================
+
+*Release date: 11-JUL-2006*
+
 What's New in IDLE 1.2b1?
 =========================
 

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/ParenMatch.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/ParenMatch.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/ParenMatch.py	Wed Aug  2 00:51:44 2006
@@ -8,7 +8,7 @@
 from HyperParser import HyperParser
 from configHandler import idleConf
 
-keysym_opener = {"parenright":'(', "bracketright":'[', "braceright":'{'}
+_openers = {')':'(',']':'[','}':'{'}
 CHECK_DELAY = 100 # miliseconds
 
 class ParenMatch:
@@ -100,12 +100,13 @@
 
     def paren_closed_event(self, event):
         # If it was a shortcut and not really a closing paren, quit.
-        if self.text.get("insert-1c") not in (')',']','}'):
+        closer = self.text.get("insert-1c")
+        if closer not in _openers:
             return
         hp = HyperParser(self.editwin, "insert-1c")
         if not hp.is_in_code():
             return
-        indices = hp.get_surrounding_brackets(keysym_opener[event.keysym], True)
+        indices = hp.get_surrounding_brackets(_openers[closer], True)
         if indices is None:
             self.warn_mismatched()
             return

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/PyShell.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/PyShell.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/PyShell.py	Wed Aug  2 00:51:44 2006
@@ -1306,10 +1306,6 @@
     script = None
     startup = False
     try:
-        sys.ps1
-    except AttributeError:
-        sys.ps1 = '>>> '
-    try:
         opts, args = getopt.getopt(sys.argv[1:], "c:deihnr:st:")
     except getopt.error, msg:
         sys.stderr.write("Error: %s\n" % str(msg))

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/ScriptBinding.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/ScriptBinding.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/ScriptBinding.py	Wed Aug  2 00:51:44 2006
@@ -51,7 +51,7 @@
         # Provide instance variables referenced by Debugger
         # XXX This should be done differently
         self.flist = self.editwin.flist
-        self.root = self.flist.root
+        self.root = self.editwin.root
 
     def check_module_event(self, event):
         filename = self.getfilename()

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/config-keys.def
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/config-keys.def	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/config-keys.def	Wed Aug  2 00:51:44 2006
@@ -159,3 +159,56 @@
 change-indentwidth=<Control-Key-u>
 del-word-left=<Control-Key-BackSpace>
 del-word-right=<Control-Key-Delete>
+
+[IDLE Classic OSX]
+toggle-tabs = <Control-Key-t>
+interrupt-execution = <Control-Key-c>
+untabify-region = <Control-Key-6>
+remove-selection = <Key-Escape>
+print-window = <Command-Key-p>
+replace = <Command-Key-r>
+goto-line = <Command-Key-j>
+plain-newline-and-indent = <Control-Key-j>
+history-previous = <Control-Key-p>
+beginning-of-line = <Control-Key-Left>
+end-of-line = <Control-Key-Right>
+comment-region = <Control-Key-3>
+redo = <Shift-Command-Key-Z>
+close-window = <Command-Key-w>
+restart-shell = <Control-Key-F6>
+save-window-as-file = <Command-Key-S>
+close-all-windows = <Command-Key-q>
+view-restart = <Key-F6>
+tabify-region = <Control-Key-5>
+find-again = <Command-Key-g> <Key-F3>
+find = <Command-Key-f>
+toggle-auto-coloring = <Control-Key-slash>
+select-all = <Command-Key-a>
+smart-backspace = <Key-BackSpace>
+change-indentwidth = <Control-Key-u>
+do-nothing = <Control-Key-F12>
+smart-indent = <Key-Tab>
+center-insert = <Control-Key-l>
+history-next = <Control-Key-n>
+del-word-right = <Option-Key-Delete>
+undo = <Command-Key-z>
+save-window = <Command-Key-s>
+uncomment-region = <Control-Key-4>
+cut = <Command-Key-x>
+find-in-files = <Command-Key-F3>
+dedent-region = <Command-Key-bracketleft>
+copy = <Command-Key-c>
+paste = <Command-Key-v>
+indent-region = <Command-Key-bracketright>
+del-word-left = <Option-Key-BackSpace> <Option-Command-Key-BackSpace>
+newline-and-indent = <Key-Return> <Key-KP_Enter>
+end-of-file = <Control-Key-d>
+open-class-browser = <Command-Key-b>
+open-new-window = <Command-Key-n>
+open-module = <Command-Key-m>
+find-selection = <Shift-Command-Key-F3>
+python-context-help = <Shift-Key-F1>
+save-copy-of-window-as-file = <Shift-Command-Key-s>
+open-window-from-file = <Command-Key-o>
+python-docs = <Key-F1>
+

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/idlever.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/idlever.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/idlever.py	Wed Aug  2 00:51:44 2006
@@ -1 +1 @@
-IDLE_VERSION = "1.2b1"
+IDLE_VERSION = "1.2b2"

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/keybindingDialog.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/keybindingDialog.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/keybindingDialog.py	Wed Aug  2 00:51:44 2006
@@ -202,7 +202,7 @@
                 ':':'colon',',':'comma','.':'period','<':'less','>':'greater',
                 '/':'slash','?':'question','Page Up':'Prior','Page Down':'Next',
                 'Left Arrow':'Left','Right Arrow':'Right','Up Arrow':'Up',
-                'Down Arrow': 'Down', 'Tab':'tab'}
+                'Down Arrow': 'Down', 'Tab':'Tab'}
         if key in translateDict.keys():
             key = translateDict[key]
         if 'Shift' in modifiers and key in string.ascii_lowercase:

Modified: python/branches/bcannon-sandboxing/Lib/idlelib/macosxSupport.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/idlelib/macosxSupport.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/idlelib/macosxSupport.py	Wed Aug  2 00:51:44 2006
@@ -25,6 +25,81 @@
 def hideTkConsole(root):
     root.tk.call('console', 'hide')
 
+def overrideRootMenu(root, flist):
+    """
+    Replace the Tk root menu by something that's more appropriate for
+    IDLE.
+    """
+    # The menu that is attached to the Tk root (".") is also used by AquaTk for
+    # all windows that don't specify a menu of their own. The default menubar
+    # contains a number of menus, none of which are appropriate for IDLE. The
+    # Most annoying of those is an 'About Tck/Tk...' menu in the application
+    # menu.
+    #
+    # This function replaces the default menubar by a mostly empty one, it
+    # should only contain the correct application menu and the window menu.
+    #
+    # Due to a (mis-)feature of TkAqua the user will also see an empty Help
+    # menu.
+    from Tkinter import Menu, Text, Text
+    from EditorWindow import prepstr, get_accelerator
+    import Bindings
+    import WindowList
+    from MultiCall import MultiCallCreator
+
+    menubar = Menu(root)
+    root.configure(menu=menubar)
+    menudict = {}
+
+    menudict['windows'] = menu = Menu(menubar, name='windows')
+    menubar.add_cascade(label='Window', menu=menu, underline=0)
+
+    def postwindowsmenu(menu=menu):
+        end = menu.index('end')
+        if end is None:
+            end = -1
+
+        if end > 0:
+            menu.delete(0, end)
+        WindowList.add_windows_to_menu(menu)
+    WindowList.register_callback(postwindowsmenu)
+
+    menudict['application'] = menu = Menu(menubar, name='apple')
+    menubar.add_cascade(label='IDLE', menu=menu)
+
+    def about_dialog(event=None):
+        import aboutDialog
+        aboutDialog.AboutDialog(root, 'About IDLE')
+
+    def config_dialog(event=None):
+        import configDialog
+        configDialog.ConfigDialog(root, 'Settings')
+
+    root.bind('<<about-idle>>', about_dialog)
+    root.bind('<<open-config-dialog>>', config_dialog)
+    if flist:
+        root.bind('<<close-all-windows>>', flist.close_all_callback)
+
+    for mname, entrylist in Bindings.menudefs:
+        menu = menudict.get(mname)
+        if not menu:
+            continue
+        for entry in entrylist:
+            if not entry:
+                menu.add_separator()
+            else:
+                label, eventname = entry
+                underline, label = prepstr(label)
+                accelerator = get_accelerator(Bindings.default_keydefs,
+                        eventname)
+                def command(text=root, eventname=eventname):
+                    text.event_generate(eventname)
+                menu.add_command(label=label, underline=underline,
+                        command=command, accelerator=accelerator)
+
+
+
+
 
 def setupApp(root, flist):
     """
@@ -33,4 +108,5 @@
     if not runningAsOSXApp(): return
 
     hideTkConsole(root)
+    overrideRootMenu(root, flist)
     addOpenEventSupport(root, flist)

Modified: python/branches/bcannon-sandboxing/Lib/inspect.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/inspect.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/inspect.py	Wed Aug  2 00:51:44 2006
@@ -89,6 +89,40 @@
     is not guaranteed."""
     return (hasattr(object, "__set__") and hasattr(object, "__get__"))
 
+if hasattr(types, 'MemberDescriptorType'):
+    # CPython and equivalent
+    def ismemberdescriptor(object):
+        """Return true if the object is a member descriptor.
+
+        Member descriptors are specialized descriptors defined in extension
+        modules."""
+        return isinstance(object, types.MemberDescriptorType)
+else:
+    # Other implementations
+    def ismemberdescriptor(object):
+        """Return true if the object is a member descriptor.
+
+        Member descriptors are specialized descriptors defined in extension
+        modules."""
+        return False
+
+if hasattr(types, 'GetSetDescriptorType'):
+    # CPython and equivalent
+    def isgetsetdescriptor(object):
+        """Return true if the object is a getset descriptor.
+
+        getset descriptors are specialized descriptors defined in extension
+        modules."""
+        return isinstance(object, types.GetSetDescriptorType)
+else:
+    # Other implementations
+    def isgetsetdescriptor(object):
+        """Return true if the object is a getset descriptor.
+
+        getset descriptors are specialized descriptors defined in extension
+        modules."""
+        return False
+
 def isfunction(object):
     """Return true if the object is a user-defined function.
 
@@ -355,40 +389,38 @@
             return None
     if os.path.exists(filename):
         return filename
-    # Ugly but necessary - '<stdin>' and '<string>' mean that getmodule()
-    # would infinitely recurse, because they're not real files nor loadable
-    # Note that this means that writing a PEP 302 loader that uses '<'
-    # at the start of a filename is now not a good idea.  :(
-    if filename[:1]!='<' and hasattr(getmodule(object), '__loader__'):
+    # only return a non-existent filename if the module has a PEP 302 loader
+    if hasattr(getmodule(object, filename), '__loader__'):
         return filename
 
-def getabsfile(object):
+def getabsfile(object, _filename=None):
     """Return an absolute path to the source or compiled file for an object.
 
     The idea is for each object to have a unique origin, so this routine
     normalizes the result as much as possible."""
-    return os.path.normcase(
-        os.path.abspath(getsourcefile(object) or getfile(object)))
+    if _filename is None:
+        _filename = getsourcefile(object) or getfile(object)
+    return os.path.normcase(os.path.abspath(_filename))
 
 modulesbyfile = {}
 
-def getmodule(object):
+def getmodule(object, _filename=None):
     """Return the module an object was defined in, or None if not found."""
     if ismodule(object):
         return object
     if hasattr(object, '__module__'):
         return sys.modules.get(object.__module__)
     try:
-        file = getabsfile(object)
+        file = getabsfile(object, _filename)
     except TypeError:
         return None
     if file in modulesbyfile:
         return sys.modules.get(modulesbyfile[file])
     for module in sys.modules.values():
         if ismodule(module) and hasattr(module, '__file__'):
-            modulesbyfile[
-                os.path.realpath(
-                        getabsfile(module))] = module.__name__
+            f = getabsfile(module)
+            modulesbyfile[f] = modulesbyfile[
+                os.path.realpath(f)] = module.__name__
     if file in modulesbyfile:
         return sys.modules.get(modulesbyfile[file])
     main = sys.modules['__main__']

Modified: python/branches/bcannon-sandboxing/Lib/lib-tk/Tkinter.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/lib-tk/Tkinter.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/lib-tk/Tkinter.py	Wed Aug  2 00:51:44 2006
@@ -186,7 +186,7 @@
         if name:
             self._name = name
         else:
-            self._name = 'PY_VAR' + `_varnum`
+            self._name = 'PY_VAR' + repr(_varnum)
             _varnum += 1
         if value != None:
             self.set(value)

Modified: python/branches/bcannon-sandboxing/Lib/lib-tk/turtle.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/lib-tk/turtle.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/lib-tk/turtle.py	Wed Aug  2 00:51:44 2006
@@ -86,7 +86,6 @@
         self._color = "black"
         self._filling = 0
         self._path = []
-        self._tofill = []
         self.clear()
         canvas._root().tkraise()
 
@@ -306,19 +305,15 @@
                                             {'fill': self._color,
                                              'smooth': smooth})
                 self._items.append(item)
-                if self._tofill:
-                    for item in self._tofill:
-                        self._canvas.itemconfigure(item, fill=self._color)
-                        self._items.append(item)
         self._path = []
-        self._tofill = []
         self._filling = flag
         if flag:
             self._path.append(self._position)
-        self.forward(0)
 
     def begin_fill(self):
         """ Called just before drawing a shape to be filled.
+            Must eventually be followed by a corresponding end_fill() call.
+            Otherwise it will be ignored.
 
         Example:
         >>> turtle.begin_fill()
@@ -331,7 +326,8 @@
         >>> turtle.forward(100)
         >>> turtle.end_fill()
         """
-        self.fill(1)
+        self._path = [self._position]
+        self._filling = 1
 
     def end_fill(self):
         """ Called after drawing a shape to be filled.
@@ -365,8 +361,8 @@
         >>> turtle.circle(120, 180)  # half a circle
         """
         if extent is None:
-            extent = self._fullcircle 
-        frac = abs(extent)/self._fullcircle 
+            extent = self._fullcircle
+        frac = abs(extent)/self._fullcircle
         steps = 1+int(min(11+abs(radius)/6.0, 59.0)*frac)
         w = 1.0 * extent / steps
         w2 = 0.5 * w
@@ -717,7 +713,7 @@
 def setup(**geometry):
     """ Sets the size and position of the main window.
 
-    Keywords are width, height, startx and starty
+    Keywords are width, height, startx and starty:
 
     width: either a size in pixels or a fraction of the screen.
       Default is 50% of screen.
@@ -792,7 +788,7 @@
         _root.geometry("%dx%d+%d+%d" % (_width, _height, _startx, _starty))
 
 def title(title):
-    """ set the window title.
+    """Set the window title.
 
     By default this is set to 'Turtle Graphics'
 
@@ -901,15 +897,30 @@
             speed(speeds[sp])
     color(0.25,0,0.75)
     fill(0)
-    color("green")
 
-    left(130)
+    # draw and fill a concave shape
+    left(120)
     up()
-    forward(90)
+    forward(70)
+    right(30)
+    down()
     color("red")
-    speed('fastest')
+    speed("fastest")
+    fill(1)
+    for i in range(4):
+        circle(50,90)
+        right(90)
+        forward(30)
+        right(90)
+    color("yellow")
+    fill(0)
+    left(90)
+    up()
+    forward(30)
     down();
 
+    color("red")
+
     # create a second turtle and make the original pursue and catch it
     turtle=Turtle()
     turtle.reset()

Modified: python/branches/bcannon-sandboxing/Lib/logging/handlers.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/logging/handlers.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/logging/handlers.py	Wed Aug  2 00:51:44 2006
@@ -562,6 +562,18 @@
         "local7":   LOG_LOCAL7,
         }
 
+    #The map below appears to be trivially lowercasing the key. However,
+    #there's more to it than meets the eye - in some locales, lowercasing
+    #gives unexpected results. See SF #1524081: in the Turkish locale,
+    #"INFO".lower() != "info"
+    priority_map = {
+        "DEBUG" : "debug",
+        "INFO" : "info",
+        "WARNING" : "warning",
+        "ERROR" : "error",
+        "CRITICAL" : "critical"
+    }
+
     def __init__(self, address=('localhost', SYSLOG_UDP_PORT), facility=LOG_USER):
         """
         Initialize a handler.
@@ -598,7 +610,7 @@
     #   necessary.
     log_format_string = '<%d>%s\000'
 
-    def encodePriority (self, facility, priority):
+    def encodePriority(self, facility, priority):
         """
         Encode the facility and priority. You can pass in strings or
         integers - if strings are passed, the facility_names and
@@ -619,6 +631,16 @@
             self.socket.close()
         logging.Handler.close(self)
 
+    def mapPriority(self, levelName):
+        """
+        Map a logging level name to a key in the priority_names map.
+        This is useful in two scenarios: when custom levels are being
+        used, and in the case where you can't do a straightforward
+        mapping by lowercasing the logging level name because of locale-
+        specific issues (see SF #1524081).
+        """
+        return self.priority_map.get(levelName, "warning")
+
     def emit(self, record):
         """
         Emit a record.
@@ -633,8 +655,8 @@
         """
         msg = self.log_format_string % (
             self.encodePriority(self.facility,
-                                string.lower(record.levelname)),
-            msg)
+                                self.mapPriority(record.levelname)),
+                                msg)
         try:
             if self.unixsocket:
                 try:

Modified: python/branches/bcannon-sandboxing/Lib/mailbox.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/mailbox.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/mailbox.py	Wed Aug  2 00:51:44 2006
@@ -15,6 +15,9 @@
 import rfc822
 import StringIO
 try:
+    if sys.platform == 'os2emx':
+        # OS/2 EMX fcntl() not adequate
+        raise ImportError
     import fcntl
 except ImportError:
     fcntl = None
@@ -565,7 +568,8 @@
         try:
             os.rename(new_file.name, self._path)
         except OSError, e:
-            if e.errno == errno.EEXIST:
+            if e.errno == errno.EEXIST or \
+              (os.name == 'os2' and e.errno == errno.EACCES):
                 os.remove(self._path)
                 os.rename(new_file.name, self._path)
             else:
@@ -1030,6 +1034,9 @@
                         if hasattr(os, 'link'):
                             os.link(os.path.join(self._path, str(key)),
                                     os.path.join(self._path, str(prev + 1)))
+                            if sys.platform == 'os2emx':
+                                # cannot unlink an open file on OS/2
+                                f.close()
                             os.unlink(os.path.join(self._path, str(key)))
                         else:
                             f.close()
@@ -1828,7 +1835,8 @@
                     os.rename(pre_lock.name, f.name + '.lock')
                     dotlock_done = True
             except OSError, e:
-                if e.errno == errno.EEXIST:
+                if e.errno == errno.EEXIST or \
+                  (os.name == 'os2' and e.errno == errno.EACCES):
                     os.remove(pre_lock.name)
                     raise ExternalClashError('dot lock unavailable: %s' %
                                              f.name)

Modified: python/branches/bcannon-sandboxing/Lib/msilib/__init__.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/msilib/__init__.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/msilib/__init__.py	Wed Aug  2 00:51:44 2006
@@ -187,7 +187,7 @@
         self.filenames = sets.Set()
         self.index = 0
 
-    def gen_id(self, dir, file):
+    def gen_id(self, file):
         logical = _logical = make_id(file)
         pos = 1
         while logical in self.filenames:
@@ -196,9 +196,11 @@
         self.filenames.add(logical)
         return logical
 
-    def append(self, full, logical):
+    def append(self, full, file, logical):
         if os.path.isdir(full):
             return
+        if not logical:
+            logical = self.gen_id(file)
         self.index += 1
         self.files.append((full, logical))
         return self.index, logical
@@ -328,7 +330,7 @@
             logical = self.keyfiles[file]
         else:
             logical = None
-        sequence, logical = self.cab.append(absolute, logical)
+        sequence, logical = self.cab.append(absolute, file, logical)
         assert logical not in self.ids
         self.ids.add(logical)
         short = self.make_short(file)
@@ -403,7 +405,7 @@
                  [(self.dlg.name, self.name, event, argument,
                    condition, ordering)])
 
-    def mapping(self, mapping, attribute):
+    def mapping(self, event, attribute):
         add_data(self.dlg.db, "EventMapping",
                  [(self.dlg.name, self.name, event, attribute)])
 

Modified: python/branches/bcannon-sandboxing/Lib/optparse.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/optparse.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/optparse.py	Wed Aug  2 00:51:44 2006
@@ -16,7 +16,7 @@
 # Python developers: please do not make changes to this file, since
 # it is automatically generated from the Optik source code.
 
-__version__ = "1.5.1+"
+__version__ = "1.5.3"
 
 __all__ = ['Option',
            'SUPPRESS_HELP',
@@ -75,9 +75,9 @@
 
 
 # This file was generated from:
-#   Id: option_parser.py 522 2006-06-11 16:22:03Z gward
+#   Id: option_parser.py 527 2006-07-23 15:21:30Z greg
 #   Id: option.py 522 2006-06-11 16:22:03Z gward
-#   Id: help.py 509 2006-04-20 00:58:24Z gward
+#   Id: help.py 527 2006-07-23 15:21:30Z greg
 #   Id: errors.py 509 2006-04-20 00:58:24Z gward
 
 try:
@@ -1631,7 +1631,10 @@
 
     # used by test suite
     def _get_encoding(self, file):
-        return getattr(file, "encoding", sys.getdefaultencoding())
+        encoding = getattr(file, "encoding", None)
+        if not encoding:
+            encoding = sys.getdefaultencoding()
+        return encoding
 
     def print_help(self, file=None):
         """print_help(file : file = stdout)

Modified: python/branches/bcannon-sandboxing/Lib/os.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/os.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/os.py	Wed Aug  2 00:51:44 2006
@@ -723,7 +723,7 @@
         """
         try:
             _urandomfd = open("/dev/urandom", O_RDONLY)
-        except:
+        except (OSError, IOError):
             raise NotImplementedError("/dev/urandom (or equivalent) not found")
         bytes = ""
         while len(bytes) < n:

Modified: python/branches/bcannon-sandboxing/Lib/pdb.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/pdb.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/pdb.py	Wed Aug  2 00:51:44 2006
@@ -230,7 +230,8 @@
         """Interpret the argument as though it had been typed in response
         to the prompt.
 
-        Checks wether  this line is typed in the normal prompt or in a breakpoint command list definition
+        Checks whether this line is typed at the normal prompt or in
+        a breakpoint command list definition.
         """
         if not self.commands_defining:
             return cmd.Cmd.onecmd(self, line)

Modified: python/branches/bcannon-sandboxing/Lib/pkgutil.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/pkgutil.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/pkgutil.py	Wed Aug  2 00:51:44 2006
@@ -69,7 +69,33 @@
 
 
 def walk_packages(path=None, prefix='', onerror=None):
-    """Yield submodule names+loaders recursively, for path or sys.path"""
+    """Yields (module_loader, name, ispkg) for all modules recursively
+    on path, or, if path is None, all accessible modules.
+
+    'path' should be either None or a list of paths to look for
+    modules in.
+
+    'prefix' is a string to output on the front of every module name
+    on output.
+
+    Note that this function must import all *packages* (NOT all
+    modules!) on the given path, in order to access the __path__
+    attribute to find submodules.
+
+    'onerror' is a function which gets called with one argument (the
+    name of the package which was being imported) if any exception
+    occurs while trying to import a package.  If no onerror function is
+    supplied, ImportErrors are caught and ignored, while all other
+    exceptions are propagated, terminating the search.
+
+    Examples:
+
+    # list all modules python can access
+    walk_packages()
+
+    # list all submodules of ctypes
+    walk_packages(ctypes.__path__, ctypes.__name__+'.')
+    """
 
     def seen(p, m={}):
         if p in m:
@@ -84,19 +110,33 @@
                 __import__(name)
             except ImportError:
                 if onerror is not None:
-                    onerror()
+                    onerror(name)
+            except Exception:
+                if onerror is not None:
+                    onerror(name)
+                else:
+                    raise
             else:
                 path = getattr(sys.modules[name], '__path__', None) or []
 
                 # don't traverse path items we've seen before
                 path = [p for p in path if not seen(p)]
 
-                for item in walk_packages(path, name+'.'):
+                for item in walk_packages(path, name+'.', onerror):
                     yield item
 
 
 def iter_modules(path=None, prefix=''):
-    """Yield submodule names+loaders for path or sys.path"""
+    """Yields (module_loader, name, ispkg) for all submodules on path,
+    or, if path is None, all top-level modules on sys.path.
+
+    'path' should be either None or a list of paths to look for
+    modules in.
+
+    'prefix' is a string to output on the front of every module name
+    on output.
+    """
+
     if path is None:
         importers = iter_importers()
     else:
@@ -341,9 +381,7 @@
             importer = None
         sys.path_importer_cache.setdefault(path_item, importer)
 
-    # The boolean values are used for caching valid and invalid
-    # file paths for the built-in import machinery
-    if importer in (None, True, False):
+    if importer is None:
         try:
             importer = ImpImporter(path_item)
         except ImportError:

Modified: python/branches/bcannon-sandboxing/Lib/popen2.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/popen2.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/popen2.py	Wed Aug  2 00:51:44 2006
@@ -72,7 +72,7 @@
         # In case the child hasn't been waited on, check if it's done.
         self.poll(_deadstate=sys.maxint)
         if self.sts < 0:
-            if _active:
+            if _active is not None:
                 # Child is still running, keep us alive until we can wait on it.
                 _active.append(self)
 

Modified: python/branches/bcannon-sandboxing/Lib/pydoc.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/pydoc.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/pydoc.py	Wed Aug  2 00:51:44 2006
@@ -318,6 +318,8 @@
         # identifies something in a way that pydoc itself has issues handling;
         # think 'super' and how it is a descriptor (which raises the exception
         # by lacking a __name__ attribute) and an instance.
+        if inspect.isgetsetdescriptor(object): return self.docdata(*args)
+        if inspect.ismemberdescriptor(object): return self.docdata(*args)
         try:
             if inspect.ismodule(object): return self.docmodule(*args)
             if inspect.isclass(object): return self.docclass(*args)
@@ -333,7 +335,7 @@
             name and ' ' + repr(name), type(object).__name__)
         raise TypeError, message
 
-    docmodule = docclass = docroutine = docother = fail
+    docmodule = docclass = docroutine = docother = docproperty = docdata = fail
 
     def getdocloc(self, object):
         """Return the location of module docs or None"""
@@ -915,6 +917,10 @@
         lhs = name and '<strong>%s</strong> = ' % name or ''
         return lhs + self.repr(object)
 
+    def docdata(self, object, name=None, mod=None, cl=None):
+        """Produce html documentation for a data descriptor."""
+        return self._docdescriptor(name, object, mod)
+
     def index(self, dir, shadowed=None):
         """Generate an HTML index for a directory of modules."""
         modpkgs = []
@@ -1268,6 +1274,10 @@
         """Produce text documentation for a property."""
         return self._docdescriptor(name, object, mod)
 
+    def docdata(self, object, name=None, mod=None, cl=None):
+        """Produce text documentation for a data descriptor."""
+        return self._docdescriptor(name, object, mod)
+
     def docother(self, object, name=None, mod=None, parent=None, maxlen=None, doc=None):
         """Produce text documentation for a data object."""
         repr = self.repr(object)
@@ -1397,6 +1407,14 @@
             return 'module ' + thing.__name__
     if inspect.isbuiltin(thing):
         return 'built-in function ' + thing.__name__
+    if inspect.isgetsetdescriptor(thing):
+        return 'getset descriptor %s.%s.%s' % (
+            thing.__objclass__.__module__, thing.__objclass__.__name__,
+            thing.__name__)
+    if inspect.ismemberdescriptor(thing):
+        return 'member descriptor %s.%s.%s' % (
+            thing.__objclass__.__module__, thing.__objclass__.__name__,
+            thing.__name__)
     if inspect.isclass(thing):
         return 'class ' + thing.__name__
     if inspect.isfunction(thing):
@@ -1453,6 +1471,8 @@
         if not (inspect.ismodule(object) or
                 inspect.isclass(object) or
                 inspect.isroutine(object) or
+                inspect.isgetsetdescriptor(object) or
+                inspect.ismemberdescriptor(object) or
                 isinstance(object, property)):
             # If the passed object is a piece of data or an instance,
             # document its available methods instead of its value.

Modified: python/branches/bcannon-sandboxing/Lib/runpy.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/runpy.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/runpy.py	Wed Aug  2 00:51:44 2006
@@ -21,19 +21,18 @@
 ]
 
 
-def _run_code(code, run_globals, init_globals, run_name,
+def _run_code(code, run_globals, init_globals,
               mod_name, mod_fname, mod_loader):
     """Helper for _run_module_code"""
     if init_globals is not None:
         run_globals.update(init_globals)
-    run_globals.update(__name__ = run_name,
-                       __module_name__ = mod_name,
+    run_globals.update(__name__ = mod_name,
                        __file__ = mod_fname,
                        __loader__ = mod_loader)
     exec code in run_globals
     return run_globals
 
-def _run_module_code(code, init_globals=None, run_name=None,
+def _run_module_code(code, init_globals=None,
                     mod_name=None, mod_fname=None,
                     mod_loader=None, alter_sys=False):
     """Helper for run_module"""
@@ -43,33 +42,26 @@
         temp_module = imp.new_module(mod_name)
         mod_globals = temp_module.__dict__
         saved_argv0 = sys.argv[0]
-        sentinel = object()
-        module_mod_name = sys.modules.get(mod_name, sentinel)
-        module_run_name = sys.modules.get(run_name, sentinel)
+        restore_module = mod_name in sys.modules
+        if restore_module:
+            saved_module = sys.modules[mod_name]
         sys.argv[0] = mod_fname
         sys.modules[mod_name] = temp_module
-        if run_name != mod_name:
-            sys.modules[run_name] = temp_module
         try:
-            _run_code(code, mod_globals, init_globals, run_name,
+            _run_code(code, mod_globals, init_globals,
                       mod_name, mod_fname, mod_loader)
         finally:
             sys.argv[0] = saved_argv0
-            if module_mod_name is not sentinel:
-                sys.modules[mod_name] = module_mod_name
-            else:
-                del sys.modules[mod_name]
-            if run_name != mod_name:
-                if module_run_name is not sentinel:
-                    sys.modules[run_name] = module_run_name
-                else:
-                    del sys.modules[run_name]
+        if restore_module:
+            sys.modules[mod_name] = saved_module
+        else:
+            del sys.modules[mod_name]
         # Copy the globals of the temporary module, as they
         # may be cleared when the temporary module goes away
         return mod_globals.copy()
     else:
         # Leave the sys module alone
-        return _run_code(code, {}, init_globals, run_name,
+        return _run_code(code, {}, init_globals,
                          mod_name, mod_fname, mod_loader)
 
 
@@ -100,7 +92,7 @@
     if run_name is None:
         run_name = mod_name
     return _run_module_code(code, init_globals, run_name,
-                            mod_name, filename, loader, alter_sys)
+                            filename, loader, alter_sys)
 
 
 if __name__ == "__main__":

Modified: python/branches/bcannon-sandboxing/Lib/shutil.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/shutil.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/shutil.py	Wed Aug  2 00:51:44 2006
@@ -127,7 +127,13 @@
         # continue with other files
         except Error, err:
             errors.extend(err.args[0])
-    copystat(src, dst)
+    try:
+        copystat(src, dst)
+    except WindowsError:
+        # can't copy file access times on Windows
+        pass
+    except OSError, why:
+        errors.extend((src, dst, str(why)))
     if errors:
         raise Error, errors
 

Modified: python/branches/bcannon-sandboxing/Lib/socket.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/socket.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/socket.py	Wed Aug  2 00:51:44 2006
@@ -139,6 +139,8 @@
     __slots__ = []
     def _dummy(*args):
         raise error(EBADF, 'Bad file descriptor')
+    def close(self):
+        pass
     # All _delegate_methods must also be initialized here.
     send = recv = recv_into = sendto = recvfrom = recvfrom_into = _dummy
     __getattr__ = _dummy
@@ -157,6 +159,7 @@
             setattr(self, method, getattr(_sock, method))
 
     def close(self):
+        self._sock.close()
         self._sock = _closedsocket()
         dummy = self._sock._dummy
         for method in _delegate_methods:

Modified: python/branches/bcannon-sandboxing/Lib/struct.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/struct.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/struct.py	Wed Aug  2 00:51:44 2006
@@ -64,7 +64,7 @@
 
 def pack_into(fmt, buf, offset, *args):
     """
-    Pack the values v2, v2, ... according to fmt, write
+    Pack the values v1, v2, ... according to fmt, write
     the packed bytes into the writable buffer buf starting at offset.
     See struct.__doc__ for more on format strings.
     """

Modified: python/branches/bcannon-sandboxing/Lib/subprocess.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/subprocess.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/subprocess.py	Wed Aug  2 00:51:44 2006
@@ -121,7 +121,7 @@
     Run command with arguments.  Wait for command to complete.  If the
     exit code was zero then return, otherwise raise
     CalledProcessError.  The CalledProcessError object will have the
-    return code in the errno attribute.
+    return code in the returncode attribute.
 
     The arguments are the same as for the Popen constructor.  Example:
 
@@ -141,8 +141,8 @@
 
 A ValueError will be raised if Popen is called with invalid arguments.
 
-check_call() will raise CalledProcessError, which is a subclass of
-OSError, if the called process returns a non-zero return code.
+check_call() will raise CalledProcessError, if the called process
+returns a non-zero return code.
 
 
 Security
@@ -234,7 +234,7 @@
 sts = os.system("mycmd" + " myarg")
 ==>
 p = Popen("mycmd" + " myarg", shell=True)
-sts = os.waitpid(p.pid, 0)
+pid, sts = os.waitpid(p.pid, 0)
 
 Note:
 
@@ -360,11 +360,16 @@
 import traceback
 
 # Exception classes used by this module.
-class CalledProcessError(OSError):
+class CalledProcessError(Exception):
     """This exception is raised when a process run by check_call() returns
     a non-zero exit status.  The exit status will be stored in the
-    errno attribute.  This exception is a subclass of
-    OSError."""
+    returncode attribute."""
+    def __init__(self, returncode, cmd):
+        self.returncode = returncode
+        self.cmd = cmd
+    def __str__(self):
+        return "Command '%s' returned non-zero exit status %d" % (self.cmd, self.returncode)
+
 
 if mswindows:
     import threading
@@ -442,7 +447,7 @@
     """Run command with arguments.  Wait for command to complete.  If
     the exit code was zero then return, otherwise raise
     CalledProcessError.  The CalledProcessError object will have the
-    return code in the errno attribute.
+    return code in the returncode attribute.
 
     The arguments are the same as for the Popen constructor.  Example:
 
@@ -453,7 +458,7 @@
     if cmd is None:
         cmd = popenargs[0]
     if retcode:
-        raise CalledProcessError(retcode, "Command %s returned non-zero exit status" % cmd)
+        raise CalledProcessError(retcode, cmd)
     return retcode
 
 
@@ -613,7 +618,7 @@
             return
         # In case the child hasn't been waited on, check if it's done.
         self.poll(_deadstate=sys.maxint)
-        if self.returncode is None:
+        if self.returncode is None and _active is not None:
             # Child is still running, keep us alive until we can wait on it.
             _active.append(self)
 

Modified: python/branches/bcannon-sandboxing/Lib/tarfile.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/tarfile.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/tarfile.py	Wed Aug  2 00:51:44 2006
@@ -1750,13 +1750,6 @@
             try:
                 tarinfo = TarInfo.frombuf(buf)
 
-                # We shouldn't rely on this checksum, because some tar programs
-                # calculate it differently and it is merely validating the
-                # header block. We could just as well skip this part, which would
-                # have a slight effect on performance...
-                if tarinfo.chksum not in calc_chksums(buf):
-                    self._dbg(1, "tarfile: Bad Checksum %r" % tarinfo.name)
-
                 # Set the TarInfo object's offset to the current position of the
                 # TarFile and set self.offset to the position where the data blocks
                 # should begin.

Modified: python/branches/bcannon-sandboxing/Lib/test/crashers/bogus_code_obj.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/crashers/bogus_code_obj.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/crashers/bogus_code_obj.py	Wed Aug  2 00:51:44 2006
@@ -1,5 +1,15 @@
 """
 Broken bytecode objects can easily crash the interpreter.
+
+This is not going to be fixed.  It is generally agreed that there is no
+point in writing a bytecode verifier and putting it in CPython just for
+this.  Moreover, a verifier is bound to accept only a subset of all safe
+bytecodes, so it could lead to unnecessary breakage.
+
+For security purposes, "restricted" interpreters are not going to let
+the user build or load random bytecodes anyway.  Otherwise, this is a
+"won't fix" case.
+
 """
 
 import types

Modified: python/branches/bcannon-sandboxing/Lib/test/crashers/gc_inspection.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/crashers/gc_inspection.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/crashers/gc_inspection.py	Wed Aug  2 00:51:44 2006
@@ -1,5 +1,20 @@
 """
 gc.get_referrers() can be used to see objects before they are fully built.
+
+Note that this is only an example.  There are many ways to crash Python
+by using gc.get_referrers(), as well as many extension modules (even
+when they are using perfectly documented patterns to build objects).
+
+Identifying and removing all places that expose to the GC a
+partially-built object is a long-term project.  A patch was proposed on
+SF specifically for this example but I consider fixing just this single
+example a bit pointless (#1517042).
+
+A fix would include a whole-scale code review, possibly with an API
+change to decouple object creation and GC registration, and according
+fixes to the documentation for extension module writers.  It's unlikely
+to happen, though.  So this is currently classified as
+"gc.get_referrers() is dangerous, use only for debugging".
 """
 
 import gc

Modified: python/branches/bcannon-sandboxing/Lib/test/crashers/recursive_call.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/crashers/recursive_call.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/crashers/recursive_call.py	Wed Aug  2 00:51:44 2006
@@ -1,6 +1,11 @@
 #!/usr/bin/env python
 
 # No bug report AFAIK, mail on python-dev on 2006-01-10
+
+# This is a "won't fix" case.  It is known that setting a high enough
+# recursion limit crashes by overflowing the stack.  Unless this is
+# redesigned somehow, it won't go away.
+
 import sys
 
 sys.setrecursionlimit(1 << 30)

Modified: python/branches/bcannon-sandboxing/Lib/test/fork_wait.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/fork_wait.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/fork_wait.py	Wed Aug  2 00:51:44 2006
@@ -34,7 +34,14 @@
                 pass
 
     def wait_impl(self, cpid):
-        spid, status = os.waitpid(cpid, 0)
+        for i in range(10):
+            # waitpid() shouldn't hang, but some of the buildbots seem to hang
+            # in the forking tests.  This is an attempt to fix the problem.
+            spid, status = os.waitpid(cpid, os.WNOHANG)
+            if spid == cpid:
+                break
+            time.sleep(2 * SHORTSLEEP)
+
         self.assertEquals(spid, cpid)
         self.assertEquals(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
 

Modified: python/branches/bcannon-sandboxing/Lib/test/output/test_ossaudiodev
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/output/test_ossaudiodev	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/output/test_ossaudiodev	Wed Aug  2 00:51:44 2006
@@ -1,3 +1,2 @@
 test_ossaudiodev
-playing test sound file...
-elapsed time: 3.1 sec
+playing test sound file (expected running time: 2.93 sec)

Modified: python/branches/bcannon-sandboxing/Lib/test/string_tests.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/string_tests.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/string_tests.py	Wed Aug  2 00:51:44 2006
@@ -147,8 +147,8 @@
                 else:
                     r2, rem = len(i)+1, 0
                 if rem or r1 != r2:
-                    self.assertEqual(rem, 0)
-                    self.assertEqual(r1, r2)
+                    self.assertEqual(rem, 0, '%s != 0 for %s' % (rem, i))
+                    self.assertEqual(r1, r2, '%s != %s for %s' % (r1, r2, i))
 
     def test_find(self):
         self.checkequal(0, 'abcdefghiabc', 'find', 'abc')
@@ -636,6 +636,11 @@
         EQ("bobobXbobob", "bobobobXbobobob", "replace", "bobob", "bob")
         EQ("BOBOBOB", "BOBOBOB", "replace", "bob", "bobby")
 
+        ba = buffer('a')
+        bb = buffer('b')
+        EQ("bbc", "abc", "replace", ba, bb)
+        EQ("aac", "abc", "replace", bb, ba)
+
         #
         self.checkequal('one at two!three!', 'one!two!three!', 'replace', '!', '@', 1)
         self.checkequal('onetwothree', 'one!two!three!', 'replace', '!', '')

Modified: python/branches/bcannon-sandboxing/Lib/test/test_ast.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_ast.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_ast.py	Wed Aug  2 00:51:44 2006
@@ -160,7 +160,7 @@
 ('Module', [('FunctionDef', (1, 0), 'f', ('arguments', [], None, None, []), [('Return', (1, 8), ('Num', (1, 15), 1))], [])]),
 ('Module', [('Delete', (1, 0), [('Name', (1, 4), 'v', ('Del',))])]),
 ('Module', [('Assign', (1, 0), [('Name', (1, 0), 'v', ('Store',))], ('Num', (1, 4), 1))]),
-('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('Load',)), ('Add',), ('Num', (1, 5), 1))]),
+('Module', [('AugAssign', (1, 0), ('Name', (1, 0), 'v', ('Store',)), ('Add',), ('Num', (1, 5), 1))]),
 ('Module', [('Print', (1, 0), ('Name', (1, 8), 'f', ('Load',)), [('Num', (1, 11), 1)], False)]),
 ('Module', [('For', (1, 0), ('Name', (1, 4), 'v', ('Store',)), ('Name', (1, 9), 'v', ('Load',)), [('Pass', (1, 11))], [])]),
 ('Module', [('While', (1, 0), ('Name', (1, 6), 'v', ('Load',)), [('Pass', (1, 8))], [])]),

Modified: python/branches/bcannon-sandboxing/Lib/test/test_bsddb.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_bsddb.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_bsddb.py	Wed Aug  2 00:51:44 2006
@@ -8,7 +8,6 @@
 import dbhash # Just so we know it's imported
 import unittest
 from test import test_support
-from sets import Set
 
 class TestBSDDB(unittest.TestCase):
     openflag = 'c'
@@ -53,7 +52,7 @@
             self.assertEqual(self.f[k], v)
 
     def assertSetEquals(self, seqn1, seqn2):
-        self.assertEqual(Set(seqn1), Set(seqn2))
+        self.assertEqual(set(seqn1), set(seqn2))
 
     def test_mapping_iteration_methods(self):
         f = self.f

Modified: python/branches/bcannon-sandboxing/Lib/test/test_compile.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_compile.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_compile.py	Wed Aug  2 00:51:44 2006
@@ -166,6 +166,16 @@
         pass"""
         compile(s, "<string>", "exec")
 
+    # This test is probably specific to CPython and may not generalize
+    # to other implementations.  We are trying to ensure that when
+    # the first line of code starts after 256, correct line numbers
+    # in tracebacks are still produced.
+    def test_leading_newlines(self):
+        s256 = "".join(["\n"] * 256 + ["spam"])
+        co = compile(s256, 'fn', 'exec')
+        self.assertEqual(co.co_firstlineno, 257)
+        self.assertEqual(co.co_lnotab, '')
+
     def test_literals_with_leading_zeroes(self):
         for arg in ["077787", "0xj", "0x.", "0e",  "090000000000000",
                     "080000000000000", "000000000000009", "000000000000008"]:
@@ -211,6 +221,25 @@
             self.assertEqual(eval("-" + all_one_bits), -18446744073709551615L)
         else:
             self.fail("How many bits *does* this machine have???")
+        # Verify treatment of contant folding on -(sys.maxint+1)
+        # i.e. -2147483648 on 32 bit platforms.  Should return int, not long.
+        self.assertTrue(isinstance(eval("%s" % (-sys.maxint - 1)), int))
+        self.assertTrue(isinstance(eval("%s" % (-sys.maxint - 2)), long))
+
+    if sys.maxint == 9223372036854775807:
+        def test_32_63_bit_values(self):
+            a = +4294967296  # 1 << 32
+            b = -4294967296  # 1 << 32
+            c = +281474976710656  # 1 << 48
+            d = -281474976710656  # 1 << 48
+            e = +4611686018427387904  # 1 << 62
+            f = -4611686018427387904  # 1 << 62
+            g = +9223372036854775807  # 1 << 63 - 1
+            h = -9223372036854775807  # 1 << 63 - 1
+
+            for variable in self.test_32_63_bit_values.func_code.co_consts:
+                if variable is not None:
+                    self.assertTrue(isinstance(variable, int))
 
     def test_sequence_unpacking_error(self):
         # Verify sequence packing/unpacking with "or".  SF bug #757818
@@ -238,6 +267,8 @@
         succeed = [
             'import sys',
             'import os, sys',
+            'import os as bar',
+            'import os.path as bar',
             'from __future__ import nested_scopes, generators',
             'from __future__ import (nested_scopes,\ngenerators)',
             'from __future__ import (nested_scopes,\ngenerators,)',
@@ -257,6 +288,10 @@
             'import (sys',
             'import sys)',
             'import (os,)',
+            'import os As bar',
+            'import os.path a bar',
+            'from sys import stdin As stdout',
+            'from sys import stdin a stdout',
             'from (sys) import stdin',
             'from __future__ import (nested_scopes',
             'from __future__ import nested_scopes)',

Modified: python/branches/bcannon-sandboxing/Lib/test/test_compiler.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_compiler.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_compiler.py	Wed Aug  2 00:51:44 2006
@@ -68,6 +68,14 @@
     def testDefaultArgs(self):
         self.assertRaises(SyntaxError, compiler.parse, "def foo(a=1, b): pass")
 
+    def testDocstrings(self):
+        c = compiler.compile('"doc"', '<string>', 'exec')
+        self.assert_('__doc__' in c.co_names)
+        c = compiler.compile('def f():\n "doc"', '<string>', 'exec')
+        g = {}
+        exec c in g
+        self.assertEquals(g['f'].__doc__, "doc")
+
     def testLineNo(self):
         # Test that all nodes except Module have a correct lineno attribute.
         filename = __file__

Modified: python/branches/bcannon-sandboxing/Lib/test/test_defaultdict.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_defaultdict.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_defaultdict.py	Wed Aug  2 00:51:44 2006
@@ -4,6 +4,7 @@
 import copy
 import tempfile
 import unittest
+from test import test_support
 
 from collections import defaultdict
 
@@ -131,5 +132,8 @@
         self.assertEqual(d2, d1)
 
 
+def test_main():
+    test_support.run_unittest(TestDefaultDict)
+
 if __name__ == "__main__":
-    unittest.main()
+    test_main()

Modified: python/branches/bcannon-sandboxing/Lib/test/test_dis.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_dis.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_dis.py	Wed Aug  2 00:51:44 2006
@@ -81,6 +81,13 @@
      bug1333982.func_code.co_firstlineno + 2,
      bug1333982.func_code.co_firstlineno + 3)
 
+_BIG_LINENO_FORMAT = """\
+%3d           0 LOAD_GLOBAL              0 (spam)
+              3 POP_TOP
+              4 LOAD_CONST               0 (None)
+              7 RETURN_VALUE
+"""
+
 class DisTests(unittest.TestCase):
     def do_disassembly_test(self, func, expected):
         s = StringIO.StringIO()
@@ -124,6 +131,23 @@
         if __debug__:
             self.do_disassembly_test(bug1333982, dis_bug1333982)
 
+    def test_big_linenos(self):
+        def func(count):
+            namespace = {}
+            func = "def foo():\n " + "".join(["\n "] * count + ["spam\n"])
+            exec func in namespace
+            return namespace['foo']
+
+        # Test all small ranges
+        for i in xrange(1, 300):
+            expected = _BIG_LINENO_FORMAT % (i + 2)
+            self.do_disassembly_test(func(i), expected)
+
+        # Test some larger ranges too
+        for i in xrange(300, 5000, 10):
+            expected = _BIG_LINENO_FORMAT % (i + 2)
+            self.do_disassembly_test(func(i), expected)
+
 def test_main():
     run_unittest(DisTests)
 

Modified: python/branches/bcannon-sandboxing/Lib/test/test_doctest.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_doctest.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_doctest.py	Wed Aug  2 00:51:44 2006
@@ -419,7 +419,6 @@
 
     >>> finder = doctest.DocTestFinder()
     >>> tests = finder.find(SampleClass)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      3  SampleClass
@@ -435,7 +434,6 @@
 New-style classes are also supported:
 
     >>> tests = finder.find(SampleNewStyleClass)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      1  SampleNewStyleClass
@@ -475,7 +473,6 @@
     >>> # ignoring the objects since they weren't defined in m.
     >>> import test.test_doctest
     >>> tests = finder.find(m, module=test.test_doctest)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      1  some_module
@@ -499,7 +496,6 @@
 
     >>> from test import doctest_aliases
     >>> tests = excl_empty_finder.find(doctest_aliases)
-    >>> tests.sort()
     >>> print len(tests)
     2
     >>> print tests[0].name
@@ -517,7 +513,6 @@
 By default, an object with no doctests doesn't create any tests:
 
     >>> tests = doctest.DocTestFinder().find(SampleClass)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      3  SampleClass
@@ -536,7 +531,6 @@
 displays.
 
     >>> tests = doctest.DocTestFinder(exclude_empty=False).find(SampleClass)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      3  SampleClass
@@ -557,7 +551,6 @@
 using the `recurse` flag:
 
     >>> tests = doctest.DocTestFinder(recurse=False).find(SampleClass)
-    >>> tests.sort()
     >>> for t in tests:
     ...     print '%2s  %s' % (len(t.examples), t.name)
      3  SampleClass

Modified: python/branches/bcannon-sandboxing/Lib/test/test_email_codecs.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_email_codecs.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_email_codecs.py	Wed Aug  2 00:51:44 2006
@@ -1,11 +1,15 @@
 # Copyright (C) 2002 Python Software Foundation
 # email package unit tests for (optional) Asian codecs
 
-import unittest
 # The specific tests now live in Lib/email/test
-from email.test.test_email_codecs import suite
+from email.test import test_email_codecs
+from email.test import test_email_codecs_renamed
+from test import test_support
 
+def test_main():
+    suite = test_email_codecs.suite()
+    suite.addTest(test_email_codecs_renamed.suite())
+    test_support.run_suite(suite)
 
-
 if __name__ == '__main__':
-    unittest.main(defaultTest='suite')
+    test_main()

Modified: python/branches/bcannon-sandboxing/Lib/test/test_filecmp.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_filecmp.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_filecmp.py	Wed Aug  2 00:51:44 2006
@@ -1,5 +1,5 @@
 
-import os, filecmp, shutil, tempfile
+import os, filecmp, shutil, tempfile, shutil
 import unittest
 from test import test_support
 
@@ -49,6 +49,7 @@
         self.caseinsensitive = os.path.normcase('A') == os.path.normcase('a')
         data = 'Contents of file go here.\n'
         for dir in [self.dir, self.dir_same, self.dir_diff]:
+            shutil.rmtree(dir, True)
             os.mkdir(dir)
             if self.caseinsensitive and dir is self.dir_same:
                 fn = 'FiLe'     # Verify case-insensitive comparison

Modified: python/branches/bcannon-sandboxing/Lib/test/test_fork1.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_fork1.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_fork1.py	Wed Aug  2 00:51:44 2006
@@ -2,6 +2,7 @@
 """
 
 import os
+import time
 from test.fork_wait import ForkWait
 from test.test_support import TestSkipped, run_unittest, reap_children
 
@@ -12,7 +13,14 @@
 
 class ForkTest(ForkWait):
     def wait_impl(self, cpid):
-        spid, status = os.waitpid(cpid, 0)
+        for i in range(10):
+            # waitpid() shouldn't hang, but some of the buildbots seem to hang
+            # in the forking tests.  This is an attempt to fix the problem.
+            spid, status = os.waitpid(cpid, os.WNOHANG)
+            if spid == cpid:
+                break
+            time.sleep(1.0)
+
         self.assertEqual(spid, cpid)
         self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
 

Modified: python/branches/bcannon-sandboxing/Lib/test/test_generators.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_generators.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_generators.py	Wed Aug  2 00:51:44 2006
@@ -1497,22 +1497,55 @@
 <type 'generator'>
 
 
+A yield expression with augmented assignment.
+
+>>> def coroutine(seq):
+...     count = 0
+...     while count < 200:
+...         count += yield
+...         seq.append(count)
+>>> seq = []
+>>> c = coroutine(seq)
+>>> c.next()
+>>> print seq
+[]
+>>> c.send(10)
+>>> print seq
+[10]
+>>> c.send(10)
+>>> print seq
+[10, 20]
+>>> c.send(10)
+>>> print seq
+[10, 20, 30]
+
+
 Check some syntax errors for yield expressions:
 
 >>> f=lambda: (yield 1),(yield 2)
 Traceback (most recent call last):
   ...
-SyntaxError: 'yield' outside function (<doctest test.test_generators.__test__.coroutine[10]>, line 1)
+SyntaxError: 'yield' outside function (<doctest test.test_generators.__test__.coroutine[21]>, line 1)
 
 >>> def f(): return lambda x=(yield): 1
 Traceback (most recent call last):
   ...
-SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.coroutine[11]>, line 1)
+SyntaxError: 'return' with argument inside generator (<doctest test.test_generators.__test__.coroutine[22]>, line 1)
 
 >>> def f(): x = yield = y
 Traceback (most recent call last):
   ...
-SyntaxError: assignment to yield expression not possible (<doctest test.test_generators.__test__.coroutine[12]>, line 1)
+SyntaxError: assignment to yield expression not possible (<doctest test.test_generators.__test__.coroutine[23]>, line 1)
+
+>>> def f(): (yield bar) = y
+Traceback (most recent call last):
+  ...
+SyntaxError: can't assign to yield expression (<doctest test.test_generators.__test__.coroutine[24]>, line 1)
+
+>>> def f(): (yield bar) += y
+Traceback (most recent call last):
+  ...
+SyntaxError: augmented assignment to yield expression not possible (<doctest test.test_generators.__test__.coroutine[25]>, line 1)
 
 
 Now check some throw() conditions:

Modified: python/branches/bcannon-sandboxing/Lib/test/test_getargs2.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_getargs2.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_getargs2.py	Wed Aug  2 00:51:44 2006
@@ -233,8 +233,25 @@
 
         self.failUnlessEqual(VERY_LARGE & ULLONG_MAX, getargs_K(VERY_LARGE))
 
+
+class Tuple_TestCase(unittest.TestCase):
+    def test_tuple(self):
+        from _testcapi import getargs_tuple
+
+        ret = getargs_tuple(1, (2, 3))
+        self.assertEquals(ret, (1,2,3))
+
+        # make sure invalid tuple arguments are handled correctly
+        class seq:
+            def __len__(self):
+                return 2
+            def __getitem__(self, n):
+                raise ValueError
+        self.assertRaises(TypeError, getargs_tuple, 1, seq())
+
+
 def test_main():
-    tests = [Signed_TestCase, Unsigned_TestCase]
+    tests = [Signed_TestCase, Unsigned_TestCase, Tuple_TestCase]
     try:
         from _testcapi import getargs_L, getargs_K
     except ImportError:

Modified: python/branches/bcannon-sandboxing/Lib/test/test_grammar.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_grammar.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_grammar.py	Wed Aug  2 00:51:44 2006
@@ -531,6 +531,11 @@
 for x in Squares(10): n = n+x
 if n != 285: raise TestFailed, 'for over growing sequence'
 
+result = []
+for x, in [(1,), (2,), (3,)]:
+    result.append(x)
+vereq(result, [1, 2, 3])
+
 print 'try_stmt'
 ### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite]
 ###         | 'try' ':' suite 'finally' ':' suite

Modified: python/branches/bcannon-sandboxing/Lib/test/test_inspect.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_inspect.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_inspect.py	Wed Aug  2 00:51:44 2006
@@ -1,6 +1,8 @@
 import sys
+import types
 import unittest
 import inspect
+import datetime
 
 from test.test_support import TESTFN, run_unittest
 
@@ -40,10 +42,12 @@
             self.failIf(other(obj), 'not %s(%s)' % (other.__name__, exp))
 
 class TestPredicates(IsTestBase):
-    def test_eleven(self):
-        # Doc/lib/libinspect.tex claims there are 11 such functions
+    def test_thirteen(self):
         count = len(filter(lambda x:x.startswith('is'), dir(inspect)))
-        self.assertEqual(count, 11, "There are %d (not 11) is* functions" % count)
+        # Doc/lib/libinspect.tex claims there are 13 such functions
+        expected = 13
+        err_msg = "There are %d (not %d) is* functions" % (count, expected)
+        self.assertEqual(count, expected, err_msg)
 
     def test_excluding_predicates(self):
         self.istest(inspect.isbuiltin, 'sys.exit')
@@ -58,6 +62,15 @@
         self.istest(inspect.istraceback, 'tb')
         self.istest(inspect.isdatadescriptor, '__builtin__.file.closed')
         self.istest(inspect.isdatadescriptor, '__builtin__.file.softspace')
+        if hasattr(types, 'GetSetDescriptorType'):
+            self.istest(inspect.isgetsetdescriptor,
+                        'type(tb.tb_frame).f_locals')
+        else:
+            self.failIf(inspect.isgetsetdescriptor(type(tb.tb_frame).f_locals))
+        if hasattr(types, 'MemberDescriptorType'):
+            self.istest(inspect.ismemberdescriptor, 'datetime.timedelta.days')
+        else:
+            self.failIf(inspect.ismemberdescriptor(datetime.timedelta.days))
 
     def test_isroutine(self):
         self.assert_(inspect.isroutine(mod.spam))
@@ -178,6 +191,17 @@
     def test_getfile(self):
         self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__)
 
+    def test_getmodule_recursion(self):
+        from new import module
+        name = '__inspect_dummy'
+        m = sys.modules[name] = module(name)
+        m.__file__ = "<string>" # hopefully not a real filename...
+        m.__loader__ = "dummy"  # pretend the filename is understood by a loader
+        exec "def x(): pass" in m.__dict__
+        self.assertEqual(inspect.getsourcefile(m.x.func_code), '<string>')
+        del sys.modules[name]
+        inspect.getmodule(compile('a=10','','single'))
+
 class TestDecorators(GetSourceBase):
     fodderFile = mod2
 

Modified: python/branches/bcannon-sandboxing/Lib/test/test_iterlen.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_iterlen.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_iterlen.py	Wed Aug  2 00:51:44 2006
@@ -235,9 +235,7 @@
         self.assertEqual(len(it), 0)
 
 
-
-if __name__ == "__main__":
-
+def test_main():
     unittests = [
         TestRepeat,
         TestXrange,
@@ -255,3 +253,6 @@
         TestSeqIterReversed,
     ]
     test_support.run_unittest(*unittests)
+
+if __name__ == "__main__":
+    test_main()

Modified: python/branches/bcannon-sandboxing/Lib/test/test_mailbox.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_mailbox.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_mailbox.py	Wed Aug  2 00:51:44 2006
@@ -461,7 +461,7 @@
 
     def setUp(self):
         TestMailbox.setUp(self)
-        if os.name == 'nt':
+        if os.name in ('nt', 'os2'):
             self._box.colon = '!'
 
     def test_add_MM(self):
@@ -520,7 +520,7 @@
         # Initialize an existing mailbox
         self.tearDown()
         for subdir in '', 'tmp', 'new', 'cur':
-            os.mkdir(os.path.join(self._path, subdir))
+            os.mkdir(os.path.normpath(os.path.join(self._path, subdir)))
         self._box = mailbox.Maildir(self._path)
         self._check_basics(factory=rfc822.Message)
         self._box = mailbox.Maildir(self._path, factory=None)

Modified: python/branches/bcannon-sandboxing/Lib/test/test_mimetools.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_mimetools.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_mimetools.py	Wed Aug  2 00:51:44 2006
@@ -1,7 +1,7 @@
 import unittest
 from test import test_support
 
-import string, StringIO, mimetools, sets
+import string, StringIO, mimetools
 
 msgtext1 = mimetools.Message(StringIO.StringIO(
 """Content-Type: text/plain; charset=iso-8859-1; format=flowed
@@ -25,7 +25,7 @@
             self.assertEqual(o.getvalue(), start)
 
     def test_boundary(self):
-        s = sets.Set([""])
+        s = set([""])
         for i in xrange(100):
             nb = mimetools.choose_boundary()
             self.assert_(nb not in s)

Modified: python/branches/bcannon-sandboxing/Lib/test/test_mimetypes.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_mimetypes.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_mimetypes.py	Wed Aug  2 00:51:44 2006
@@ -1,7 +1,6 @@
 import mimetypes
 import StringIO
 import unittest
-from sets import Set
 
 from test import test_support
 
@@ -52,8 +51,8 @@
         # First try strict.  Use a set here for testing the results because if
         # test_urllib2 is run before test_mimetypes, global state is modified
         # such that the 'all' set will have more items in it.
-        all = Set(self.db.guess_all_extensions('text/plain', strict=True))
-        unless(all >= Set(['.bat', '.c', '.h', '.ksh', '.pl', '.txt']))
+        all = set(self.db.guess_all_extensions('text/plain', strict=True))
+        unless(all >= set(['.bat', '.c', '.h', '.ksh', '.pl', '.txt']))
         # And now non-strict
         all = self.db.guess_all_extensions('image/jpg', strict=False)
         all.sort()

Modified: python/branches/bcannon-sandboxing/Lib/test/test_minidom.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_minidom.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_minidom.py	Wed Aug  2 00:51:44 2006
@@ -1,4 +1,4 @@
-# test for xmlcore.dom.minidom
+# test for xml.dom.minidom
 
 import os
 import sys
@@ -7,12 +7,12 @@
 from StringIO import StringIO
 from test.test_support import verbose
 
-import xmlcore.dom
-import xmlcore.dom.minidom
-import xmlcore.parsers.expat
+import xml.dom
+import xml.dom.minidom
+import xml.parsers.expat
 
-from xmlcore.dom.minidom import parse, Node, Document, parseString
-from xmlcore.dom.minidom import getDOMImplementation
+from xml.dom.minidom import parse, Node, Document, parseString
+from xml.dom.minidom import getDOMImplementation
 
 
 if __name__ == "__main__":
@@ -138,29 +138,29 @@
     text = dom.createTextNode('text')
 
     try: dom.appendChild(text)
-    except xmlcore.dom.HierarchyRequestErr: pass
+    except xml.dom.HierarchyRequestErr: pass
     else:
         print "dom.appendChild didn't raise HierarchyRequestErr"
 
     dom.appendChild(elem)
     try: dom.insertBefore(text, elem)
-    except xmlcore.dom.HierarchyRequestErr: pass
+    except xml.dom.HierarchyRequestErr: pass
     else:
         print "dom.appendChild didn't raise HierarchyRequestErr"
 
     try: dom.replaceChild(text, elem)
-    except xmlcore.dom.HierarchyRequestErr: pass
+    except xml.dom.HierarchyRequestErr: pass
     else:
         print "dom.appendChild didn't raise HierarchyRequestErr"
 
     nodemap = elem.attributes
     try: nodemap.setNamedItem(text)
-    except xmlcore.dom.HierarchyRequestErr: pass
+    except xml.dom.HierarchyRequestErr: pass
     else:
         print "NamedNodeMap.setNamedItem didn't raise HierarchyRequestErr"
 
     try: nodemap.setNamedItemNS(text)
-    except xmlcore.dom.HierarchyRequestErr: pass
+    except xml.dom.HierarchyRequestErr: pass
     else:
         print "NamedNodeMap.setNamedItemNS didn't raise HierarchyRequestErr"
 
@@ -439,7 +439,7 @@
             and pi.firstChild is None
             and pi.lastChild is None
             and pi.localName is None
-            and pi.namespaceURI == xmlcore.dom.EMPTY_NAMESPACE)
+            and pi.namespaceURI == xml.dom.EMPTY_NAMESPACE)
 
 def testProcessingInstructionRepr(): pass
 
@@ -454,7 +454,7 @@
     elem = doc.createElement("extra")
     try:
         doc.appendChild(elem)
-    except xmlcore.dom.HierarchyRequestErr:
+    except xml.dom.HierarchyRequestErr:
         pass
     else:
         print "Failed to catch expected exception when" \
@@ -491,7 +491,7 @@
     confirm(a1.isSameNode(a2))
     try:
         attrs.removeNamedItem("a")
-    except xmlcore.dom.NotFoundErr:
+    except xml.dom.NotFoundErr:
         pass
 
 def testRemoveNamedItemNS():
@@ -503,7 +503,7 @@
     confirm(a1.isSameNode(a2))
     try:
         attrs.removeNamedItemNS("http://xml.python.org/", "b")
-    except xmlcore.dom.NotFoundErr:
+    except xml.dom.NotFoundErr:
         pass
 
 def testAttrListValues(): pass
@@ -682,7 +682,7 @@
     doc2 = parseString("<doc/>")
     try:
         doc1.importNode(doc2, deep)
-    except xmlcore.dom.NotSupportedErr:
+    except xml.dom.NotSupportedErr:
         pass
     else:
         raise Exception(testName +
@@ -705,14 +705,12 @@
     doctype = getDOMImplementation().createDocumentType("doc", None, None)
     doctype.entities._seq = []
     doctype.notations._seq = []
-    notation = xmlcore.dom.minidom.Notation(
-        "my-notation", None,
-        "http://xml.python.org/notations/my")
+    notation = xml.dom.minidom.Notation("my-notation", None,
+                                        "http://xml.python.org/notations/my")
     doctype.notations._seq.append(notation)
-    entity = xmlcore.dom.minidom.Entity(
-        "my-entity", None,
-        "http://xml.python.org/entities/my",
-        "my-notation")
+    entity = xml.dom.minidom.Entity("my-entity", None,
+                                    "http://xml.python.org/entities/my",
+                                    "my-notation")
     entity.version = "1.0"
     entity.encoding = "utf-8"
     entity.actualEncoding = "us-ascii"
@@ -731,7 +729,7 @@
     target = create_doc_without_doctype()
     try:
         imported = target.importNode(src.doctype, 0)
-    except xmlcore.dom.NotSupportedErr:
+    except xml.dom.NotSupportedErr:
         pass
     else:
         raise Exception(
@@ -742,7 +740,7 @@
     target = create_doc_without_doctype()
     try:
         imported = target.importNode(src.doctype, 1)
-    except xmlcore.dom.NotSupportedErr:
+    except xml.dom.NotSupportedErr:
         pass
     else:
         raise Exception(
@@ -850,7 +848,7 @@
     doc.unlink()
 
 def testSAX2DOM():
-    from xmlcore.dom import pulldom
+    from xml.dom import pulldom
 
     sax2dom = pulldom.SAX2DOM()
     sax2dom.startDocument()
@@ -940,11 +938,11 @@
     attr = elem.attributes['a']
 
     # Simple renaming
-    attr = doc.renameNode(attr, xmlcore.dom.EMPTY_NAMESPACE, "b")
+    attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "b")
     confirm(attr.name == "b"
             and attr.nodeName == "b"
             and attr.localName is None
-            and attr.namespaceURI == xmlcore.dom.EMPTY_NAMESPACE
+            and attr.namespaceURI == xml.dom.EMPTY_NAMESPACE
             and attr.prefix is None
             and attr.value == "v"
             and elem.getAttributeNode("a") is None
@@ -989,11 +987,11 @@
             and attrmap[("http://xml.python.org/ns2", "d")].isSameNode(attr))
 
     # Rename back to a simple non-NS node
-    attr = doc.renameNode(attr, xmlcore.dom.EMPTY_NAMESPACE, "e")
+    attr = doc.renameNode(attr, xml.dom.EMPTY_NAMESPACE, "e")
     confirm(attr.name == "e"
             and attr.nodeName == "e"
             and attr.localName is None
-            and attr.namespaceURI == xmlcore.dom.EMPTY_NAMESPACE
+            and attr.namespaceURI == xml.dom.EMPTY_NAMESPACE
             and attr.prefix is None
             and attr.value == "v"
             and elem.getAttributeNode("a") is None
@@ -1007,7 +1005,7 @@
 
     try:
         doc.renameNode(attr, "http://xml.python.org/ns", "xmlns")
-    except xmlcore.dom.NamespaceErr:
+    except xml.dom.NamespaceErr:
         pass
     else:
         print "expected NamespaceErr"
@@ -1020,11 +1018,11 @@
     elem = doc.documentElement
 
     # Simple renaming
-    elem = doc.renameNode(elem, xmlcore.dom.EMPTY_NAMESPACE, "a")
+    elem = doc.renameNode(elem, xml.dom.EMPTY_NAMESPACE, "a")
     confirm(elem.tagName == "a"
             and elem.nodeName == "a"
             and elem.localName is None
-            and elem.namespaceURI == xmlcore.dom.EMPTY_NAMESPACE
+            and elem.namespaceURI == xml.dom.EMPTY_NAMESPACE
             and elem.prefix is None
             and elem.ownerDocument.isSameNode(doc))
 
@@ -1047,11 +1045,11 @@
             and elem.ownerDocument.isSameNode(doc))
 
     # Rename back to a simple non-NS node
-    elem = doc.renameNode(elem, xmlcore.dom.EMPTY_NAMESPACE, "d")
+    elem = doc.renameNode(elem, xml.dom.EMPTY_NAMESPACE, "d")
     confirm(elem.tagName == "d"
             and elem.nodeName == "d"
             and elem.localName is None
-            and elem.namespaceURI == xmlcore.dom.EMPTY_NAMESPACE
+            and elem.namespaceURI == xml.dom.EMPTY_NAMESPACE
             and elem.prefix is None
             and elem.ownerDocument.isSameNode(doc))
 
@@ -1062,15 +1060,15 @@
     # Make sure illegal NS usage is detected:
     try:
         doc.renameNode(node, "http://xml.python.org/ns", "xmlns:foo")
-    except xmlcore.dom.NamespaceErr:
+    except xml.dom.NamespaceErr:
         pass
     else:
         print "expected NamespaceErr"
 
     doc2 = parseString("<doc/>")
     try:
-        doc2.renameNode(node, xmlcore.dom.EMPTY_NAMESPACE, "foo")
-    except xmlcore.dom.WrongDocumentErr:
+        doc2.renameNode(node, xml.dom.EMPTY_NAMESPACE, "foo")
+    except xml.dom.WrongDocumentErr:
         pass
     else:
         print "expected WrongDocumentErr"
@@ -1078,12 +1076,12 @@
 def testRenameOther():
     # We have to create a comment node explicitly since not all DOM
     # builders used with minidom add comments to the DOM.
-    doc = xmlcore.dom.minidom.getDOMImplementation().createDocument(
-        xmlcore.dom.EMPTY_NAMESPACE, "e", None)
+    doc = xml.dom.minidom.getDOMImplementation().createDocument(
+        xml.dom.EMPTY_NAMESPACE, "e", None)
     node = doc.createComment("comment")
     try:
-        doc.renameNode(node, xmlcore.dom.EMPTY_NAMESPACE, "foo")
-    except xmlcore.dom.NotSupportedErr:
+        doc.renameNode(node, xml.dom.EMPTY_NAMESPACE, "foo")
+    except xml.dom.NotSupportedErr:
         pass
     else:
         print "expected NotSupportedErr when renaming comment node"
@@ -1194,13 +1192,13 @@
     # since each supports a different level of DTD information.
     t = elem.schemaType
     confirm(t.name is None
-            and t.namespace == xmlcore.dom.EMPTY_NAMESPACE)
+            and t.namespace == xml.dom.EMPTY_NAMESPACE)
     names = "id notid text enum ref refs ent ents nm nms".split()
     for name in names:
         a = elem.getAttributeNode(name)
         t = a.schemaType
         confirm(hasattr(t, "name")
-                and t.namespace == xmlcore.dom.EMPTY_NAMESPACE)
+                and t.namespace == xml.dom.EMPTY_NAMESPACE)
 
 def testSetIdAttribute():
     doc = parseString("<doc a1='v' a2='w'/>")
@@ -1229,7 +1227,7 @@
             and a2.isId
             and not a3.isId)
     # renaming an attribute should not affect its ID-ness:
-    doc.renameNode(a2, xmlcore.dom.EMPTY_NAMESPACE, "an")
+    doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
     confirm(e.isSameNode(doc.getElementById("w"))
             and a2.isId)
 
@@ -1265,7 +1263,7 @@
     confirm(not a3.isId)
     confirm(doc.getElementById("v") is None)
     # renaming an attribute should not affect its ID-ness:
-    doc.renameNode(a2, xmlcore.dom.EMPTY_NAMESPACE, "an")
+    doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
     confirm(e.isSameNode(doc.getElementById("w"))
             and a2.isId)
 
@@ -1301,7 +1299,7 @@
     confirm(not a3.isId)
     confirm(doc.getElementById("v") is None)
     # renaming an attribute should not affect its ID-ness:
-    doc.renameNode(a2, xmlcore.dom.EMPTY_NAMESPACE, "an")
+    doc.renameNode(a2, xml.dom.EMPTY_NAMESPACE, "an")
     confirm(e.isSameNode(doc.getElementById("w"))
             and a2.isId)
 

Modified: python/branches/bcannon-sandboxing/Lib/test/test_multibytecodec.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_multibytecodec.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_multibytecodec.py	Wed Aug  2 00:51:44 2006
@@ -6,17 +6,37 @@
 
 from test import test_support
 from test import test_multibytecodec_support
-import unittest, StringIO, codecs, sys
+from test.test_support import TESTFN
+import unittest, StringIO, codecs, sys, os
+
+ALL_CJKENCODINGS = [
+# _codecs_cn
+    'gb2312', 'gbk', 'gb18030', 'hz',
+# _codecs_hk
+    'big5hkscs',
+# _codecs_jp
+    'cp932', 'shift_jis', 'euc_jp', 'euc_jisx0213', 'shift_jisx0213',
+    'euc_jis_2004', 'shift_jis_2004',
+# _codecs_kr
+    'cp949', 'euc_kr', 'johab',
+# _codecs_tw
+    'big5', 'cp950',
+# _codecs_iso2022
+    'iso2022_jp', 'iso2022_jp_1', 'iso2022_jp_2', 'iso2022_jp_2004',
+    'iso2022_jp_3', 'iso2022_jp_ext', 'iso2022_kr',
+]
 
 class Test_MultibyteCodec(unittest.TestCase):
 
     def test_nullcoding(self):
-        self.assertEqual(''.decode('gb18030'), u'')
-        self.assertEqual(unicode('', 'gb18030'), u'')
-        self.assertEqual(u''.encode('gb18030'), '')
+        for enc in ALL_CJKENCODINGS:
+            self.assertEqual(''.decode(enc), u'')
+            self.assertEqual(unicode('', enc), u'')
+            self.assertEqual(u''.encode(enc), '')
 
     def test_str_decode(self):
-        self.assertEqual('abcd'.encode('gb18030'), 'abcd')
+        for enc in ALL_CJKENCODINGS:
+            self.assertEqual('abcd'.encode(enc), 'abcd')
 
     def test_errorcallback_longindex(self):
         dec = codecs.getdecoder('euc-kr')
@@ -25,6 +45,14 @@
         self.assertRaises(IndexError, dec,
                           'apple\x92ham\x93spam', 'test.cjktest')
 
+    def test_codingspec(self):
+        try:
+            for enc in ALL_CJKENCODINGS:
+                print >> open(TESTFN, 'w'), '# coding:', enc
+                exec open(TESTFN)
+        finally:
+            os.unlink(TESTFN)
+
 class Test_IncrementalEncoder(unittest.TestCase):
 
     def test_stateless(self):

Modified: python/branches/bcannon-sandboxing/Lib/test/test_optparse.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_optparse.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_optparse.py	Wed Aug  2 00:51:44 2006
@@ -1460,10 +1460,11 @@
             make_option("--foo", action="append", type="string", dest='foo',
                         help="store FOO in the foo list for later fooing"),
             ]
-        # The parser constructor looks at the COLUMNS envar.  We need to
-        # restore the original value after the parser is constructed, else
-        # that's a permanent change possibly affecting other tests, and
-        # definitely affecting these tests when they're run multiple times.
+
+        # We need to set COLUMNS for the OptionParser constructor, but
+        # we must restore its original value -- otherwise, this test
+        # screws things up for other tests when it's part of the Python
+        # test suite.
         orig_columns = os.environ.get('COLUMNS')
         os.environ['COLUMNS'] = str(columns)
         try:

Modified: python/branches/bcannon-sandboxing/Lib/test/test_ossaudiodev.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_ossaudiodev.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_ossaudiodev.py	Wed Aug  2 00:51:44 2006
@@ -40,6 +40,10 @@
     data = audioop.ulaw2lin(data, 2)
     return (data, rate, 16, nchannels)
 
+# version of assert that still works with -O
+def _assert(expr, message=None):
+    if not expr:
+        raise AssertionError(message or "assertion failed")
 
 def play_sound_file(data, rate, ssize, nchannels):
     try:
@@ -57,9 +61,9 @@
     dsp.fileno()
 
     # Make sure the read-only attributes work.
-    assert dsp.closed is False, "dsp.closed is not False"
-    assert dsp.name == "/dev/dsp"
-    assert dsp.mode == 'w', "bad dsp.mode: %r" % dsp.mode
+    _assert(dsp.closed is False, "dsp.closed is not False")
+    _assert(dsp.name == "/dev/dsp")
+    _assert(dsp.mode == 'w', "bad dsp.mode: %r" % dsp.mode)
 
     # And make sure they're really read-only.
     for attr in ('closed', 'name', 'mode'):
@@ -69,14 +73,23 @@
         except TypeError:
             pass
 
+    # Compute expected running time of sound sample (in seconds).
+    expected_time = float(len(data)) / (ssize/8) / nchannels / rate
+
     # set parameters based on .au file headers
     dsp.setparameters(AFMT_S16_NE, nchannels, rate)
+    print ("playing test sound file (expected running time: %.2f sec)"
+           % expected_time)
     t1 = time.time()
-    print "playing test sound file..."
     dsp.write(data)
     dsp.close()
     t2 = time.time()
-    print "elapsed time: %.1f sec" % (t2-t1)
+    elapsed_time = t2 - t1
+
+    percent_diff = (abs(elapsed_time - expected_time) / expected_time) * 100
+    _assert(percent_diff <= 10.0, \
+            ("elapsed time (%.2f sec) > 10%% off of expected time (%.2f sec)"
+             % (elapsed_time, expected_time)))
 
 def test_setparameters(dsp):
     # Two configurations for testing:
@@ -101,11 +114,11 @@
     # setparameters() should be able to set this configuration in
     # either strict or non-strict mode.
     result = dsp.setparameters(fmt, channels, rate, False)
-    assert result == (fmt, channels, rate), \
-           "setparameters%r: returned %r" % (config + result)
+    _assert(result == (fmt, channels, rate),
+            "setparameters%r: returned %r" % (config, result))
     result = dsp.setparameters(fmt, channels, rate, True)
-    assert result == (fmt, channels, rate), \
-           "setparameters%r: returned %r" % (config + result)
+    _assert(result == (fmt, channels, rate),
+            "setparameters%r: returned %r" % (config, result))
 
 def test_bad_setparameters(dsp):
 
@@ -123,8 +136,8 @@
                   ]:
         (fmt, channels, rate) = config
         result = dsp.setparameters(fmt, channels, rate, False)
-        assert result != config, \
-               "setparameters: unexpectedly got requested configuration"
+        _assert(result != config,
+                "setparameters: unexpectedly got requested configuration")
 
         try:
             result = dsp.setparameters(fmt, channels, rate, True)
@@ -145,6 +158,6 @@
         #test_bad_setparameters(dsp)
     finally:
         dsp.close()
-        assert dsp.closed is True, "dsp.closed is not True"
+        _assert(dsp.closed is True, "dsp.closed is not True")
 
 test()

Modified: python/branches/bcannon-sandboxing/Lib/test/test_runpy.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_runpy.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_runpy.py	Wed Aug  2 00:51:44 2006
@@ -23,8 +23,6 @@
         "run_argv0 = sys.argv[0]\n"
         "if __name__ in sys.modules:\n"
         "    run_name = sys.modules[__name__].__name__\n"
-        "if __module_name__ in sys.modules:\n"
-        "    mod_name = sys.modules[__module_name__].__module_name__\n"
         "# Check nested operation\n"
         "import runpy\n"
         "nested = runpy._run_module_code('x=1\\n', mod_name='<run>',\n"
@@ -34,16 +32,14 @@
 
     def test_run_module_code(self):
         initial = object()
-        run_name = "<Nonsense>"
-        mod_name = "<ModuleNonsense>"
+        name = "<Nonsense>"
         file = "Some other nonsense"
         loader = "Now you're just being silly"
         d1 = dict(initial=initial)
         saved_argv0 = sys.argv[0]
         d2 = _run_module_code(self.test_source,
                               d1,
-                              run_name,
-                              mod_name,
+                              name,
                               file,
                               loader,
                               True)
@@ -51,23 +47,19 @@
         self.failUnless(d2["initial"] is initial)
         self.failUnless(d2["result"] == self.expected_result)
         self.failUnless(d2["nested"]["x"] == 1)
-        self.failUnless(d2["__name__"] is run_name)
-        self.failUnless(d2["run_name"] is run_name)
-        self.failUnless(d2["__module_name__"] is mod_name)
-        self.failUnless(d2["mod_name"] is mod_name)
+        self.failUnless(d2["__name__"] is name)
+        self.failUnless(d2["run_name"] is name)
         self.failUnless(d2["__file__"] is file)
         self.failUnless(d2["run_argv0"] is file)
         self.failUnless(d2["__loader__"] is loader)
         self.failUnless(sys.argv[0] is saved_argv0)
-        self.failUnless(mod_name not in sys.modules)
-        self.failUnless(run_name not in sys.modules)
+        self.failUnless(name not in sys.modules)
 
     def test_run_module_code_defaults(self):
         saved_argv0 = sys.argv[0]
         d = _run_module_code(self.test_source)
         self.failUnless(d["result"] == self.expected_result)
         self.failUnless(d["__name__"] is None)
-        self.failUnless(d["__module_name__"] is None)
         self.failUnless(d["__file__"] is None)
         self.failUnless(d["__loader__"] is None)
         self.failUnless(d["run_argv0"] is saved_argv0)

Modified: python/branches/bcannon-sandboxing/Lib/test/test_sax.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_sax.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_sax.py	Wed Aug  2 00:51:44 2006
@@ -1,17 +1,17 @@
 # regression test for SAX 2.0            -*- coding: iso-8859-1 -*-
 # $Id$
 
-from xmlcore.sax import make_parser, ContentHandler, \
-     SAXException, SAXReaderNotAvailable, SAXParseException
+from xml.sax import make_parser, ContentHandler, \
+                    SAXException, SAXReaderNotAvailable, SAXParseException
 try:
     make_parser()
 except SAXReaderNotAvailable:
     # don't try to test this module if we cannot create a parser
     raise ImportError("no XML parsers available")
-from xmlcore.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \
-     XMLFilterBase
-from xmlcore.sax.expatreader import create_parser
-from xmlcore.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
+from xml.sax.saxutils import XMLGenerator, escape, unescape, quoteattr, \
+                             XMLFilterBase
+from xml.sax.expatreader import create_parser
+from xml.sax.xmlreader import InputSource, AttributesImpl, AttributesNSImpl
 from cStringIO import StringIO
 from test.test_support import verify, verbose, TestFailed, findfile
 import os
@@ -36,17 +36,17 @@
         # Creating parsers several times in a row should succeed.
         # Testing this because there have been failures of this kind
         # before.
-        from xmlcore.sax import make_parser
+        from xml.sax import make_parser
         p = make_parser()
-        from xmlcore.sax import make_parser
+        from xml.sax import make_parser
         p = make_parser()
-        from xmlcore.sax import make_parser
+        from xml.sax import make_parser
         p = make_parser()
-        from xmlcore.sax import make_parser
+        from xml.sax import make_parser
         p = make_parser()
-        from xmlcore.sax import make_parser
+        from xml.sax import make_parser
         p = make_parser()
-        from xmlcore.sax import make_parser
+        from xml.sax import make_parser
         p = make_parser()
     except:
         return 0
@@ -108,7 +108,7 @@
     try:
         # Creating a parser should succeed - it should fall back
         # to the expatreader
-        p = make_parser(['xmlcore.parsers.no_such_parser'])
+        p = make_parser(['xml.parsers.no_such_parser'])
     except:
         return 0
     else:
@@ -671,6 +671,55 @@
            attrs.getQNameByName((ns_uri, "attr")) == "ns:attr"
 
 
+# During the development of Python 2.5, an attempt to move the "xml"
+# package implementation to a new package ("xmlcore") proved painful.
+# The goal of this change was to allow applications to be able to
+# obtain and rely on behavior in the standard library implementation
+# of the XML support without needing to be concerned about the
+# availability of the PyXML implementation.
+#
+# While the existing import hackery in Lib/xml/__init__.py can cause
+# PyXML's _xmlpus package to supplant the "xml" package, that only
+# works because either implementation uses the "xml" package name for
+# imports.
+#
+# The move resulted in a number of problems related to the fact that
+# the import machinery's "package context" is based on the name that's
+# being imported rather than the __name__ of the actual package
+# containment; it wasn't possible for the "xml" package to be replaced
+# by a simple module that indirected imports to the "xmlcore" package.
+#
+# The following two tests exercised bugs that were introduced in that
+# attempt.  Keeping these tests around will help detect problems with
+# other attempts to provide reliable access to the standard library's
+# implementation of the XML support.
+
+def test_sf_1511497():
+    # Bug report: http://www.python.org/sf/1511497
+    import sys
+    old_modules = sys.modules.copy()
+    for modname in sys.modules.keys():
+        if modname.startswith("xml."):
+            del sys.modules[modname]
+    try:
+        import xml.sax.expatreader
+        module = xml.sax.expatreader
+        return module.__name__ == "xml.sax.expatreader"
+    finally:
+        sys.modules.update(old_modules)
+
+def test_sf_1513611():
+    # Bug report: http://www.python.org/sf/1513611
+    sio = StringIO("invalid")
+    parser = make_parser()
+    from xml.sax import SAXParseException
+    try:
+        parser.parse(sio)
+    except SAXParseException:
+        return True
+    else:
+        return False
+
 # ===== Main program
 
 def make_test_output():

Modified: python/branches/bcannon-sandboxing/Lib/test/test_scope.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_scope.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_scope.py	Wed Aug  2 00:51:44 2006
@@ -299,6 +299,17 @@
 else:
     raise TestFailed
 
+# test for bug #1501934: incorrect LOAD/STORE_GLOBAL generation
+global_x = 1
+def f():
+    global_x += 1
+try:
+    f()
+except UnboundLocalError:
+    pass
+else:
+    raise TestFailed, 'scope of global_x not correctly determined'
+
 print "14. complex definitions"
 
 def makeReturner(*lst):

Modified: python/branches/bcannon-sandboxing/Lib/test/test_shutil.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_shutil.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_shutil.py	Wed Aug  2 00:51:44 2006
@@ -74,6 +74,33 @@
             except:
                 pass
 
+
+    def test_copytree_simple(self):
+        src_dir = tempfile.mkdtemp()
+        dst_dir = os.path.join(tempfile.mkdtemp(), 'destination')
+        open(os.path.join(src_dir, 'test.txt'), 'w').write('123')
+        os.mkdir(os.path.join(src_dir, 'test_dir'))
+        open(os.path.join(src_dir, 'test_dir', 'test.txt'), 'w').write('456')
+        #
+        try:
+            shutil.copytree(src_dir, dst_dir)
+            self.assertTrue(os.path.isfile(os.path.join(dst_dir, 'test.txt')))
+            self.assertTrue(os.path.isdir(os.path.join(dst_dir, 'test_dir')))
+            self.assertTrue(os.path.isfile(os.path.join(dst_dir, 'test_dir', 'test.txt')))
+            self.assertEqual(open(os.path.join(dst_dir, 'test.txt')).read(), '123')
+            self.assertEqual(open(os.path.join(dst_dir, 'test_dir', 'test.txt')).read(), '456')
+        finally:
+            try:
+                os.remove(os.path.join(src_dir, 'test.txt'))
+                os.remove(os.path.join(dst_dir, 'test.txt'))
+                os.remove(os.path.join(src_dir, 'test_dir', 'test.txt'))
+                os.remove(os.path.join(dst_dir, 'test_dir', 'test.txt'))
+                os.removedirs(src_dir)
+                os.removedirs(dst_dir)
+            except:
+                pass
+
+
     if hasattr(os, "symlink"):
         def test_dont_copy_file_onto_link_to_itself(self):
             # bug 851123.

Modified: python/branches/bcannon-sandboxing/Lib/test/test_signal.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_signal.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_signal.py	Wed Aug  2 00:51:44 2006
@@ -25,7 +25,11 @@
  ) &
 """ % vars()
 
+a_called = b_called = False
+
 def handlerA(*args):
+    global a_called
+    a_called = True
     if verbose:
         print "handlerA", args
 
@@ -33,11 +37,14 @@
     pass
 
 def handlerB(*args):
+    global b_called
+    b_called = True
     if verbose:
         print "handlerB", args
     raise HandlerBCalled, args
 
-signal.alarm(20)                        # Entire test lasts at most 20 sec.
+MAX_DURATION = 20
+signal.alarm(MAX_DURATION)   # Entire test should last at most 20 sec.
 hup = signal.signal(signal.SIGHUP, handlerA)
 usr1 = signal.signal(signal.SIGUSR1, handlerB)
 usr2 = signal.signal(signal.SIGUSR2, signal.SIG_IGN)
@@ -65,9 +72,34 @@
 except TypeError:
     pass
 
+# Set up a child to send an alarm signal to us (the parent) after waiting
+# long enough to receive the alarm.  It seems we miss the alarm for some
+# reason.  This will hopefully stop the hangs on Tru64/Alpha.
+def force_test_exit():
+    # Sigh, both imports seem necessary to avoid errors.
+    import os
+    fork_pid = os.fork()
+    if fork_pid == 0:
+        # In child
+        import os, time
+        try:
+            # Wait 5 seconds longer than the expected alarm to give enough
+            # time for the normal sequence of events to occur.  This is
+            # just a stop-gap to prevent the test from hanging.
+            time.sleep(MAX_DURATION + 5)
+            for i in range(3):
+                os.kill(pid, signal.SIGALARM)
+        finally:
+            os._exit(0)
+    # In parent (or error)
+    return fork_pid
+
 try:
     os.system(script)
 
+    # Try to ensure this test exits even if there is some problem with alarm.
+    # Tru64/Alpha sometimes hangs and is ultimately killed by the buildbot.
+    fork_pid = force_test_exit()
     print "starting pause() loop..."
 
     try:
@@ -88,6 +120,22 @@
         if verbose:
             print "KeyboardInterrupt (assume the alarm() went off)"
 
+    # Forcibly kill the child we created to ping us if there was a test error.
+    try:
+        # Make sure we don't kill ourself if there was a fork error.
+        if fork_pid > 0:
+            os.kill(fork_pid, signal.SIGKILL)
+    except:
+        # If the child killed us, it has probably exited.  Killing a
+        # non-existant process will raise an error which we don't care about.
+        pass
+
+    if not a_called:
+        print 'HandlerA not called'
+
+    if not b_called:
+        print 'HandlerB not called'
+
 finally:
     signal.signal(signal.SIGHUP, hup)
     signal.signal(signal.SIGUSR1, usr1)

Modified: python/branches/bcannon-sandboxing/Lib/test/test_subprocess.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_subprocess.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_subprocess.py	Wed Aug  2 00:51:44 2006
@@ -30,12 +30,14 @@
     def setUp(self):
         # Try to minimize the number of children we have so this test
         # doesn't crash on some buildbots (Alphas in particular).
-        test_support.reap_children()
+        if hasattr(test_support, "reap_children"):
+            test_support.reap_children()
 
     def tearDown(self):
         # Try to minimize the number of children we have so this test
         # doesn't crash on some buildbots (Alphas in particular).
-        test_support.reap_children()
+        if hasattr(test_support, "reap_children"):
+            test_support.reap_children()
 
     def mkstemp(self):
         """wrapper for mkstemp, calling mktemp if mkstemp is not available"""
@@ -66,7 +68,7 @@
             subprocess.check_call([sys.executable, "-c",
                                    "import sys; sys.exit(47)"])
         except subprocess.CalledProcessError, e:
-            self.assertEqual(e.errno, 47)
+            self.assertEqual(e.returncode, 47)
         else:
             self.fail("Expected CalledProcessError")
 
@@ -474,10 +476,36 @@
             else:
                 self.fail("Expected OSError")
 
+        def _suppress_core_files(self):
+            """Try to prevent core files from being created.
+            Returns previous ulimit if successful, else None.
+            """
+            try:
+                import resource
+                old_limit = resource.getrlimit(resource.RLIMIT_CORE)
+                resource.setrlimit(resource.RLIMIT_CORE, (0,0))
+                return old_limit
+            except (ImportError, ValueError, resource.error):
+                return None
+
+        def _unsuppress_core_files(self, old_limit):
+            """Return core file behavior to default."""
+            if old_limit is None:
+                return
+            try:
+                import resource
+                resource.setrlimit(resource.RLIMIT_CORE, old_limit)
+            except (ImportError, ValueError, resource.error):
+                return
+            
         def test_run_abort(self):
             # returncode handles signal termination
-            p = subprocess.Popen([sys.executable,
-                                  "-c", "import os; os.abort()"])
+            old_limit = self._suppress_core_files()
+            try:
+                p = subprocess.Popen([sys.executable,
+                                      "-c", "import os; os.abort()"])
+            finally:
+                self._unsuppress_core_files(old_limit)
             p.wait()
             self.assertEqual(-p.returncode, signal.SIGABRT)
 
@@ -610,7 +638,8 @@
 
 def test_main():
     test_support.run_unittest(ProcessTestCase)
-    test_support.reap_children()
+    if hasattr(test_support, "reap_children"):
+        test_support.reap_children()
 
 if __name__ == "__main__":
     test_main()

Modified: python/branches/bcannon-sandboxing/Lib/test/test_sys.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_sys.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_sys.py	Wed Aug  2 00:51:44 2006
@@ -237,6 +237,90 @@
             is sys._getframe().f_code
         )
 
+    # sys._current_frames() is a CPython-only gimmick.
+    def test_current_frames(self):
+        have_threads = True
+        try:
+            import thread
+        except ImportError:
+            have_threads = False
+
+        if have_threads:
+            self.current_frames_with_threads()
+        else:
+            self.current_frames_without_threads()
+
+    # Test sys._current_frames() in a WITH_THREADS build.
+    def current_frames_with_threads(self):
+        import threading, thread
+        import traceback
+
+        # Spawn a thread that blocks at a known place.  Then the main
+        # thread does sys._current_frames(), and verifies that the frames
+        # returned make sense.
+        entered_g = threading.Event()
+        leave_g = threading.Event()
+        thread_info = []  # the thread's id
+
+        def f123():
+            g456()
+
+        def g456():
+            thread_info.append(thread.get_ident())
+            entered_g.set()
+            leave_g.wait()
+
+        t = threading.Thread(target=f123)
+        t.start()
+        entered_g.wait()
+
+        # At this point, t has finished its entered_g.set(), although it's
+        # impossible to guess whether it's still on that line or has moved on
+        # to its leave_g.wait().
+        self.assertEqual(len(thread_info), 1)
+        thread_id = thread_info[0]
+
+        d = sys._current_frames()
+
+        main_id = thread.get_ident()
+        self.assert_(main_id in d)
+        self.assert_(thread_id in d)
+
+        # Verify that the captured main-thread frame is _this_ frame.
+        frame = d.pop(main_id)
+        self.assert_(frame is sys._getframe())
+
+        # Verify that the captured thread frame is blocked in g456, called
+        # from f123.  This is a litte tricky, since various bits of
+        # threading.py are also in the thread's call stack.
+        frame = d.pop(thread_id)
+        stack = traceback.extract_stack(frame)
+        for i, (filename, lineno, funcname, sourceline) in enumerate(stack):
+            if funcname == "f123":
+                break
+        else:
+            self.fail("didn't find f123() on thread's call stack")
+
+        self.assertEqual(sourceline, "g456()")
+
+        # And the next record must be for g456().
+        filename, lineno, funcname, sourceline = stack[i+1]
+        self.assertEqual(funcname, "g456")
+        self.assert_(sourceline in ["leave_g.wait()", "entered_g.set()"])
+
+        # Reap the spawned thread.
+        leave_g.set()
+        t.join()
+
+    # Test sys._current_frames() when thread support doesn't exist.
+    def current_frames_without_threads(self):
+        # Not much happens here:  there is only one thread, with artificial
+        # "thread id" 0.
+        d = sys._current_frames()
+        self.assertEqual(len(d), 1)
+        self.assert_(0 in d)
+        self.assert_(d[0] is sys._getframe())
+
     def test_attributes(self):
         self.assert_(isinstance(sys.api_version, int))
         self.assert_(isinstance(sys.argv, list))

Modified: python/branches/bcannon-sandboxing/Lib/test/test_time.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_time.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_time.py	Wed Aug  2 00:51:44 2006
@@ -39,9 +39,9 @@
 
     def test_strftime_bounds_checking(self):
         # Make sure that strftime() checks the bounds of the various parts
-        #of the time tuple.
+        #of the time tuple (0 is valid for *all* values).
 
-        # Check year
+        # Check year [1900, max(int)]
         self.assertRaises(ValueError, time.strftime, '',
                             (1899, 1, 1, 0, 0, 0, 0, 1, -1))
         if time.accept2dyear:
@@ -49,27 +49,27 @@
                                 (-1, 1, 1, 0, 0, 0, 0, 1, -1))
             self.assertRaises(ValueError, time.strftime, '',
                                 (100, 1, 1, 0, 0, 0, 0, 1, -1))
-        # Check month
+        # Check month [1, 12] + zero support
         self.assertRaises(ValueError, time.strftime, '',
-                            (1900, 0, 1, 0, 0, 0, 0, 1, -1))
+                            (1900, -1, 1, 0, 0, 0, 0, 1, -1))
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 13, 1, 0, 0, 0, 0, 1, -1))
-        # Check day of month
+        # Check day of month [1, 31] + zero support
         self.assertRaises(ValueError, time.strftime, '',
-                            (1900, 1, 0, 0, 0, 0, 0, 1, -1))
+                            (1900, 1, -1, 0, 0, 0, 0, 1, -1))
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 1, 32, 0, 0, 0, 0, 1, -1))
-        # Check hour
+        # Check hour [0, 23]
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 1, 1, -1, 0, 0, 0, 1, -1))
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 1, 1, 24, 0, 0, 0, 1, -1))
-        # Check minute
+        # Check minute [0, 59]
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 1, 1, 0, -1, 0, 0, 1, -1))
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 1, 1, 0, 60, 0, 0, 1, -1))
-        # Check second
+        # Check second [0, 61]
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 1, 1, 0, 0, -1, 0, 1, -1))
         # C99 only requires allowing for one leap second, but Python's docs say
@@ -82,17 +82,25 @@
         #  modulo.
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 1, 1, 0, 0, 0, -2, 1, -1))
-        # Check day of the year
+        # Check day of the year [1, 366] + zero support
         self.assertRaises(ValueError, time.strftime, '',
-                            (1900, 1, 1, 0, 0, 0, 0, 0, -1))
+                            (1900, 1, 1, 0, 0, 0, 0, -1, -1))
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 1, 1, 0, 0, 0, 0, 367, -1))
-        # Check daylight savings flag
+        # Check daylight savings flag [-1, 1]
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 1, 1, 0, 0, 0, 0, 1, -2))
         self.assertRaises(ValueError, time.strftime, '',
                             (1900, 1, 1, 0, 0, 0, 0, 1, 2))
 
+    def test_default_values_for_zero(self):
+        # Make sure that using all zeros uses the proper default values.
+        # No test for daylight savings since strftime() does not change output
+        # based on its value.
+        expected = "2000 01 01 00 00 00 1 001"
+        result = time.strftime("%Y %m %d %H %M %S %w %j", (0,)*9)
+        self.assertEquals(expected, result)
+
     def test_strptime(self):
         tt = time.gmtime(self.t)
         for directive in ('a', 'A', 'b', 'B', 'c', 'd', 'H', 'I',

Modified: python/branches/bcannon-sandboxing/Lib/test/test_traceback.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_traceback.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_traceback.py	Wed Aug  2 00:51:44 2006
@@ -31,8 +31,9 @@
         err = self.get_exception_format(self.syntax_error_with_caret,
                                         SyntaxError)
         self.assert_(len(err) == 4)
-        self.assert_("^" in err[2]) # third line has caret
         self.assert_(err[1].strip() == "return x!")
+        self.assert_("^" in err[2]) # third line has caret
+        self.assert_(err[1].find("!") == err[2].find("^")) # in the right place
 
     def test_nocaret(self):
         if is_jython:
@@ -47,8 +48,9 @@
         err = self.get_exception_format(self.syntax_error_bad_indentation,
                                         IndentationError)
         self.assert_(len(err) == 4)
-        self.assert_("^" in err[2])
         self.assert_(err[1].strip() == "print 2")
+        self.assert_("^" in err[2])
+        self.assert_(err[1].find("2") == err[2].find("^"))
 
     def test_bug737473(self):
         import sys, os, tempfile, time
@@ -109,6 +111,36 @@
         lst = traceback.format_exception_only(e.__class__, e)
         self.assertEqual(lst, ['KeyboardInterrupt\n'])
 
+    # String exceptions are deprecated, but legal.  The quirky form with
+    # separate "type" and "value" tends to break things, because
+    #     not isinstance(value, type)
+    # and a string cannot be the first argument to issubclass.
+    #
+    # Note that sys.last_type and sys.last_value do not get set if an
+    # exception is caught, so we sort of cheat and just emulate them.
+    #
+    # test_string_exception1 is equivalent to
+    #
+    # >>> raise "String Exception"
+    #
+    # test_string_exception2 is equivalent to
+    #
+    # >>> raise "String Exception", "String Value"
+    #
+    def test_string_exception1(self):
+        str_type = "String Exception"
+        err = traceback.format_exception_only(str_type, None)
+        self.assert_(len(err) == 1)
+        self.assert_(err[0] == str_type + '\n')
+
+    def test_string_exception2(self):
+        str_type = "String Exception"
+        str_value = "String Value"
+        err = traceback.format_exception_only(str_type, str_value)
+        self.assert_(len(err) == 1)
+        self.assert_(err[0] == str_type + ': ' + str_value + '\n')
+
+
 def test_main():
     run_unittest(TracebackCases)
 

Modified: python/branches/bcannon-sandboxing/Lib/test/test_urllib2.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_urllib2.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_urllib2.py	Wed Aug  2 00:51:44 2006
@@ -676,11 +676,11 @@
             r = MockResponse(200, "OK", {}, "")
             newreq = h.do_request_(req)
             if data is None:  # GET
-                self.assert_("Content-length" not in req.unredirected_hdrs)
-                self.assert_("Content-type" not in req.unredirected_hdrs)
+                self.assert_("Content-Length" not in req.unredirected_hdrs)
+                self.assert_("Content-Type" not in req.unredirected_hdrs)
             else:  # POST
-                self.assertEqual(req.unredirected_hdrs["Content-length"], "0")
-                self.assertEqual(req.unredirected_hdrs["Content-type"],
+                self.assertEqual(req.unredirected_hdrs["Content-Length"], "0")
+                self.assertEqual(req.unredirected_hdrs["Content-Type"],
                              "application/x-www-form-urlencoded")
             # XXX the details of Host could be better tested
             self.assertEqual(req.unredirected_hdrs["Host"], "example.com")
@@ -692,8 +692,8 @@
             req.add_unredirected_header("Host", "baz")
             req.add_unredirected_header("Spam", "foo")
             newreq = h.do_request_(req)
-            self.assertEqual(req.unredirected_hdrs["Content-length"], "foo")
-            self.assertEqual(req.unredirected_hdrs["Content-type"], "bar")
+            self.assertEqual(req.unredirected_hdrs["Content-Length"], "foo")
+            self.assertEqual(req.unredirected_hdrs["Content-Type"], "bar")
             self.assertEqual(req.unredirected_hdrs["Host"], "baz")
             self.assertEqual(req.unredirected_hdrs["Spam"], "foo")
 
@@ -847,7 +847,7 @@
             407, 'Proxy-Authenticate: Basic realm="%s"\r\n\r\n' % realm)
         opener.add_handler(auth_handler)
         opener.add_handler(http_handler)
-        self._test_basic_auth(opener, auth_handler, "Proxy-authorization",
+        self._test_basic_auth(opener, auth_handler, "Proxy-Authorization",
                               realm, http_handler, password_manager,
                               "http://acme.example.com:3128/protected",
                               "proxy.example.com:3128",

Modified: python/branches/bcannon-sandboxing/Lib/test/test_uuid.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_uuid.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_uuid.py	Wed Aug  2 00:51:44 2006
@@ -1,4 +1,5 @@
-from unittest import TestCase, main
+from unittest import TestCase
+from test import test_support
 import uuid
 
 def importable(name):
@@ -10,6 +11,7 @@
 
 class TestUUID(TestCase):
     last_node = None
+    source2node = {}
 
     def test_UUID(self):
         equal = self.assertEqual
@@ -265,7 +267,7 @@
         badtype(lambda: setattr(u, 'fields', f))
         badtype(lambda: setattr(u, 'int', i))
 
-    def check_node(self, node, source=''):
+    def check_node(self, node, source):
         individual_group_bit = (node >> 40L) & 1
         universal_local_bit = (node >> 40L) & 2
         message = "%012x doesn't look like a real MAC address" % node
@@ -274,25 +276,41 @@
         self.assertNotEqual(node, 0, message)
         self.assertNotEqual(node, 0xffffffffffffL, message)
         self.assert_(0 <= node, message)
-        self.assert_(node < 1<<48L, message)
+        self.assert_(node < (1L << 48), message)
 
-        import sys
-        if source:
-            sys.stderr.write('(%s: %012x)' % (source, node))
+        TestUUID.source2node[source] = node
         if TestUUID.last_node:
-            self.assertEqual(TestUUID.last_node, node, 'inconsistent node IDs')
+            if TestUUID.last_node != node:
+                msg = "different sources disagree on node:\n"
+                for s, n in TestUUID.source2node.iteritems():
+                    msg += "    from source %r, node was %012x\n" % (s, n)
+                # There's actually no reason to expect the MAC addresses
+                # to agree across various methods -- e.g., a box may have
+                # multiple network interfaces, and different ways of getting
+                # a MAC address may favor different HW.
+                ##self.fail(msg)
         else:
             TestUUID.last_node = node
 
     def test_ifconfig_getnode(self):
+        import sys
+        print >>sys.__stdout__, \
+"""    WARNING: uuid._ifconfig_getnode is unreliable on many platforms.
+        It is disabled until the code and/or test can be fixed properly."""
+        return
+
         import os
         if os.name == 'posix':
-            self.check_node(uuid._ifconfig_getnode(), 'ifconfig')
+            node = uuid._ifconfig_getnode()
+            if node is not None:
+                self.check_node(node, 'ifconfig')
 
     def test_ipconfig_getnode(self):
         import os
         if os.name == 'nt':
-            self.check_node(uuid._ipconfig_getnode(), 'ipconfig')
+            node = uuid._ipconfig_getnode()
+            if node is not None:
+                self.check_node(node, 'ipconfig')
 
     def test_netbios_getnode(self):
         if importable('win32wnet') and importable('netbios'):
@@ -301,9 +319,15 @@
     def test_random_getnode(self):
         node = uuid._random_getnode()
         self.assert_(0 <= node)
-        self.assert_(node < 1<<48L)
+        self.assert_(node < (1L <<48))
 
     def test_unixdll_getnode(self):
+        import sys
+        print >>sys.__stdout__, \
+"""    WARNING: uuid._unixdll_getnode is unreliable on many platforms.
+        It is disabled until the code and/or test can be fixed properly."""
+        return
+
         import os
         if importable('ctypes') and os.name == 'posix':
             self.check_node(uuid._unixdll_getnode(), 'unixdll')
@@ -314,10 +338,20 @@
             self.check_node(uuid._windll_getnode(), 'windll')
 
     def test_getnode(self):
-        self.check_node(uuid.getnode())
+        import sys
+        print >>sys.__stdout__, \
+"""    WARNING: uuid.getnode is unreliable on many platforms.
+        It is disabled until the code and/or test can be fixed properly."""
+        return
+
+        node1 = uuid.getnode()
+        self.check_node(node1, "getnode1")
 
         # Test it again to ensure consistency.
-        self.check_node(uuid.getnode())
+        node2 = uuid.getnode()
+        self.check_node(node2, "getnode2")
+
+        self.assertEqual(node1, node2)
 
     def test_uuid1(self):
         equal = self.assertEqual
@@ -392,5 +426,9 @@
             equal(u, uuid.UUID(v))
             equal(str(u), v)
 
+
+def test_main():
+    test_support.run_unittest(TestUUID)
+
 if __name__ == '__main__':
-    main()
+    test_main()

Modified: python/branches/bcannon-sandboxing/Lib/test/test_wait3.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_wait3.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_wait3.py	Wed Aug  2 00:51:44 2006
@@ -2,6 +2,7 @@
 """
 
 import os
+import time
 from test.fork_wait import ForkWait
 from test.test_support import TestSkipped, run_unittest, reap_children
 
@@ -17,10 +18,14 @@
 
 class Wait3Test(ForkWait):
     def wait_impl(self, cpid):
-        while 1:
-            spid, status, rusage = os.wait3(0)
+        for i in range(10):
+            # wait3() shouldn't hang, but some of the buildbots seem to hang
+            # in the forking tests.  This is an attempt to fix the problem.
+            spid, status, rusage = os.wait3(os.WNOHANG)
             if spid == cpid:
                 break
+            time.sleep(1.0)
+
         self.assertEqual(spid, cpid)
         self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
         self.assertTrue(rusage)

Modified: python/branches/bcannon-sandboxing/Lib/test/test_wait4.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_wait4.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_wait4.py	Wed Aug  2 00:51:44 2006
@@ -2,6 +2,7 @@
 """
 
 import os
+import time
 from test.fork_wait import ForkWait
 from test.test_support import TestSkipped, run_unittest, reap_children
 
@@ -17,7 +18,13 @@
 
 class Wait4Test(ForkWait):
     def wait_impl(self, cpid):
-        spid, status, rusage = os.wait4(cpid, 0)
+        for i in range(10):
+            # wait4() shouldn't hang, but some of the buildbots seem to hang
+            # in the forking tests.  This is an attempt to fix the problem.
+            spid, status, rusage = os.wait4(cpid, os.WNOHANG)
+            if spid == cpid:
+                break
+            time.sleep(1.0)
         self.assertEqual(spid, cpid)
         self.assertEqual(status, 0, "cause = %d, exit = %d" % (status&0xff, status>>8))
         self.assertTrue(rusage)

Modified: python/branches/bcannon-sandboxing/Lib/test/test_winreg.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_winreg.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_winreg.py	Wed Aug  2 00:51:44 2006
@@ -151,3 +151,6 @@
 else:
     print "Remote registry calls can be tested using",
     print "'test_winreg.py --remote \\\\machine_name'"
+    # perform minimal ConnectRegistry test which just invokes it
+    h = ConnectRegistry(None, HKEY_LOCAL_MACHINE)
+    h.Close()

Modified: python/branches/bcannon-sandboxing/Lib/test/test_xml_etree.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_xml_etree.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_xml_etree.py	Wed Aug  2 00:51:44 2006
@@ -1,4 +1,4 @@
-# xmlcore.etree test.  This file contains enough tests to make sure that
+# xml.etree test.  This file contains enough tests to make sure that
 # all included components work as they should.  For a more extensive
 # test suite, see the selftest script in the ElementTree distribution.
 
@@ -6,8 +6,6 @@
 
 from test import test_support
 
-from xmlcore.etree import ElementTree as ET
-
 SAMPLE_XML = """
 <body>
   <tag>text</tag>
@@ -32,9 +30,9 @@
     """
     Import sanity.
 
-    >>> from xmlcore.etree import ElementTree
-    >>> from xmlcore.etree import ElementInclude
-    >>> from xmlcore.etree import ElementPath
+    >>> from xml.etree import ElementTree
+    >>> from xml.etree import ElementInclude
+    >>> from xml.etree import ElementPath
     """
 
 def check_method(method):
@@ -61,6 +59,8 @@
     """
     Test element tree interface.
 
+    >>> from xml.etree import ElementTree as ET
+
     >>> element = ET.Element("tag", key="value")
     >>> tree = ET.ElementTree(element)
 
@@ -108,6 +108,8 @@
     """
     Test find methods (including xpath syntax).
 
+    >>> from xml.etree import ElementTree as ET
+
     >>> elem = ET.XML(SAMPLE_XML)
     >>> elem.find("tag").tag
     'tag'
@@ -174,6 +176,8 @@
 def parseliteral():
     r"""
 
+    >>> from xml.etree import ElementTree as ET
+
     >>> element = ET.XML("<html><body>text</body></html>")
     >>> ET.ElementTree(element).write(sys.stdout)
     <html><body>text</body></html>
@@ -195,18 +199,20 @@
     'body'
     """
 
-def check_encoding(encoding):
+
+def check_encoding(ET, encoding):
     """
-    >>> check_encoding("ascii")
-    >>> check_encoding("us-ascii")
-    >>> check_encoding("iso-8859-1")
-    >>> check_encoding("iso-8859-15")
-    >>> check_encoding("cp437")
-    >>> check_encoding("mac-roman")
+    >>> from xml.etree import ElementTree as ET
+
+    >>> check_encoding(ET, "ascii")
+    >>> check_encoding(ET, "us-ascii")
+    >>> check_encoding(ET, "iso-8859-1")
+    >>> check_encoding(ET, "iso-8859-15")
+    >>> check_encoding(ET, "cp437")
+    >>> check_encoding(ET, "mac-roman")
     """
-    ET.XML(
-        "<?xml version='1.0' encoding='%s'?><xml />" % encoding
-        )
+    ET.XML("<?xml version='1.0' encoding='%s'?><xml />" % encoding)
+
 
 #
 # xinclude tests (samples from appendix C of the xinclude specification)
@@ -282,14 +288,16 @@
     except KeyError:
         raise IOError("resource not found")
     if parse == "xml":
-        return ET.XML(data)
+        from xml.etree.ElementTree import XML
+        return XML(data)
     return data
 
 def xinclude():
     r"""
     Basic inclusion example (XInclude C.1)
 
-    >>> from xmlcore.etree import ElementInclude
+    >>> from xml.etree import ElementTree as ET
+    >>> from xml.etree import ElementInclude
 
     >>> document = xinclude_loader("C1.xml")
     >>> ElementInclude.include(document, xinclude_loader)

Modified: python/branches/bcannon-sandboxing/Lib/test/test_xml_etree_c.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/test/test_xml_etree_c.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/test/test_xml_etree_c.py	Wed Aug  2 00:51:44 2006
@@ -1,10 +1,10 @@
-# xmlcore.etree test for cElementTree
+# xml.etree test for cElementTree
 
 import doctest, sys
 
 from test import test_support
 
-from xmlcore.etree import cElementTree as ET
+from xml.etree import cElementTree as ET
 
 SAMPLE_XML = """
 <body>
@@ -30,7 +30,7 @@
     """
     Import sanity.
 
-    >>> from xmlcore.etree import cElementTree
+    >>> from xml.etree import cElementTree
     """
 
 def check_method(method):

Modified: python/branches/bcannon-sandboxing/Lib/traceback.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/traceback.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/traceback.py	Wed Aug  2 00:51:44 2006
@@ -150,50 +150,63 @@
 
     The arguments are the exception type and value such as given by
     sys.last_type and sys.last_value. The return value is a list of
-    strings, each ending in a newline.  Normally, the list contains a
-    single string; however, for SyntaxError exceptions, it contains
-    several lines that (when printed) display detailed information
-    about where the syntax error occurred.  The message indicating
-    which exception occurred is the always last string in the list.
+    strings, each ending in a newline.
+
+    Normally, the list contains a single string; however, for
+    SyntaxError exceptions, it contains several lines that (when
+    printed) display detailed information about where the syntax
+    error occurred.
+
+    The message indicating which exception occurred is always the last
+    string in the list.
+
     """
-    list = []
-    if (type(etype) == types.ClassType
-        or (isinstance(etype, type) and issubclass(etype, BaseException))):
-        stype = etype.__name__
+
+    # An instance should not have a meaningful value parameter, but
+    # sometimes does, particularly for string exceptions, such as
+    # >>> raise string1, string2  # deprecated
+    #
+    # Clear these out first because issubtype(string1, SyntaxError)
+    # would throw another exception and mask the original problem.
+    if (isinstance(etype, BaseException) or
+        isinstance(etype, types.InstanceType) or
+        type(etype) is str):
+        return [_format_final_exc_line(etype, value)]
+
+    stype = etype.__name__
+
+    if not issubclass(etype, SyntaxError):
+        return [_format_final_exc_line(stype, value)]
+
+    # It was a syntax error; show exactly where the problem was found.
+    lines = []
+    try:
+        msg, (filename, lineno, offset, badline) = value
+    except Exception:
+        pass
     else:
-        stype = etype
-    if value is None:
-        list.append(str(stype) + '\n')
+        filename = filename or "<string>"
+        lines.append('  File "%s", line %d\n' % (filename, lineno))
+        if badline is not None:
+            lines.append('    %s\n' % badline.strip())
+            if offset is not None:
+                caretspace = badline[:offset].lstrip()
+                # non-space whitespace (likes tabs) must be kept for alignment
+                caretspace = ((c.isspace() and c or ' ') for c in caretspace)
+                # only three spaces to account for offset1 == pos 0
+                lines.append('   %s^\n' % ''.join(caretspace))
+            value = msg
+
+    lines.append(_format_final_exc_line(stype, value))
+    return lines
+
+def _format_final_exc_line(etype, value):
+    """Return a list of a single line -- normal case for format_exception_only"""
+    if value is None or not str(value):
+        line = "%s\n" % etype
     else:
-        if issubclass(etype, SyntaxError):
-            try:
-                msg, (filename, lineno, offset, line) = value
-            except:
-                pass
-            else:
-                if not filename: filename = "<string>"
-                list.append('  File "%s", line %d\n' %
-                            (filename, lineno))
-                if line is not None:
-                    i = 0
-                    while i < len(line) and line[i].isspace():
-                        i = i+1
-                    list.append('    %s\n' % line.strip())
-                    if offset is not None:
-                        s = '    '
-                        for c in line[i:offset-1]:
-                            if c.isspace():
-                                s = s + c
-                            else:
-                                s = s + ' '
-                        list.append('%s^\n' % s)
-                    value = msg
-        s = _some_str(value)
-        if s:
-            list.append('%s: %s\n' % (str(stype), s))
-        else:
-            list.append('%s\n' % str(stype))
-    return list
+        line = "%s: %s\n" % (etype, _some_str(value))
+    return line
 
 def _some_str(value):
     try:

Modified: python/branches/bcannon-sandboxing/Lib/types.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/types.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/types.py	Wed Aug  2 00:51:44 2006
@@ -86,4 +86,16 @@
 DictProxyType = type(TypeType.__dict__)
 NotImplementedType = type(NotImplemented)
 
-del sys, _f, _g, _C, _x                  # Not for export
+# Extension types defined in a C helper module.  XXX There may be no
+# equivalent in implementations other than CPython, so it seems better to
+# leave them undefined then to set them to e.g. None.
+try:
+    import _types
+except ImportError:
+    pass
+else:
+    GetSetDescriptorType = type(_types.Helper.getter)
+    MemberDescriptorType = type(_types.Helper.member)
+    del _types
+
+del sys, _f, _g, _C, _x                           # Not for export

Modified: python/branches/bcannon-sandboxing/Lib/urllib.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/urllib.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/urllib.py	Wed Aug  2 00:51:44 2006
@@ -118,7 +118,7 @@
         self.proxies = proxies
         self.key_file = x509.get('key_file')
         self.cert_file = x509.get('cert_file')
-        self.addheaders = [('User-agent', self.version)]
+        self.addheaders = [('User-Agent', self.version)]
         self.__tempfiles = []
         self.__unlink = os.unlink # See cleanup()
         self.tempcache = None
@@ -314,8 +314,8 @@
         h = httplib.HTTP(host)
         if data is not None:
             h.putrequest('POST', selector)
-            h.putheader('Content-type', 'application/x-www-form-urlencoded')
-            h.putheader('Content-length', '%d' % len(data))
+            h.putheader('Content-Type', 'application/x-www-form-urlencoded')
+            h.putheader('Content-Length', '%d' % len(data))
         else:
             h.putrequest('GET', selector)
         if proxy_auth: h.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth)
@@ -400,9 +400,9 @@
                               cert_file=self.cert_file)
             if data is not None:
                 h.putrequest('POST', selector)
-                h.putheader('Content-type',
+                h.putheader('Content-Type',
                             'application/x-www-form-urlencoded')
-                h.putheader('Content-length', '%d' % len(data))
+                h.putheader('Content-Length', '%d' % len(data))
             else:
                 h.putrequest('GET', selector)
             if proxy_auth: h.putheader('Proxy-Authorization: Basic %s' % proxy_auth)
@@ -584,7 +584,7 @@
             data = base64.decodestring(data)
         else:
             data = unquote(data)
-        msg.append('Content-length: %d' % len(data))
+        msg.append('Content-Length: %d' % len(data))
         msg.append('')
         msg.append(data)
         msg = '\n'.join(msg)

Modified: python/branches/bcannon-sandboxing/Lib/urllib2.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/urllib2.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/urllib2.py	Wed Aug  2 00:51:44 2006
@@ -263,11 +263,11 @@
 
     def add_header(self, key, val):
         # useful for something like authentication
-        self.headers[key.capitalize()] = val
+        self.headers[key.title()] = val
 
     def add_unredirected_header(self, key, val):
         # will not be added to a redirected request
-        self.unredirected_hdrs[key.capitalize()] = val
+        self.unredirected_hdrs[key.title()] = val
 
     def has_header(self, header_name):
         return (header_name in self.headers or
@@ -286,7 +286,7 @@
 class OpenerDirector:
     def __init__(self):
         client_version = "Python-urllib/%s" % __version__
-        self.addheaders = [('User-agent', client_version)]
+        self.addheaders = [('User-Agent', client_version)]
         # manage the individual handlers
         self.handlers = []
         self.handle_open = {}
@@ -675,7 +675,7 @@
         if user and password:
             user_pass = '%s:%s' % (unquote(user), unquote(password))
             creds = base64.encodestring(user_pass).strip()
-            req.add_header('Proxy-authorization', 'Basic ' + creds)
+            req.add_header('Proxy-Authorization', 'Basic ' + creds)
         hostport = unquote(hostport)
         req.set_proxy(hostport, proxy_type)
         if orig_type == proxy_type:
@@ -819,7 +819,7 @@
 
 class ProxyBasicAuthHandler(AbstractBasicAuthHandler, BaseHandler):
 
-    auth_header = 'Proxy-authorization'
+    auth_header = 'Proxy-Authorization'
 
     def http_error_407(self, req, fp, code, msg, headers):
         # http_error_auth_reqed requires that there is no userinfo component in
@@ -1022,20 +1022,20 @@
 
         if request.has_data():  # POST
             data = request.get_data()
-            if not request.has_header('Content-type'):
+            if not request.has_header('Content-Type'):
                 request.add_unredirected_header(
-                    'Content-type',
+                    'Content-Type',
                     'application/x-www-form-urlencoded')
-            if not request.has_header('Content-length'):
+            if not request.has_header('Content-Length'):
                 request.add_unredirected_header(
-                    'Content-length', '%d' % len(data))
+                    'Content-Length', '%d' % len(data))
 
         scheme, sel = splittype(request.get_selector())
         sel_host, sel_path = splithost(sel)
         if not request.has_header('Host'):
             request.add_unredirected_header('Host', sel_host or host)
         for name, value in self.parent.addheaders:
-            name = name.capitalize()
+            name = name.title()
             if not request.has_header(name):
                 request.add_unredirected_header(name, value)
 
@@ -1217,7 +1217,7 @@
         modified = email.Utils.formatdate(stats.st_mtime, usegmt=True)
         mtype = mimetypes.guess_type(file)[0]
         headers = mimetools.Message(StringIO(
-            'Content-type: %s\nContent-length: %d\nLast-modified: %s\n' %
+            'Content-Type: %s\nContent-Length: %d\nLast-Modified: %s\n' %
             (mtype or 'text/plain', size, modified)))
         if host:
             host, port = splitport(host)
@@ -1272,9 +1272,9 @@
             headers = ""
             mtype = mimetypes.guess_type(req.get_full_url())[0]
             if mtype:
-                headers += "Content-type: %s\n" % mtype
+                headers += "Content-Type: %s\n" % mtype
             if retrlen is not None and retrlen >= 0:
-                headers += "Content-length: %d\n" % retrlen
+                headers += "Content-Length: %d\n" % retrlen
             sf = StringIO(headers)
             headers = mimetools.Message(sf)
             return addinfourl(fp, headers, req.get_full_url())

Modified: python/branches/bcannon-sandboxing/Lib/uuid.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/uuid.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/uuid.py	Wed Aug  2 00:51:44 2006
@@ -271,19 +271,51 @@
 
     version = property(get_version)
 
-def _ifconfig_getnode():
-    """Get the hardware address on Unix by running ifconfig."""
+def _find_mac(command, args, hw_identifiers, get_index):
     import os
     for dir in ['', '/sbin/', '/usr/sbin']:
+        executable = os.path.join(dir, command)
+        if not os.path.exists(executable):
+            continue
+
         try:
-            pipe = os.popen(os.path.join(dir, 'ifconfig'))
+            # LC_ALL to get English output, 2>/dev/null to
+            # prevent output on stderr
+            cmd = 'LC_ALL=C %s %s 2>/dev/null' % (executable, args)
+            pipe = os.popen(cmd)
         except IOError:
             continue
+
         for line in pipe:
             words = line.lower().split()
             for i in range(len(words)):
-                if words[i] in ['hwaddr', 'ether']:
-                    return int(words[i + 1].replace(':', ''), 16)
+                if words[i] in hw_identifiers:
+                    return int(words[get_index(i)].replace(':', ''), 16)
+    return None
+
+def _ifconfig_getnode():
+    """Get the hardware address on Unix by running ifconfig."""
+
+    # This works on Linux ('' or '-a'), Tru64 ('-av'), but not all Unixes.
+    for args in ('', '-a', '-av'):
+        mac = _find_mac('ifconfig', args, ['hwaddr', 'ether'], lambda i: i+1)
+        if mac:
+            return mac
+
+    import socket
+    ip_addr = socket.gethostbyname(socket.gethostname())
+
+    # Try getting the MAC addr from arp based on our IP address (Solaris).
+    mac = _find_mac('arp', '-an', [ip_addr], lambda i: -1)
+    if mac:
+        return mac
+
+    # This might work on HP-UX.
+    mac = _find_mac('lanscan', '-ai', ['lan0'], lambda i: 0)
+    if mac:
+        return mac
+
+    return None
 
 def _ipconfig_getnode():
     """Get the hardware address on Windows by running ipconfig.exe."""
@@ -359,6 +391,10 @@
     # hardware address.  On Windows 2000 and later, UuidCreate makes a
     # random UUID and UuidCreateSequential gives a UUID containing the
     # hardware address.  These routines are provided by the RPC runtime.
+    # NOTE:  at least on Tim's WinXP Pro SP2 desktop box, while the last
+    # 6 bytes returned by UuidCreateSequential are fixed, they don't appear
+    # to bear any relationship to the MAC address of any network device
+    # on the box.
     try:
         lib = ctypes.windll.rpcrt4
     except:
@@ -386,10 +422,13 @@
 _node = None
 
 def getnode():
-    """Get the hardware address as a 48-bit integer.  The first time this
-    runs, it may launch a separate program, which could be quite slow.  If
-    all attempts to obtain the hardware address fail, we choose a random
-    48-bit number with its eighth bit set to 1 as recommended in RFC 4122."""
+    """Get the hardware address as a 48-bit positive integer.
+
+    The first time this runs, it may launch a separate program, which could
+    be quite slow.  If all attempts to obtain the hardware address fail, we
+    choose a random 48-bit number with its eighth bit set to 1 as recommended
+    in RFC 4122.
+    """
 
     global _node
     if _node is not None:

Modified: python/branches/bcannon-sandboxing/Lib/warnings.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/warnings.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/warnings.py	Wed Aug  2 00:51:44 2006
@@ -261,3 +261,4 @@
 # Module initialization
 _processoptions(sys.warnoptions)
 simplefilter("ignore", category=PendingDeprecationWarning, append=1)
+simplefilter("ignore", category=ImportWarning, append=1)

Deleted: /python/branches/bcannon-sandboxing/Lib/xml.py
==============================================================================
--- /python/branches/bcannon-sandboxing/Lib/xml.py	Wed Aug  2 00:51:44 2006
+++ (empty file)
@@ -1,47 +0,0 @@
-"""Core XML support for Python.
-
-This package contains four sub-packages:
-
-dom -- The W3C Document Object Model.  This supports DOM Level 1 +
-       Namespaces.
-
-parsers -- Python wrappers for XML parsers (currently only supports Expat).
-
-sax -- The Simple API for XML, developed by XML-Dev, led by David
-       Megginson and ported to Python by Lars Marius Garshol.  This
-       supports the SAX 2 API.
-
-etree -- The ElementTree XML library.  This is a subset of the full
-       ElementTree XML release.
-
-"""
-
-import sys
-import xmlcore
-
-__all__ = ["dom", "parsers", "sax", "etree"]
-
-# When being checked-out without options, this has the form
-# "<dollar>Revision: x.y </dollar>"
-# When exported using -kv, it is "x.y".
-__version__ = "$Revision$".split()[-2:][0]
-
-
-_MINIMUM_XMLPLUS_VERSION = (0, 8, 4)
-
-try:
-    import _xmlplus
-except ImportError:
-    sys.modules[__name__] = xmlcore
-else:
-    try:
-        v = _xmlplus.version_info
-    except AttributeError:
-        # _xmlplus is too old; ignore it
-        pass
-    else:
-        if v >= _MINIMUM_XMLPLUS_VERSION:
-            _xmlplus.__path__.extend(xmlcore.__path__)
-            sys.modules[__name__] = _xmlplus
-        else:
-            del v

Modified: python/branches/bcannon-sandboxing/Lib/zipfile.py
==============================================================================
--- python/branches/bcannon-sandboxing/Lib/zipfile.py	(original)
+++ python/branches/bcannon-sandboxing/Lib/zipfile.py	Wed Aug  2 00:51:44 2006
@@ -664,7 +664,7 @@
 
                 if zinfo.header_offset > ZIP64_LIMIT:
                     extra.append(zinfo.header_offset)
-                    header_offset = 0xffffffff #-1
+                    header_offset = -1  # struct "l" format:  32 one bits
                 else:
                     header_offset = zinfo.header_offset
 
@@ -708,9 +708,10 @@
                         stringEndArchive64Locator, 0, pos2, 1)
                 self.fp.write(zip64locrec)
 
+                # XXX Why is `pos3` computed next?  It's never referenced.
                 pos3 = self.fp.tell()
                 endrec = struct.pack(structEndArchive, stringEndArchive,
-                         0, 0, count, count, pos2 - pos1, 0xffffffff, 0) # -1, 0)
+                            0, 0, count, count, pos2 - pos1, -1, 0)
                 self.fp.write(endrec)
 
             else:

Modified: python/branches/bcannon-sandboxing/Mac/BuildScript/scripts/postflight.patch-profile
==============================================================================
--- python/branches/bcannon-sandboxing/Mac/BuildScript/scripts/postflight.patch-profile	(original)
+++ python/branches/bcannon-sandboxing/Mac/BuildScript/scripts/postflight.patch-profile	Wed Aug  2 00:51:44 2006
@@ -5,14 +5,27 @@
 echo "These changes will be effective only in shell windows that you open"
 echo "after running this script."
 
-PYVER=@PYVER@
+PYVER=2.5
 PYTHON_ROOT="/Library/Frameworks/Python.framework/Versions/Current"
 
+if [ `id -ur` = 0 ]; then
+	# Run from the installer, do some trickery to fetch the information
+	# we need.
+	theShell="`finger $USER | grep Shell: | head  -1 | awk '{ print $NF }'`"
+
+else
+	theShell="${SHELL}"
+fi
+
 # Make sure the directory ${PYTHON_ROOT}/bin is on the users PATH.
-BSH="`basename "${SHELL}"`"
+BSH="`basename "${theShell}"`"
 case "${BSH}" in
 bash|ksh|sh|*csh)
-	P="`${SHELL} -c 'echo $PATH'`"
+	if [ `id -ur` = 0 ]; then
+		P=`su - ${USER} -c 'echo A-X-4-X@@$PATH@@X-4-X-A' | grep 'A-X-4-X@@.*@@X-4-X-A' | sed -e 's/^A-X-4-X@@//g' -e 's/@@X-4-X-A$//g'`
+	else
+		P="`(exec -l ${theShell} -c 'echo $PATH')`"
+	fi
 	;;
 *)
 	echo "Sorry, I don't know how to patch $BSH shells"
@@ -42,10 +55,15 @@
 	echo "# Setting PATH for MacPython ${PYVER}" >> "${HOME}/.cshrc"
 	echo "# The orginal version is saved in .cshrc.pysave" >> "${HOME}/.cshrc"
 	echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${HOME}/.cshrc"
+	if [ `id -ur` = 0 ]; then
+		chown "${USER}" "${HOME}/.cshrc"
+	fi
 	exit 0
 	;;
 bash)
-	if [ -e "${HOME}/.profile" ]; then
+	if [ -e "${HOME}/.bash_profile" ]; then
+		PR="${HOME}/.bash_profile"
+	elif [ -e "${HOME}/.profile" ]; then
 		PR="${HOME}/.profile"
 	else
 		PR="${HOME}/.bash_profile"
@@ -66,6 +84,6 @@
 echo 'PATH="'"${PYTHON_ROOT}/bin"':${PATH}"' >> "${PR}"
 echo 'export PATH' >> "${PR}"
 if [ `id -ur` = 0 ]; then
-	chown "${LOGNAME}" "${PR}"
+	chown "${USER}" "${PR}"
 fi
 exit 0

Modified: python/branches/bcannon-sandboxing/Mac/IDLE/config-main.def
==============================================================================
--- python/branches/bcannon-sandboxing/Mac/IDLE/config-main.def	(original)
+++ python/branches/bcannon-sandboxing/Mac/IDLE/config-main.def	Wed Aug  2 00:51:44 2006
@@ -71,7 +71,7 @@
 
 [Keys]
 default= 1
-name= IDLE Classic Mac
+name= IDLE Classic OSX
 
 [History]
 cyclic=1

Deleted: /python/branches/bcannon-sandboxing/Mac/Modules/macosmodule.c
==============================================================================
--- /python/branches/bcannon-sandboxing/Mac/Modules/macosmodule.c	Wed Aug  2 00:51:44 2006
+++ (empty file)
@@ -1,643 +0,0 @@
-/***********************************************************
-Copyright 1991-1997 by Stichting Mathematisch Centrum, Amsterdam,
-The Netherlands.
-
-                        All Rights Reserved
-
-Permission to use, copy, modify, and distribute this software and its 
-documentation for any purpose and without fee is hereby granted, 
-provided that the above copyright notice appear in all copies and that
-both that copyright notice and this permission notice appear in 
-supporting documentation, and that the names of Stichting Mathematisch
-Centrum or CWI not be used in advertising or publicity pertaining to
-distribution of the software without specific, written prior permission.
-
-STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO
-THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
-FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE
-FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
-OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-
-******************************************************************/
-
-/* Macintosh OS-specific interface */
-
-#include "Python.h"
-#include "pymactoolbox.h"
-
-#include <Carbon/Carbon.h>
-#include <ApplicationServices/ApplicationServices.h>
-
-static PyObject *MacOS_Error; /* Exception MacOS.Error */
-
-#define PATHNAMELEN 1024
-
-/* ----------------------------------------------------- */
-
-/* Declarations for objects of type Resource fork */
-
-typedef struct {
-	PyObject_HEAD
-	short fRefNum;
-	int isclosed;
-} rfobject;
-
-static PyTypeObject Rftype;
-
-
-
-/* ---------------------------------------------------------------- */
-
-static void
-do_close(rfobject *self)
-{
-	if (self->isclosed ) return;
-	(void)FSClose(self->fRefNum);
-	self->isclosed = 1;
-}
-
-static char rf_read__doc__[] = 
-"Read data from resource fork"
-;
-
-static PyObject *
-rf_read(rfobject *self, PyObject *args)
-{
-	long n;
-	PyObject *v;
-	OSErr err;
-	
-	if (self->isclosed) {
-		PyErr_SetString(PyExc_ValueError, "Operation on closed file");
-		return NULL;
-	}
-	
-	if (!PyArg_ParseTuple(args, "l", &n))
-		return NULL;
-		
-	v = PyString_FromStringAndSize((char *)NULL, n);
-	if (v == NULL)
-		return NULL;
-		
-	err = FSRead(self->fRefNum, &n, PyString_AsString(v));
-	if (err && err != eofErr) {
-		PyMac_Error(err);
-		Py_DECREF(v);
-		return NULL;
-	}
-	_PyString_Resize(&v, n);
-	return v;
-}
-
-
-static char rf_write__doc__[] = 
-"Write to resource fork"
-;
-
-static PyObject *
-rf_write(rfobject *self, PyObject *args)
-{
-	char *buffer;
-	long size;
-	OSErr err;
-	
-	if (self->isclosed) {
-		PyErr_SetString(PyExc_ValueError, "Operation on closed file");
-		return NULL;
-	}
-	if (!PyArg_ParseTuple(args, "s#", &buffer, &size))
-		return NULL;
-	err = FSWrite(self->fRefNum, &size, buffer);
-	if (err) {
-		PyMac_Error(err);
-		return NULL;
-	}
-	Py_INCREF(Py_None);
-	return Py_None;
-}
-
-
-static char rf_seek__doc__[] = 
-"Set file position"
-;
-
-static PyObject *
-rf_seek(rfobject *self, PyObject *args)
-{
-	long amount, pos;
-	int whence = SEEK_SET;
-	long eof;
-	OSErr err;
-	
-	if (self->isclosed) {
-		PyErr_SetString(PyExc_ValueError, "Operation on closed file");
-		return NULL;
-	}
-	if (!PyArg_ParseTuple(args, "l|i", &amount, &whence))
-		return NULL;
-	
-	if ((err = GetEOF(self->fRefNum, &eof)))
-		goto ioerr;
-	
-	switch (whence) {
-	case SEEK_CUR:
-		if ((err = GetFPos(self->fRefNum, &pos)))
-			goto ioerr; 
-		break;
-	case SEEK_END:
-		pos = eof;
-		break;
-	case SEEK_SET:
-		pos = 0;
-		break;
-	default:
-		PyErr_BadArgument();
-		return NULL;
-	}
-	
-	pos += amount;
-	
-	/* Don't bother implementing seek past EOF */
-	if (pos > eof || pos < 0) {
-		PyErr_BadArgument();
-		return NULL;
-	}
-	
-	if ((err = SetFPos(self->fRefNum, fsFromStart, pos)) ) {
-ioerr:
-		PyMac_Error(err);
-		return NULL;
-	}
-	Py_INCREF(Py_None);
-	return Py_None;
-}
-
-
-static char rf_tell__doc__[] = 
-"Get file position"
-;
-
-static PyObject *
-rf_tell(rfobject *self, PyObject *args)
-{
-	long where;
-	OSErr err;
-	
-	if (self->isclosed) {
-		PyErr_SetString(PyExc_ValueError, "Operation on closed file");
-		return NULL;
-	}
-	if (!PyArg_ParseTuple(args, ""))
-		return NULL;
-	if ((err = GetFPos(self->fRefNum, &where)) ) {
-		PyMac_Error(err);
-		return NULL;
-	}
-	return PyInt_FromLong(where);
-}
-
-static char rf_close__doc__[] = 
-"Close resource fork"
-;
-
-static PyObject *
-rf_close(rfobject *self, PyObject *args)
-{
-	if (!PyArg_ParseTuple(args, ""))
-		return NULL;
-	do_close(self);
-	Py_INCREF(Py_None);
-	return Py_None;
-}
-
-
-static struct PyMethodDef rf_methods[] = {
- {"read",	(PyCFunction)rf_read,	1,	rf_read__doc__},
- {"write",	(PyCFunction)rf_write,	1,	rf_write__doc__},
- {"seek",	(PyCFunction)rf_seek,	1,	rf_seek__doc__},
- {"tell",	(PyCFunction)rf_tell,	1,	rf_tell__doc__},
- {"close",	(PyCFunction)rf_close,	1,	rf_close__doc__},
- 
-	{NULL,		NULL}		/* sentinel */
-};
-
-/* ---------- */
-
-
-static rfobject *
-newrfobject(void)
-{
-	rfobject *self;
-	
-	self = PyObject_NEW(rfobject, &Rftype);
-	if (self == NULL)
-		return NULL;
-	self->isclosed = 1;
-	return self;
-}
-
-
-static void
-rf_dealloc(rfobject *self)
-{
-	do_close(self);
-	PyObject_DEL(self);
-}
-
-static PyObject *
-rf_getattr(rfobject *self, char *name)
-{
-	return Py_FindMethod(rf_methods, (PyObject *)self, name);
-}
-
-static char Rftype__doc__[] = 
-"Resource fork file object"
-;
-
-static PyTypeObject Rftype = {
-	PyObject_HEAD_INIT(&PyType_Type)
-	0,				/*ob_size*/
-	"MacOS.ResourceFork",		/*tp_name*/
-	sizeof(rfobject),		/*tp_basicsize*/
-	0,				/*tp_itemsize*/
-	/* methods */
-	(destructor)rf_dealloc,	/*tp_dealloc*/
-	(printfunc)0,		/*tp_print*/
-	(getattrfunc)rf_getattr,	/*tp_getattr*/
-	(setattrfunc)0,	/*tp_setattr*/
-	(cmpfunc)0,		/*tp_compare*/
-	(reprfunc)0,		/*tp_repr*/
-	0,			/*tp_as_number*/
-	0,		/*tp_as_sequence*/
-	0,		/*tp_as_mapping*/
-	(hashfunc)0,		/*tp_hash*/
-	(ternaryfunc)0,		/*tp_call*/
-	(reprfunc)0,		/*tp_str*/
-
-	/* Space for future expansion */
-	0L,0L,0L,0L,
-	Rftype__doc__ /* Documentation string */
-};
-
-/* End of code for Resource fork objects */
-/* -------------------------------------------------------- */
-
-/*----------------------------------------------------------------------*/
-/* Miscellaneous File System Operations */
-
-static char getcrtp_doc[] = "Get MacOS 4-char creator and type for a file";
-
-static PyObject *
-MacOS_GetCreatorAndType(PyObject *self, PyObject *args)
-{
-	FSSpec fss;
-	FInfo info;
-	PyObject *creator, *type, *res;
-	OSErr err;
-	
-	if (!PyArg_ParseTuple(args, "O&", PyMac_GetFSSpec, &fss))
-		return NULL;
-	if ((err = FSpGetFInfo(&fss, &info)) != noErr)
-		return PyErr_Mac(MacOS_Error, err);
-	creator = PyString_FromStringAndSize((char *)&info.fdCreator, 4);
-	type = PyString_FromStringAndSize((char *)&info.fdType, 4);
-	res = Py_BuildValue("OO", creator, type);
-	Py_DECREF(creator);
-	Py_DECREF(type);
-	return res;
-}
-
-static char setcrtp_doc[] = "Set MacOS 4-char creator and type for a file";
-
-static PyObject *
-MacOS_SetCreatorAndType(PyObject *self, PyObject *args)
-{
-	FSSpec fss;
-	ResType creator, type;
-	FInfo info;
-	OSErr err;
-	
-	if (!PyArg_ParseTuple(args, "O&O&O&",
-			PyMac_GetFSSpec, &fss, PyMac_GetOSType, &creator, PyMac_GetOSType, &type))
-		return NULL;
-	if ((err = FSpGetFInfo(&fss, &info)) != noErr)
-		return PyErr_Mac(MacOS_Error, err);
-	info.fdCreator = creator;
-	info.fdType = type;
-	if ((err = FSpSetFInfo(&fss, &info)) != noErr)
-		return PyErr_Mac(MacOS_Error, err);
-	Py_INCREF(Py_None);
-	return Py_None;
-}
-
-
-static char geterr_doc[] = "Convert OSErr number to string";
-
-static PyObject *
-MacOS_GetErrorString(PyObject *self, PyObject *args)
-{
-	int err;
-	char buf[256];
-	Handle h;
-	char *str;
-	static int errors_loaded;
-	
-	if (!PyArg_ParseTuple(args, "i", &err))
-		return NULL;
-
-	h = GetResource('Estr', err);
-	if (!h && !errors_loaded) {
-		/*
-		** Attempt to open the resource file containing the
-		** Estr resources. We ignore all errors. We also try
-		** this only once.
-		*/
-		PyObject *m, *rv;
-		errors_loaded = 1;
-		
-		m = PyImport_ImportModule("macresource");
-		if (!m) {
-			if (Py_VerboseFlag)
-				PyErr_Print();
-			PyErr_Clear();
-		}
-		else {
-			rv = PyObject_CallMethod(m, "open_error_resource", "");
-			if (!rv) {
-				if (Py_VerboseFlag)
-					PyErr_Print();
-				PyErr_Clear();
-			}
-			else {
-				Py_DECREF(rv);
-				/* And try again... */
-				h = GetResource('Estr', err);
-			}
-		}
-	}
-	/*
-	** Whether the code above succeeded or not, we won't try
-	** again.
-	*/
-	errors_loaded = 1;
-		
-	if (h) {
-		HLock(h);
-		str = (char *)*h;
-		memcpy(buf, str+1, (unsigned char)str[0]);
-		buf[(unsigned char)str[0]] = '\0';
-		HUnlock(h);
-		ReleaseResource(h);
-	}
-	else {
-		PyOS_snprintf(buf, sizeof(buf), "Mac OS error code %d", err);
-	}
-
-	return Py_BuildValue("s", buf);
-}
-
-static char splash_doc[] = "Open a splash-screen dialog by resource-id (0=close)";
-
-static PyObject *
-MacOS_splash(PyObject *self, PyObject *args)
-{
-	int resid = -1;
-	static DialogPtr curdialog = NULL;
-	DialogPtr olddialog;
-	WindowRef theWindow;
-	CGrafPtr thePort;
-#if 0
-	short xpos, ypos, width, height, swidth, sheight;
-#endif
-	
-	if (!PyArg_ParseTuple(args, "|i", &resid))
-		return NULL;
-	olddialog = curdialog;
-	curdialog = NULL;
-		
-	if ( resid != -1 ) {
-		curdialog = GetNewDialog(resid, NULL, (WindowPtr)-1);
-		if ( curdialog ) {
-			theWindow = GetDialogWindow(curdialog);
-			thePort = GetWindowPort(theWindow);
-#if 0
-			width = thePort->portRect.right - thePort->portRect.left;
-			height = thePort->portRect.bottom - thePort->portRect.top;
-			swidth = qd.screenBits.bounds.right - qd.screenBits.bounds.left;
-			sheight = qd.screenBits.bounds.bottom - qd.screenBits.bounds.top - LMGetMBarHeight();
-			xpos = (swidth-width)/2;
-			ypos = (sheight-height)/5 + LMGetMBarHeight();
-			MoveWindow(theWindow, xpos, ypos, 0);
-			ShowWindow(theWindow);
-#endif
-			DrawDialog(curdialog);
-		}
-	}
-	if (olddialog)
-		DisposeDialog(olddialog);
-	Py_INCREF(Py_None);
-	return Py_None;
-}
-
-static char DebugStr_doc[] = "Switch to low-level debugger with a message";
-
-static PyObject *
-MacOS_DebugStr(PyObject *self, PyObject *args)
-{
-	Str255 message;
-	PyObject *object = 0;
-	
-	if (!PyArg_ParseTuple(args, "O&|O", PyMac_GetStr255, message, &object))
-		return NULL;
-	DebugStr(message);
-	Py_INCREF(Py_None);
-	return Py_None;
-}
-
-static char SysBeep_doc[] = "BEEEEEP!!!";
-
-static PyObject *
-MacOS_SysBeep(PyObject *self, PyObject *args)
-{
-	int duration = 6;
-	
-	if (!PyArg_ParseTuple(args, "|i", &duration))
-		return NULL;
-	SysBeep(duration);
-	Py_INCREF(Py_None);
-	return Py_None;
-}
-
-static char WMAvailable_doc[] = 
-	"True if this process can interact with the display."
-	"Will foreground the application on the first call as a side-effect."
-	;
-
-static PyObject *
-MacOS_WMAvailable(PyObject *self, PyObject *args)
-{
-	static PyObject *rv = NULL;
-	
-	if (!PyArg_ParseTuple(args, ""))
-		return NULL;
-	if (!rv) {
-		ProcessSerialNumber psn;
-		
-		/*
-		** This is a fairly innocuous call to make if we don't have a window
-		** manager, or if we have no permission to talk to it. It will print
-		** a message on stderr, but at least it won't abort the process.
-		** It appears the function caches the result itself, and it's cheap, so
-		** no need for us to cache.
-		*/
-#ifdef kCGNullDirectDisplay
-		/* On 10.1 CGMainDisplayID() isn't available, and
-		** kCGNullDirectDisplay isn't defined.
-		*/
-		if (CGMainDisplayID() == 0) {
-			rv = Py_False;
-		} else {
-#else
-		{
-#endif
-			if (GetCurrentProcess(&psn) < 0 ||
-				SetFrontProcess(&psn) < 0) {
-				rv = Py_False;
-			} else {
-				rv = Py_True;
-			}
-		}
-	}
-	Py_INCREF(rv);
-	return rv;
-}
-
-static char GetTicks_doc[] = "Return number of ticks since bootup";
-
-static PyObject *
-MacOS_GetTicks(PyObject *self, PyObject *args)
-{
-	return Py_BuildValue("i", (int)TickCount());
-}
-
-static char openrf_doc[] = "Open resource fork of a file";
-
-static PyObject *
-MacOS_openrf(PyObject *self, PyObject *args)
-{
-	OSErr err;
-	char *mode = "r";
-	FSSpec fss;
-	SignedByte permission = 1;
-	rfobject *fp;
-		
-	if (!PyArg_ParseTuple(args, "O&|s", PyMac_GetFSSpec, &fss, &mode))
-		return NULL;
-	while (*mode) {
-		switch (*mode++) {
-		case '*': break;
-		case 'r': permission = 1; break;
-		case 'w': permission = 2; break;
-		case 'b': break;
-		default:
-			PyErr_BadArgument();
-			return NULL;
-		}
-	}
-	
-	if ( (fp = newrfobject()) == NULL )
-		return NULL;
-		
-	err = HOpenRF(fss.vRefNum, fss.parID, fss.name, permission, &fp->fRefNum);
-	
-	if ( err == fnfErr ) {
-		/* In stead of doing complicated things here to get creator/type
-		** correct we let the standard i/o library handle it
-		*/
-		FILE *tfp;
-		char pathname[PATHNAMELEN];
-		
-		if ( (err=PyMac_GetFullPathname(&fss, pathname, PATHNAMELEN)) ) {
-			PyMac_Error(err);
-			Py_DECREF(fp);
-			return NULL;
-		}
-		
-		if ( (tfp = fopen(pathname, "w")) == NULL ) {
-			PyMac_Error(fnfErr); /* What else... */
-			Py_DECREF(fp);
-			return NULL;
-		}
-		fclose(tfp);
-		err = HOpenRF(fss.vRefNum, fss.parID, fss.name, permission, &fp->fRefNum);
-	}
-	if ( err ) {
-		Py_DECREF(fp);
-		PyMac_Error(err);
-		return NULL;
-	}
-	fp->isclosed = 0;
-	return (PyObject *)fp;
-}
-
-
-static PyMethodDef MacOS_Methods[] = {
-	{"GetCreatorAndType",		MacOS_GetCreatorAndType, 1,	getcrtp_doc},
-	{"SetCreatorAndType",		MacOS_SetCreatorAndType, 1,	setcrtp_doc},
-	{"GetErrorString",		MacOS_GetErrorString,	1,	geterr_doc},
-	{"openrf",			MacOS_openrf, 		1, 	openrf_doc},
-	{"splash",			MacOS_splash,		1, 	splash_doc},
-	{"DebugStr",			MacOS_DebugStr,		1,	DebugStr_doc},
-	{"GetTicks",			MacOS_GetTicks,		1,	GetTicks_doc},
-	{"SysBeep",			MacOS_SysBeep,		1,	SysBeep_doc},
-	{"WMAvailable",			MacOS_WMAvailable,		1,	WMAvailable_doc},
-	{NULL,				NULL}		 /* Sentinel */
-};
-
-
-void
-initMacOS(void)
-{
-	PyObject *m, *d;
-	
-	m = Py_InitModule("MacOS", MacOS_Methods);
-	d = PyModule_GetDict(m);
-	
-	/* Initialize MacOS.Error exception */
-	MacOS_Error = PyMac_GetOSErrException();
-	if (MacOS_Error == NULL || PyDict_SetItemString(d, "Error", MacOS_Error) != 0)
-		return;
-	Rftype.ob_type = &PyType_Type;
-	Py_INCREF(&Rftype);
-	if (PyDict_SetItemString(d, "ResourceForkType", (PyObject *)&Rftype) != 0)
-		return;
-	/*
-	** This is a hack: the following constant added to the id() of a string
-	** object gives you the address of the data. Unfortunately, it is needed for
-	** some of the image and sound processing interfaces on the mac:-(
-	*/
-	{
-		PyStringObject *p = 0;
-		long off = (long)&(p->ob_sval[0]);
-		
-		if( PyDict_SetItemString(d, "string_id_to_buffer", Py_BuildValue("i", off)) != 0)
-			return;
-	}
-#define PY_RUNTIMEMODEL "macho"
-	if (PyDict_SetItemString(d, "runtimemodel", 
-				Py_BuildValue("s", PY_RUNTIMEMODEL)) != 0)
-		return;
-#if defined(WITH_NEXT_FRAMEWORK)
-#define PY_LINKMODEL "framework"
-#elif defined(Py_ENABLE_SHARED)
-#define PY_LINKMODEL "shared"
-#else
-#define PY_LINKMODEL "static"
-#endif
-	if (PyDict_SetItemString(d, "linkmodel", 
-				Py_BuildValue("s", PY_LINKMODEL)) != 0)
-		return;
-
-}

Modified: python/branches/bcannon-sandboxing/Mac/PythonLauncher/FileSettings.m
==============================================================================
--- python/branches/bcannon-sandboxing/Mac/PythonLauncher/FileSettings.m	(original)
+++ python/branches/bcannon-sandboxing/Mac/PythonLauncher/FileSettings.m	Wed Aug  2 00:51:44 2006
@@ -245,12 +245,26 @@
     if (value) with_terminal = [value boolValue];
 }
 
+- (NSString*)_replaceSingleQuotes: (NSString*)string
+{
+	/* Replace all single-quotes by '"'"', that way shellquoting will
+	 * be correct when the result value is delimited  using single quotes.
+	 */
+	NSArray* components = [string componentsSeparatedByString:@"'"];
+
+	return [components componentsJoinedByString:@"'\"'\"'"];
+}
+
 - (NSString *)commandLineForScript: (NSString *)script
 {
     NSString *cur_interp = NULL;
+    NSString* script_dir = NULL;
     char hashbangbuf[1024];
     FILE *fp;
     char *p;
+
+    script_dir = [script substringToIndex:
+	    [script length]-[[script lastPathComponent] length]];
     
     if (honourhashbang &&
        (fp=fopen([script cString], "r")) &&
@@ -266,8 +280,9 @@
         cur_interp = interpreter;
         
     return [NSString stringWithFormat:
-        @"\"%@\"%s%s%s%s%s%s %@ \"%@\" %@ %s",
-        cur_interp,
+        @"cd '%@' && '%@'%s%s%s%s%s%s %@ '%@' %@ %s",
+    	[self _replaceSingleQuotes:script_dir],
+        [self _replaceSingleQuotes:cur_interp],
         debug?" -d":"",
         verbose?" -v":"",
         inspect?" -i":"",
@@ -275,7 +290,7 @@
         nosite?" -S":"",
         tabs?" -t":"",
         others,
-        script,
+        [self _replaceSingleQuotes:script],
         scriptargs,
         with_terminal? "&& echo Exit status: $? && exit 1" : " &"];
 }

Modified: python/branches/bcannon-sandboxing/Makefile.pre.in
==============================================================================
--- python/branches/bcannon-sandboxing/Makefile.pre.in	(original)
+++ python/branches/bcannon-sandboxing/Makefile.pre.in	Wed Aug  2 00:51:44 2006
@@ -318,6 +318,7 @@
 ##########################################################################
 # objects that get linked into the Python library
 LIBRARY_OBJS=	\
+		Modules/_typesmodule.o \
 		Modules/getbuildinfo.o \
 		$(PARSER_OBJS) \
 		$(OBJECT_OBJS) \
@@ -354,6 +355,7 @@
 $(LIBRARY): $(LIBRARY_OBJS)
 	-rm -f $@
 	$(AR) cr $@ Modules/getbuildinfo.o
+	$(AR) cr $@ Modules/_typesmodule.o
 	$(AR) cr $@ $(PARSER_OBJS)
 	$(AR) cr $@ $(OBJECT_OBJS)
 	$(AR) cr $@ $(PYTHON_OBJS)
@@ -486,7 +488,7 @@
 
 $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
 	$(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
-	
+
 Python/compile.o Python/symtable.o: $(GRAMMAR_H) $(AST_H)
 
 Python/getplatform.o: $(srcdir)/Python/getplatform.c
@@ -650,6 +652,7 @@
 	else true; \
 	fi
 	(cd $(DESTDIR)$(BINDIR); $(LN) python$(VERSION)$(EXE) $(PYTHON))
+	(cd $(DESTDIR)$(BINDIR); $(LN) -sf python$(VERSION)-config python-config)
 
 # Install the interpreter with $(VERSION) affixed
 # This goes into $(exec_prefix)
@@ -693,7 +696,7 @@
 EXTRAPLATDIR= @EXTRAPLATDIR@
 EXTRAMACHDEPPATH=@EXTRAMACHDEPPATH@
 MACHDEPS=	$(PLATDIR) $(EXTRAPLATDIR)
-XMLLIBSUBDIRS=  xmlcore xmlcore/dom xmlcore/etree xmlcore/parsers xmlcore/sax
+XMLLIBSUBDIRS=  xml xml/dom xml/etree xml/parsers xml/sax
 PLATMACDIRS= plat-mac plat-mac/Carbon plat-mac/lib-scriptpackages \
 	plat-mac/lib-scriptpackages/_builtinSuites \
 	plat-mac/lib-scriptpackages/CodeWarrior \
@@ -850,8 +853,8 @@
 	$(INSTALL_SCRIPT) $(srcdir)/install-sh $(DESTDIR)$(LIBPL)/install-sh
 	# Substitution happens here, as the completely-expanded BINDIR
 	# is not available in configure
-	sed -e "s, at BINDIR@,$(BINDIR)," < $(srcdir)/Misc/python-config.in >python-config
-	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python-config
+	sed -e "s, at EXENAME@,$(BINDIR)/python$(VERSION)$(EXE)," < $(srcdir)/Misc/python-config.in >python-config
+	$(INSTALL_SCRIPT) python-config $(DESTDIR)$(BINDIR)/python$(VERSION)-config
 	rm python-config
 	@if [ -s Modules/python.exp -a \
 		"`echo $(MACHDEP) | sed 's/^\(...\).*/\1/'`" = "aix" ]; then \
@@ -935,7 +938,7 @@
 # Install a number of symlinks to keep software that expects a normal unix
 # install (which includes python-config) happy.
 frameworkinstallmaclib:
-	ln -s "../../../Python" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
+	ln -fs "../../../Python" "$(DESTDIR)$(prefix)/lib/python$(VERSION)/config/libpython$(VERSION).a"
 	cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
 
 # This installs the IDE, the Launcher and other apps into /Applications

Modified: python/branches/bcannon-sandboxing/Misc/ACKS
==============================================================================
--- python/branches/bcannon-sandboxing/Misc/ACKS	(original)
+++ python/branches/bcannon-sandboxing/Misc/ACKS	Wed Aug  2 00:51:44 2006
@@ -203,6 +203,7 @@
 Russell Finn
 Nils Fischbeck
 Frederik Fix
+Matt Fleming
 Hernán Martínez Foffani
 Doug Fort
 John Fouhy
@@ -623,6 +624,7 @@
 John Tromp
 Jason Trowbridge
 Anthony Tuininga
+Christopher Tur Lesniewski-Laas
 Stephen Turner
 Bill Tutt
 Doobee R. Tzeck

Modified: python/branches/bcannon-sandboxing/Misc/NEWS
==============================================================================
--- python/branches/bcannon-sandboxing/Misc/NEWS	(original)
+++ python/branches/bcannon-sandboxing/Misc/NEWS	Wed Aug  2 00:51:44 2006
@@ -4,14 +4,213 @@
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
+What's New in Python 2.5 beta 3?
+================================
+
+*Release date: XX-AUG-2006*
+
+Core and builtins
+-----------------
+
+- Bug #1515471: string.replace() accepts character buffers again.
+
+- Add PyErr_WarnEx() so C code can pass the stacklevel to warnings.warn().
+  This provides the proper warning for struct.pack().
+  PyErr_Warn() is now deprecated in favor of PyErr_WarnEx().
+
+- Patch #1531113: Fix augmented assignment with yield expressions.
+  Also fix a SystemError when trying to assign to yield expressions.
+
+- Bug #1529871: The speed enhancement patch #921466 broke Python's compliance
+  with PEP 302.  This was fixed by adding an ``imp.NullImporter`` type that is
+  used in ``sys.path_importer_cache`` to cache non-directory paths and avoid
+  excessive filesystem operations during imports.
+
+- Bug #1521947: When checking for overflow, ``PyOS_strtol()`` used some
+  operations on signed longs that are formally undefined by C.
+  Unfortunately, at least one compiler now cares about that, so complicated
+  the code to make that compiler happy again.
+
+- Bug #1524310: Properly report errors from FindNextFile in os.listdir.
+
+- Patch #1232023: Stop including current directory in search
+  path on Windows.
+
+- Fix some potential crashes found with failmalloc.
+
+- Fix warnings reported by Klocwork's static analysis tool.
+
+- Bug #1512814, Fix incorrect lineno's when code within a function
+  had more than 255 blank lines.
+
+- Patch #1521179: Python now accepts the standard options ``--help`` and
+  ``--version`` as well as ``/?`` on Windows.
+
+- Bug #1520864: unpacking singleton tuples in a 'for' loop (for x, in) works
+  again.  Fixing this problem required changing the .pyc magic number.
+  This means that .pyc files generated before 2.5c1 will be regenerated.
+
+- Bug #1524317:  Compiling Python ``--without-threads`` failed.
+  The Python core compiles again then, and, in a build without threads, the
+  new ``sys._current_frames()`` returns a dictionary with one entry,
+  mapping the faux "thread id" 0 to the current frame.
+
+- Bug #1525447: build on MacOS X on a case-sensitive filesystem.
+
+
+Library
+-------
+
+- os.urandom no longer masks unrelated exceptions like SystemExit or
+  KeyboardInterrupt.
+
+- Bug #1525866: Don't copy directory stat times in 
+  shutil.copytree on Windows
+
+- Bug #1002398: The documentation for os.path.sameopenfile now correctly
+  refers to file descriptors, not file objects.
+
+- Rename of the xml package to xmlcore, and the import hackery done to
+  make it appear at both names, has been removed.  Bug #1511497,
+  #1513611, and probably others.
+
+- Bug #1441397: The compiler module now recognizes module and function
+  docstrings correctly as it did in Python 2.4.
+
+- Bug #1529297:  The rewrite of doctest for Python 2.4 unintentionally
+  lost that tests are sorted by name before being run.  This rarely
+  matters for well-written tests, but can create baffling symptoms if
+  side effects from one test to the next affect outcomes.  ``DocTestFinder``
+  has been changed to sort the list of tests it returns.
+
+- The distutils version has been changed to 2.5.0, and are now kept
+  in sync with sys.version_info[:3].
+
+- Bug #978833: Really close underlying socket in _socketobject.close.
+
+- Bug #1459963: urllib and urllib2 now normalize HTTP header names correctly
+  with title().
+
+- Patch #1525766: In pkgutil.walk_packages, correctly pass the onerror callback
+  to recursive calls and call it with the failing package name.
+
+- Bug #1525817: Don't truncate short lines in IDLE's tool tips.
+
+- Patch #1515343: Fix printing of deprecated string exceptions with a
+  value in the traceback module.
+
+- Resync optparse with Optik 1.5.3: minor tweaks for/to tests.
+
+- Patch #1524429: Use repr() instead of backticks in Tkinter again.
+
+- Bug #1520914: Change time.strftime() to accept a zero for any position in its
+  argument tuple.  For arguments where zero is illegal, the value is forced to
+  the minimum value that is correct.  This is to support an undocumented but
+  common way people used  to fill in inconsequential information in the time
+  tuple pre-2.4.
+
+- Patch #1220874: Update the binhex module for Mach-O.
+
+- The email package has improved RFC 2231 support, specifically for
+  recognizing the difference between encoded (name*0*=<blah>) and non-encoded
+  (name*0=<blah>) parameter continuations.  This may change the types of
+  values returned from email.message.Message.get_param() and friends.
+  Specifically in some cases where non-encoded continuations were used,
+  get_param() used to return a 3-tuple of (None, None, string) whereas now it
+  will just return the string (since non-encoded continuations don't have
+  charset and language parts).
+
+  Also, whereas % values were decoded in all parameter continuations, they are
+  now only decoded in encoded parameter parts.
+
+- Bug #1517990: IDLE keybindings on MacOS X now work correctly
+
+- Bug #1517996: IDLE now longer shows the default Tk menu when a
+  path browser, class browser or debugger is the frontmost window on MacOS X
+
+- Patch #1520294: Support for getset and member descriptors in types.py,
+  inspect.py, and pydoc.py.  Specifically, this allows for querying the type
+  of an object against these built-in types and more importantly, for getting
+  their docstrings printed in the interactive interpreter's help() function.
+
+
+Extension Modules
+-----------------
+
+- Patch #1529514: The _ctypes extension is now compiled on more
+  openbsd target platforms.
+
+- The ``__reduce__()`` method of the new ``collections.defaultdict`` had
+  a memory leak, affecting pickles and deep copies.
+
+- Bug #1471938: Fix curses module build problem on Solaris 8; patch by
+  Paul Eggert.
+
+- Patch #1448199: Release interpreter lock in _winreg.ConnectRegistry.
+
+- Patch #1521817: Index range checking on ctypes arrays containing
+  exactly one element enabled again.  This allows iterating over these
+  arrays, without the need to check the array size before.
+
+- Bug #1521375: When the code in ctypes.util.find_library was
+  run with root privileges, it could overwrite or delete
+  /dev/null in certain cases; this is now fixed.
+
+- Bug #1467450: On Mac OS X 10.3, RTLD_GLOBAL is now used as the
+  default mode for loading shared libraries in ctypes.
+
+- Because of a misspelled preprocessor symbol, ctypes was always
+  compiled without thread support; this is now fixed.
+
+- pybsddb Bug #1527939: bsddb module DBEnv dbremove and dbrename
+  methods now allow their database parameter to be None as the
+  sleepycat API allows.
+
+- Bug #1526460: Fix socketmodule compile on NetBSD as it has a different
+  bluetooth API compared with Linux and FreeBSD.
+
+Tests
+-----
+
+- Bug #1501330: Change test_ossaudiodev to be much more tolerant in terms of
+  how long the test file should take to play.  Now accepts taking 2.93 secs
+  (exact time) +/- 10% instead of the hard-coded 3.1 sec.
+
+- Patch #1529686: The standard tests ``test_defaultdict``, ``test_iterlen``,
+  ``test_uuid`` and ``test_email_codecs`` didn't actually run any tests when
+  run via ``regrtest.py``. Now they do.
+
+Build
+-----
+
+- Bug #1439538: Drop usage of test -e in configure as it is not portable.
+
+Mac
+---
+
+- PythonLauncher now works correctly when the path to the script contains
+  characters that are treated specially by the shell (such as quotes).
+
+- Bug #1527397: PythonLauncher now launches scripts with the working directory
+  set to the directory that contains the script instead of the user home
+  directory. That latter was an implementation accident and not what users 
+  expect.
+
+
 What's New in Python 2.5 beta 2?
 ================================
 
-*Release date: XX-JUL-2006*
+*Release date: 11-JUL-2006*
 
 Core and builtins
 -----------------
 
+- Bug #1441486: The literal representation of -(sys.maxint - 1)
+  again evaluates to a int object, not a long.
+
+- Bug #1501934: The scope of global variables that are locally assigned
+  using augmented assignment is now correctly determined.
+
 - Bug #927248: Recursive method-wrapper objects can now safely
   be released.
 
@@ -22,9 +221,37 @@
   omit a default "error" argument for NULL pointer.  This allows
   the parser to take a codec from cjkcodecs again.
 
+- Bug #1519018: 'as' is now validated properly in import statements.
+
+- On 64 bit systems, int literals that use less than 64 bits are
+  now ints rather than longs.
+
+- Bug #1512814, Fix incorrect lineno's when code at module scope
+  started after line 256.
+
+- New function ``sys._current_frames()`` returns a dict mapping thread
+  id to topmost thread stack frame.  This is for expert use, and is
+  especially useful for debugging application deadlocks.  The functionality
+  was previously available in Fazal Majid's ``threadframe`` extension
+  module, but it wasn't possible to do this in a wholly threadsafe way from
+  an extension.
+
 Library
 -------
 
+- Bug #1257728: Mention Cygwin in distutils error message about a missing
+  VS 2003.
+
+- Patch #1519566: Update turtle demo, make begin_fill idempotent.
+
+- Bug #1508010: msvccompiler now requires the DISTUTILS_USE_SDK
+  environment variable to be set in order to the SDK environment
+  for finding the compiler, include files, etc.
+
+- Bug #1515998: Properly generate logical ids for files in bdist_msi.
+
+- warnings.py now ignores ImportWarning by default
+
 - string.Template() now correctly handles tuple-values. Previously,
   multi-value tuples would raise an exception and single-value tuples would
   be treated as the value they contain, instead.
@@ -47,9 +274,6 @@
 - Bug #1513223: .close() of a _socketobj now releases the underlying
   socket again, which then gets closed as it becomes unreferenced.
 
-- The '_ctypes' extension module now works when Python is configured
-  with the --without-threads option.
-
 - Bug #1504333: Make sgmllib support angle brackets in quoted
   attribute values.
 
@@ -77,15 +301,52 @@
 Extension Modules
 -----------------
 
+- #1494314: Fix a regression with high-numbered sockets in 2.4.3. This
+  means that select() on sockets > FD_SETSIZE (typically 1024) work again.
+  The patch makes sockets use poll() internally where available.
+
+- Assigning None to pointer type fields in ctypes structures possible
+  overwrote the wrong fields, this is fixed now.
+
+- Fixed a segfault in _ctypes when ctypes.wintypes were imported
+  on non-Windows platforms.
+
+- Bug #1518190: The ctypes.c_void_p constructor now accepts any
+  integer or long, without range checking.
+
+- Patch #1517790: It is now possible to use custom objects in the ctypes
+  foreign function argtypes sequence as long as they provide a from_param
+  method, no longer is it required that the object is a ctypes type.
+
+- The '_ctypes' extension module now works when Python is configured
+  with the --without-threads option.
+
 - Bug #1513646: os.access on Windows now correctly determines write
   access, again.
 
 - Bug #1512695: cPickle.loads could crash if it was interrupted with
   a KeyboardInterrupt.
 
+- Bug #1296433: parsing XML with a non-default encoding and
+  a CharacterDataHandler could crash the interpreter in pyexpat.
+
+- Patch #1516912: improve Modules support for OpenVMS.
+
 Build
 -----
 
+- Automate Windows build process for the Win64 SSL module.
+
+- 'configure' now detects the zlib library the same way as distutils.
+  Previously, the slight difference could cause compilation errors of the
+  'zlib' module on systems with more than one version of zlib.
+
+- The MSI compileall step was fixed to also support a TARGETDIR
+  with spaces in it.
+
+- Bug #1517388: sqlite3.dll is now installed on Windows independent
+  of Tcl/Tk.
+
 - Bug #1513032: 'make install' failed on FreeBSD 5.3 due to lib-old
   trying to be installed even though it's empty.
 
@@ -98,8 +359,12 @@
 Documentation
 -------------
 
+- Cover ImportWarning, PendingDeprecationWarning and simplefilter() in the
+  documentation for the warnings module.
+
 - Patch #1509163: MS Toolkit Compiler no longer available.
 
+- Patch #1504046: Add documentation for xml.etree.
 
 What's New in Python 2.5 beta 1?
 ================================
@@ -476,6 +741,10 @@
 Library
 -------
 
+- Bug #1223937: subprocess.CalledProcessError reports the exit status
+  of the process using the returncode attribute, instead of
+  abusing errno.
+
 - Patch #1475231: ``doctest`` has a new ``SKIP`` option, which causes
   a doctest to be skipped (the code is not run, and the expected output
   or exception is ignored).
@@ -1094,6 +1363,10 @@
 Library
 -------
 
+- Patch #1388073: Numerous __-prefixed attributes of unittest.TestCase have
+  been renamed to have only a single underscore prefix.  This was done to
+  make subclassing easier.
+
 - PEP 338: new module runpy defines a run_module function to support
   executing modules which provide access to source code or a code object
   via the PEP 302 import mechanisms.
@@ -1409,8 +1682,8 @@
 - Bug #792570: SimpleXMLRPCServer had problems if the request grew too large.
   Fixed by reading the HTTP body in chunks instead of one big socket.read().
 
-- Patches #893642, #1039083: add allow_none, encoding arguments to constructors of
-  SimpleXMLRPCServer and CGIXMLRPCRequestHandler.
+- Patches #893642, #1039083: add allow_none, encoding arguments to
+  constructors of SimpleXMLRPCServer and CGIXMLRPCRequestHandler.
 
 - Bug #1110478: Revert os.environ.update to do putenv again.
 

Modified: python/branches/bcannon-sandboxing/Misc/RPM/python-2.5.spec
==============================================================================
--- python/branches/bcannon-sandboxing/Misc/RPM/python-2.5.spec	(original)
+++ python/branches/bcannon-sandboxing/Misc/RPM/python-2.5.spec	Wed Aug  2 00:51:44 2006
@@ -33,7 +33,7 @@
 #################################
 
 %define name python
-%define version 2.5a2
+%define version 2.5b2
 %define libvers 2.5
 %define release 1pydotorg
 %define __prefix /usr

Modified: python/branches/bcannon-sandboxing/Misc/build.sh
==============================================================================
--- python/branches/bcannon-sandboxing/Misc/build.sh	(original)
+++ python/branches/bcannon-sandboxing/Misc/build.sh	Wed Aug  2 00:51:44 2006
@@ -161,6 +161,10 @@
             make install >& build/$F
             update_status "Installing" "$F" $start
 
+            if [ ! -x $PYTHON ]; then
+                ln -s ${PYTHON}2.* $PYTHON
+            fi
+
             ## make and run basic tests
             F=make-test.out
             start=`current_time`

Modified: python/branches/bcannon-sandboxing/Misc/python-config.in
==============================================================================
--- python/branches/bcannon-sandboxing/Misc/python-config.in	(original)
+++ python/branches/bcannon-sandboxing/Misc/python-config.in	Wed Aug  2 00:51:44 2006
@@ -1,4 +1,4 @@
-#!@BINDIR@/python
+#!@EXENAME@
 
 import sys
 import os
@@ -36,13 +36,14 @@
     print sysconfig.EXEC_PREFIX
 
 elif opt in ('--includes', '--cflags'):
-    flags = ['-I'+dir for dir in getvar('INCLDIRSTOMAKE').split()]
+    flags = ['-I' + sysconfig.get_python_inc(),
+             '-I' + sysconfig.get_python_inc(plat_specific=True)]
     if opt == '--cflags':
         flags.extend(getvar('CFLAGS').split())
     print ' '.join(flags)
 
 elif opt in ('--libs', '--ldflags'):
-    libs = sysconfig.get_config_var('LIBS').split()
+    libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
     libs.append('-lpython'+pyver)
     if opt == '--ldflags':
         libs.insert(0, '-L' + getvar('LIBPL'))

Modified: python/branches/bcannon-sandboxing/Modules/_bsddb.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_bsddb.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_bsddb.c	Wed Aug  2 00:51:44 2006
@@ -98,7 +98,7 @@
 #error "eek! DBVER can't handle minor versions > 9"
 #endif
 
-#define PY_BSDDB_VERSION "4.4.4"
+#define PY_BSDDB_VERSION "4.4.5"
 static char *rcs_id = "$Id$";
 
 
@@ -528,6 +528,7 @@
     PyObject *errObj = NULL;
     PyObject *errTuple = NULL;
     int exceptionRaised = 0;
+    unsigned int bytes_left;
 
     switch (err) {
         case 0:                     /* successful, no error */      break;
@@ -535,12 +536,15 @@
 #if (DBVER < 41)
         case DB_INCOMPLETE:
 #if INCOMPLETE_IS_WARNING
-            our_strlcpy(errTxt, db_strerror(err), sizeof(errTxt));
-            if (_db_errmsg[0]) {
+            bytes_left = our_strlcpy(errTxt, db_strerror(err), sizeof(errTxt));
+            /* Ensure that bytes_left never goes negative */
+            if (_db_errmsg[0] && bytes_left < (sizeof(errTxt) - 4)) {
+                bytes_left = sizeof(errTxt) - bytes_left - 4 - 1;
+		assert(bytes_left >= 0);
                 strcat(errTxt, " -- ");
-                strcat(errTxt, _db_errmsg);
-                _db_errmsg[0] = 0;
+                strncat(errTxt, _db_errmsg, bytes_left);
             }
+            _db_errmsg[0] = 0;
 #ifdef HAVE_WARNINGS
             exceptionRaised = PyErr_Warn(PyExc_RuntimeWarning, errTxt);
 #else
@@ -588,12 +592,15 @@
     }
 
     if (errObj != NULL) {
-        our_strlcpy(errTxt, db_strerror(err), sizeof(errTxt));
-        if (_db_errmsg[0]) {
+        bytes_left = our_strlcpy(errTxt, db_strerror(err), sizeof(errTxt));
+        /* Ensure that bytes_left never goes negative */
+        if (_db_errmsg[0] && bytes_left < (sizeof(errTxt) - 4)) {
+            bytes_left = sizeof(errTxt) - bytes_left - 4 - 1;
+            assert(bytes_left >= 0);
             strcat(errTxt, " -- ");
-            strcat(errTxt, _db_errmsg);
-            _db_errmsg[0] = 0;
+            strncat(errTxt, _db_errmsg, bytes_left);
         }
+        _db_errmsg[0] = 0;
 
 	errTuple = Py_BuildValue("(is)", err, errTxt);
         PyErr_SetObject(errObj, errTuple);
@@ -798,10 +805,12 @@
 
     MYDB_BEGIN_ALLOW_THREADS;
     err = db_create(&self->db, db_env, flags);
-    self->db->set_errcall(self->db, _db_errorCallback);
+    if (self->db != NULL) {
+        self->db->set_errcall(self->db, _db_errorCallback);
 #if (DBVER >= 33)
-    self->db->app_private = (void*)self;
+        self->db->app_private = (void*)self;
 #endif
+    }
     MYDB_END_ALLOW_THREADS;
     /* TODO add a weakref(self) to the self->myenvobj->open_child_weakrefs
      * list so that a DBEnv can refuse to close without aborting any open
@@ -3867,7 +3876,7 @@
     static char* kwnames[] = { "file", "database", "txn", "flags",
                                      NULL };
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss|Oi:dbremove", kwnames,
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|zOi:dbremove", kwnames,
 		&file, &database, &txnobj, &flags)) {
 	return NULL;
     }
@@ -3895,7 +3904,7 @@
     static char* kwnames[] = { "file", "database", "newname", "txn",
                                      "flags", NULL };
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sss|Oi:dbrename", kwnames,
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "szs|Oi:dbrename", kwnames,
 		&file, &database, &newname, &txnobj, &flags)) {
 	return NULL;
     }

Modified: python/branches/bcannon-sandboxing/Modules/_ctypes/_ctypes.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_ctypes/_ctypes.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_ctypes/_ctypes.c	Wed Aug  2 00:51:44 2006
@@ -1384,13 +1384,20 @@
 		Py_DECREF(result);
 		return NULL;
 	}
+	fmt = getentry(PyString_AS_STRING(proto));
+	if (fmt == NULL) {
+		Py_DECREF(result);
+		PyErr_Format(PyExc_ValueError,
+			     "_type_ '%s' not supported",
+			     PyString_AS_STRING(proto));
+		return NULL;
+	}
+
 	stgdict = (StgDictObject *)PyObject_CallObject(
 		(PyObject *)&StgDict_Type, NULL);
 	if (!stgdict)
 		return NULL;
 
-	fmt = getentry(PyString_AS_STRING(proto));
-
 	stgdict->ffi_type_pointer = *fmt->pffi_type;
 	stgdict->align = fmt->pffi_type->alignment;
 	stgdict->length = 0;
@@ -1633,9 +1640,8 @@
 
 	for (i = 0; i < nArgs; ++i) {
 		PyObject *tp = PyTuple_GET_ITEM(ob, i);
-		StgDictObject *dict = PyType_stgdict(tp);
 		PyObject *cnv = PyObject_GetAttrString(tp, "from_param");
-		if (!dict || !cnv)
+		if (!cnv)
 			goto argtypes_error_1;
 		PyTuple_SET_ITEM(converters, i, cnv);
 	}
@@ -1646,7 +1652,7 @@
 	Py_XDECREF(converters);
 	Py_DECREF(ob);
 	PyErr_Format(PyExc_TypeError,
-		     "item %d in _argtypes_ is not a valid C type", i+1);
+		     "item %d in _argtypes_ has no from_param method", i+1);
 	return NULL;
 }
 
@@ -2181,7 +2187,7 @@
 			Py_DECREF(ob);
 			return result;
 		} else if (value == Py_None && PointerTypeObject_Check(type)) {
-			*(void **)dst->b_ptr = NULL;
+			*(void **)ptr = NULL;
 			Py_INCREF(Py_None);
 			return Py_None;
 		} else {
@@ -3567,7 +3573,8 @@
 	int offset, size;
 	StgDictObject *stgdict;
 
-	if (self->b_length == 0 || index < 0 || (self->b_length > 1 && index >= self->b_length)) {
+
+	if (index < 0 || index >= self->b_length) {
 		PyErr_SetString(PyExc_IndexError,
 				"invalid index");
 		return NULL;
@@ -3596,11 +3603,11 @@
 
 	if (ilow < 0)
 		ilow = 0;
-	else if (ilow > self->b_length && self->b_length != 1)
+	else if (ilow > self->b_length)
 		ilow = self->b_length;
 	if (ihigh < ilow)
 		ihigh = ilow;
-	else if (ihigh > self->b_length && self->b_length != 1)
+	else if (ihigh > self->b_length)
 		ihigh = self->b_length;
 	len = ihigh - ilow;
 
@@ -3643,8 +3650,7 @@
 	}
 	
 	stgdict = PyObject_stgdict((PyObject *)self);
-	if (self->b_length == 0 || index < 0
-	    || (self->b_length > 1 && index >= self->b_length)) {
+	if (index < 0 || index >= stgdict->length) {
 		PyErr_SetString(PyExc_IndexError,
 				"invalid index");
 		return -1;
@@ -3671,19 +3677,17 @@
 
 	if (ilow < 0)
 		ilow = 0;
-	else if (ilow > self->b_length && self->b_length != 1)
+	else if (ilow > self->b_length)
 		ilow = self->b_length;
-
 	if (ihigh < 0)
 		ihigh = 0;
-
 	if (ihigh < ilow)
 		ihigh = ilow;
-	else if (ihigh > self->b_length && self->b_length != 1)
+	else if (ihigh > self->b_length)
 		ihigh = self->b_length;
 
 	len = PySequence_Length(value);
-	if (self->b_length != 1 && len != ihigh - ilow) {
+	if (len != ihigh - ilow) {
 		PyErr_SetString(PyExc_ValueError,
 				"Can only assign sequence of same size");
 		return -1;
@@ -4517,23 +4521,30 @@
 		if (obj->b_objects == Py_None) {
 			Py_DECREF(Py_None);
 			obj->b_objects = PyDict_New();
+			if (obj->b_objects == NULL)
+				goto failed;
 		}
-		Py_INCREF(obj->b_objects);
 		result->b_objects = obj->b_objects;
 		if (result->b_objects) {
-			PyObject *index = PyLong_FromVoidPtr((void *)src);
+			PyObject *index;
 			int rc;
+			Py_INCREF(obj->b_objects);
+			index = PyLong_FromVoidPtr((void *)src);
 			if (index == NULL)
-				return NULL;
+				goto failed;
 			rc = PyDict_SetItem(result->b_objects, index, src);
 			Py_DECREF(index);
 			if (rc == -1)
-				return NULL;
+				goto failed;
 		}
 	}
 	/* Should we assert that result is a pointer type? */
 	memcpy(result->b_ptr, &ptr, sizeof(void *));
 	return (PyObject *)result;
+
+  failed:
+	Py_DECREF(result);
+	return NULL;
 }
 
 #ifdef CTYPES_UNICODE
@@ -4555,7 +4566,7 @@
    ob_type is the metatype (the 'type'), defaults to PyType_Type,
    tp_base is the base type, defaults to 'object' aka PyBaseObject_Type.
 */
-#ifdef WITH_THREADS
+#ifdef WITH_THREAD
 	PyEval_InitThreads();
 #endif
 	m = Py_InitModule3("_ctypes", module_methods, module_docs);
@@ -4667,7 +4678,7 @@
 #endif
 	PyModule_AddObject(m, "FUNCFLAG_CDECL", PyInt_FromLong(FUNCFLAG_CDECL));
 	PyModule_AddObject(m, "FUNCFLAG_PYTHONAPI", PyInt_FromLong(FUNCFLAG_PYTHONAPI));
-	PyModule_AddStringConstant(m, "__version__", "0.9.9.7");
+	PyModule_AddStringConstant(m, "__version__", "1.0.0");
 
 	PyModule_AddObject(m, "_memmove_addr", PyLong_FromVoidPtr(memmove));
 	PyModule_AddObject(m, "_memset_addr", PyLong_FromVoidPtr(memset));
@@ -4705,13 +4716,14 @@
 }
 
 /*****************************************************************
- * replacements for broken Python api functions
+ * replacements for broken Python api functions (in Python 2.3).
+ * See #1047269 Buffer overwrite in PyUnicode_AsWideChar
  */
 
 #ifdef HAVE_WCHAR_H
 
 PyObject *My_PyUnicode_FromWideChar(register const wchar_t *w,
-				    int size)
+				    Py_ssize_t size)
 {
     PyUnicodeObject *unicode;
 
@@ -4743,7 +4755,7 @@
 
 int My_PyUnicode_AsWideChar(PyUnicodeObject *unicode,
 			    register wchar_t *w,
-			    int size)
+			    Py_ssize_t size)
 {
     if (unicode == NULL) {
 	PyErr_BadInternalCall();

Modified: python/branches/bcannon-sandboxing/Modules/_ctypes/callbacks.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_ctypes/callbacks.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_ctypes/callbacks.c	Wed Aug  2 00:51:44 2006
@@ -127,7 +127,7 @@
 	PyObject *result;
 	PyObject *arglist = NULL;
 	int nArgs;
-#ifdef WITH_THREADS
+#ifdef WITH_THREAD
 	PyGILState_STATE state = PyGILState_Ensure();
 #endif
 
@@ -237,7 +237,7 @@
 	Py_XDECREF(result);
   Done:
 	Py_XDECREF(arglist);
-#ifdef WITH_THREADS	
+#ifdef WITH_THREAD
 	PyGILState_Release(state);
 #endif
 }
@@ -348,7 +348,9 @@
 static void LoadPython(void)
 {
 	if (!Py_IsInitialized()) {
+#ifdef WITH_THREAD
 		PyEval_InitThreads();
+#endif
 		Py_Initialize();
 	}
 }
@@ -400,16 +402,16 @@
 			 LPVOID *ppv)
 {
 	long result;
-#ifdef WITH_THREADS
+#ifdef WITH_THREAD
 	PyGILState_STATE state;
 #endif
 
 	LoadPython();
-#ifdef WITH_THREADS
+#ifdef WITH_THREAD
 	state = PyGILState_Ensure();
 #endif
 	result = Call_GetClassObject(rclsid, riid, ppv);
-#ifdef WITH_THREADS
+#ifdef WITH_THREAD
 	PyGILState_Release(state);
 #endif
 	return result;
@@ -463,11 +465,11 @@
 STDAPI DllCanUnloadNow(void)
 {
 	long result;
-#ifdef WITH_THREADS
+#ifdef WITH_THREAD
 	PyGILState_STATE state = PyGILState_Ensure();
 #endif
 	result = Call_CanUnloadNow();
-#ifdef WITH_THREADS
+#ifdef WITH_THREAD
 	PyGILState_Release(state);
 #endif
 	return result;

Modified: python/branches/bcannon-sandboxing/Modules/_ctypes/callproc.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_ctypes/callproc.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_ctypes/callproc.c	Wed Aug  2 00:51:44 2006
@@ -617,7 +617,7 @@
 				  void *resmem,
 				  int argcount)
 {
-#ifdef WITH_THREADS
+#ifdef WITH_THREAD
 	PyThreadState *_save = NULL; /* For Py_BLOCK_THREADS and Py_UNBLOCK_THREADS */
 #endif
 	ffi_cif cif;
@@ -651,7 +651,7 @@
 		return -1;
 	}
 
-#ifdef WITH_THREADS
+#ifdef WITH_THREAD
 	if ((flags & FUNCFLAG_PYTHONAPI) == 0)
 		Py_UNBLOCK_THREADS
 #endif
@@ -671,7 +671,7 @@
 	}
 #endif
 #endif
-#ifdef WITH_THREADS
+#ifdef WITH_THREAD
 	if ((flags & FUNCFLAG_PYTHONAPI) == 0)
 		Py_BLOCK_THREADS
 #endif
@@ -818,7 +818,9 @@
 	/* We absolutely have to release the GIL during COM method calls,
 	   otherwise we may get a deadlock!
 	*/
+#ifdef WITH_THREAD
 	Py_BEGIN_ALLOW_THREADS
+#endif
 
 	hr = pIunk->lpVtbl->QueryInterface(pIunk, &IID_ISupportErrorInfo, (void **)&psei);
 	if (FAILED(hr))
@@ -842,22 +844,24 @@
 	pei->lpVtbl->Release(pei);
 
   failed:
+#ifdef WITH_THREAD
 	Py_END_ALLOW_THREADS
+#endif
 
 	progid = NULL;
 	ProgIDFromCLSID(&guid, &progid);
 
-/* XXX Is COMError derived from WindowsError or not? */
 	text = FormatError(errcode);
+	obj = Py_BuildValue(
 #ifdef _UNICODE
-	obj = Py_BuildValue("iu(uuuiu)",
+		"iu(uuuiu)",
 #else
-	obj = Py_BuildValue("is(uuuiu)",
+		"is(uuuiu)",
 #endif
-			    errcode,
-			    text,
-			    descr, source, helpfile, helpcontext,
-			    progid);
+		errcode,
+		text,
+		descr, source, helpfile, helpcontext,
+		progid);
 	if (obj) {
 		PyErr_SetObject(ComError, obj);
 		Py_DECREF(obj);
@@ -1156,7 +1160,7 @@
 }
 
 static char copy_com_pointer_doc[] =
-"CopyComPointer(a, b) -> integer\n";
+"CopyComPointer(src, dst) -> HRESULT value\n";
 
 static PyObject *
 copy_com_pointer(PyObject *self, PyObject *args)
@@ -1526,21 +1530,7 @@
 	return Py_None;
 }
 
-static PyObject *
-uses_seh(PyObject *self, PyObject *args)
-{
-#if defined(DONT_USE_SEH) || !defined(MS_WIN32)
-	Py_INCREF(Py_False);
-	return Py_False;
-#else
-	Py_INCREF(Py_True);
-	return Py_True;
-#endif
-}
-
 PyMethodDef module_methods[] = {
-	{"uses_seh", uses_seh, METH_NOARGS,
-	 "Return whether ctypes uses Windows structured exception handling"},
 	{"resize", resize, METH_VARARGS, "Resize the memory buffer of a ctypes instance"},
 #ifdef CTYPES_UNICODE
 	{"set_conversion_mode", set_conversion_mode, METH_VARARGS, set_conversion_mode_doc},

Modified: python/branches/bcannon-sandboxing/Modules/_ctypes/cfield.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_ctypes/cfield.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_ctypes/cfield.c	Wed Aug  2 00:51:44 2006
@@ -124,7 +124,7 @@
 	self->getfunc = getfunc;
 	self->index = index;
 
-	Py_XINCREF(proto);
+	Py_INCREF(proto);
 	self->proto = proto;
 
 	switch (fieldtype) {
@@ -1486,16 +1486,27 @@
 		*(void **)ptr = NULL;
 		_RET(value);
 	}
-	
-	v = PyLong_AsVoidPtr(value);
-	if (PyErr_Occurred()) {
-		/* prevent the SystemError: bad argument to internal function */
-		if (!PyInt_Check(value) && !PyLong_Check(value)) {
-			PyErr_SetString(PyExc_TypeError,
-					"cannot be converted to pointer");
-		}
+
+	if (!PyInt_Check(value) && !PyLong_Check(value)) {
+		PyErr_SetString(PyExc_TypeError,
+				"cannot be converted to pointer");
 		return NULL;
 	}
+
+#if SIZEOF_VOID_P <= SIZEOF_LONG
+	v = (void *)PyInt_AsUnsignedLongMask(value);
+#else
+#ifndef HAVE_LONG_LONG
+#   error "PyLong_AsVoidPtr: sizeof(void*) > sizeof(long), but no long long"
+#elif SIZEOF_LONG_LONG < SIZEOF_VOID_P
+#   error "PyLong_AsVoidPtr: sizeof(PY_LONG_LONG) < sizeof(void*)"
+#endif
+	v = (void *)PyInt_AsUnsignedLongLongMask(value);
+#endif
+
+	if (PyErr_Occurred())
+		return NULL;
+
 	*(void **)ptr = v;
 	_RET(value);
 }

Modified: python/branches/bcannon-sandboxing/Modules/_ctypes/ctypes.h
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_ctypes/ctypes.h	(original)
+++ python/branches/bcannon-sandboxing/Modules/_ctypes/ctypes.h	Wed Aug  2 00:51:44 2006
@@ -377,8 +377,8 @@
 #  undef PyUnicode_AsWideChar
 #  define PyUnicode_AsWideChar My_PyUnicode_AsWideChar
 
-extern PyObject *My_PyUnicode_FromWideChar(const wchar_t *, int);
-extern int My_PyUnicode_AsWideChar(PyUnicodeObject *, wchar_t *, int);
+extern PyObject *My_PyUnicode_FromWideChar(const wchar_t *, Py_ssize_t);
+extern int My_PyUnicode_AsWideChar(PyUnicodeObject *, wchar_t *, Py_ssize_t);
 
 #endif
 

Modified: python/branches/bcannon-sandboxing/Modules/_ctypes/libffi/configure
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_ctypes/libffi/configure	(original)
+++ python/branches/bcannon-sandboxing/Modules/_ctypes/libffi/configure	Wed Aug  2 00:51:44 2006
@@ -934,7 +934,7 @@
     else
       echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
     fi
-    cd $ac_popdir
+    cd "$ac_popdir"
   done
 fi
 
@@ -1973,8 +1973,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -2032,8 +2031,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -2149,8 +2147,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -2204,8 +2201,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -2250,8 +2246,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -2295,8 +2290,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -2623,8 +2617,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -2794,8 +2787,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -2862,8 +2854,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -3047,8 +3038,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -3111,8 +3101,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -3290,8 +3279,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -3408,8 +3396,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -3483,6 +3470,12 @@
 
 TARGETDIR="unknown"
 case "$host" in
+mips*-*-openbsd*) TARGET=MIPS; TARGETDIR=mips;;
+sparc-*-openbsd*) TARGET=SPARC; TARGETDIR=sparc;;
+sparc64-*-openbsd*) TARGET=SPARC; TARGETDIR=sparc;;
+alpha*-*-openbsd*) TARGET=ALPHA; TARGETDIR=alpha;;
+m68k-*-openbsd*) TARGET=M68K; TARGETDIR=m68k;;
+powerpc-*-openbsd*) TARGET=POWERPC; TARGETDIR=powerpc;;
 i*86-*-darwin*) TARGET=X86_DARWIN; TARGETDIR=x86;;
 i*86-*-linux*) TARGET=X86; TARGETDIR=x86;;
 i*86-*-gnu*) TARGET=X86; TARGETDIR=x86;;
@@ -3575,8 +3568,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -3777,8 +3769,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -3841,8 +3832,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -3923,8 +3913,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4065,8 +4054,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4202,8 +4190,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4265,8 +4252,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4306,8 +4292,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4363,8 +4348,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4404,8 +4388,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4469,8 +4452,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4501,10 +4483,8 @@
 esac
 else
   if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
+  { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5
+echo "$as_me: error: internal error: not reached in cross-compile" >&2;}
    { (exit 1); exit 1; }; }
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -4616,8 +4596,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4679,8 +4658,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4720,8 +4698,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4777,8 +4754,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4818,8 +4794,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4883,8 +4858,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -4915,10 +4889,8 @@
 esac
 else
   if test "$cross_compiling" = yes; then
-  { { echo "$as_me:$LINENO: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&5
-echo "$as_me: error: cannot run test program while cross compiling
-See \`config.log' for more details." >&2;}
+  { { echo "$as_me:$LINENO: error: internal error: not reached in cross-compile" >&5
+echo "$as_me: error: internal error: not reached in cross-compile" >&2;}
    { (exit 1); exit 1; }; }
 else
   cat >conftest.$ac_ext <<_ACEOF
@@ -5048,8 +5020,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -5091,8 +5062,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -5149,8 +5119,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -5282,8 +5251,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -5349,8 +5317,7 @@
   cat conftest.err >&5
   echo "$as_me:$LINENO: \$? = $ac_status" >&5
   (exit $ac_status); } &&
-	 { ac_try='test -z "$ac_c_werror_flag"
-			 || test ! -s conftest.err'
+	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   (eval $ac_try) 2>&5
   ac_status=$?
@@ -6309,11 +6276,6 @@
 
 
 
-  if test x"$ac_file" != x-; then
-    { echo "$as_me:$LINENO: creating $ac_file" >&5
-echo "$as_me: creating $ac_file" >&6;}
-    rm -f "$ac_file"
-  fi
   # Let's still pretend it is `configure' which instantiates (i.e., don't
   # use $as_me), people would be surprised to read:
   #    /* config.h.  Generated by config.status.  */
@@ -6352,6 +6314,12 @@
 	 fi;;
       esac
     done` || { (exit 1); exit 1; }
+
+  if test x"$ac_file" != x-; then
+    { echo "$as_me:$LINENO: creating $ac_file" >&5
+echo "$as_me: creating $ac_file" >&6;}
+    rm -f "$ac_file"
+  fi
 _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF
   sed "$ac_vpsub

Modified: python/branches/bcannon-sandboxing/Modules/_ctypes/libffi/configure.ac
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_ctypes/libffi/configure.ac	(original)
+++ python/branches/bcannon-sandboxing/Modules/_ctypes/libffi/configure.ac	Wed Aug  2 00:51:44 2006
@@ -21,6 +21,12 @@
 
 TARGETDIR="unknown"
 case "$host" in
+mips*-*-openbsd*) TARGET=MIPS; TARGETDIR=mips;;
+sparc-*-openbsd*) TARGET=SPARC; TARGETDIR=sparc;;
+sparc64-*-openbsd*) TARGET=SPARC; TARGETDIR=sparc;;
+alpha*-*-openbsd*) TARGET=ALPHA; TARGETDIR=alpha;;
+m68k-*-openbsd*) TARGET=M68K; TARGETDIR=m68k;;
+powerpc-*-openbsd*) TARGET=POWERPC; TARGETDIR=powerpc;;
 i*86-*-darwin*) TARGET=X86_DARWIN; TARGETDIR=x86;;
 i*86-*-linux*) TARGET=X86; TARGETDIR=x86;;
 i*86-*-gnu*) TARGET=X86; TARGETDIR=x86;;

Modified: python/branches/bcannon-sandboxing/Modules/_ctypes/stgdict.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_ctypes/stgdict.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_ctypes/stgdict.c	Wed Aug  2 00:51:44 2006
@@ -134,16 +134,25 @@
 	type = (PyTypeObject *)obj;
 	if (!PyType_HasFeature(type, Py_TPFLAGS_HAVE_CLASS))
 		return NULL;
-	if (!type->tp_dict || !StgDict_Check(type->tp_dict))
+	if (!type->tp_dict || !StgDict_CheckExact(type->tp_dict))
 		return NULL;
 	return (StgDictObject *)type->tp_dict;
 }
 
 /* May return NULL, but does not set an exception! */
+/*
+  This function should be as fast as possible, so we don't call PyType_stgdict
+  above but inline the code, and avoid the PyType_Check().
+*/
 StgDictObject *
 PyObject_stgdict(PyObject *self)
 {
-	return PyType_stgdict((PyObject *)self->ob_type);
+	PyTypeObject *type = self->ob_type;
+	if (!PyType_HasFeature(type, Py_TPFLAGS_HAVE_CLASS))
+		return NULL;
+	if (!type->tp_dict || !StgDict_CheckExact(type->tp_dict))
+		return NULL;
+	return (StgDictObject *)type->tp_dict;
 }
 
 /* descr is the descriptor for a field marked as anonymous.  Get all the

Modified: python/branches/bcannon-sandboxing/Modules/_cursesmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_cursesmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_cursesmodule.c	Wed Aug  2 00:51:44 2006
@@ -43,7 +43,7 @@
 	del_curterm delscreen dupwin inchnstr inchstr innstr keyok
 	mcprint mvaddchnstr mvaddchstr mvchgat mvcur mvinchnstr
 	mvinchstr mvinnstr mmvwaddchnstr mvwaddchstr mvwchgat
-	mvwgetnstr mvwinchnstr mvwinchstr mvwinnstr newterm
+	mvwinchnstr mvwinchstr mvwinnstr newterm
 	restartterm ripoffline scr_dump
 	scr_init scr_restore scr_set scrl set_curterm set_term setterm
 	tgetent tgetflag tgetnum tgetstr tgoto timeout tputs
@@ -819,14 +819,17 @@
     if (!PyArg_ParseTuple(args,"ii;y,x",&y,&x))
       return NULL;
     Py_BEGIN_ALLOW_THREADS
+#ifdef STRICT_SYSV_CURSES
+    rtn2 = wmove(self->win,y,x)==ERR ? ERR : wgetnstr(self->win, rtn, 1023);
+#else
     rtn2 = mvwgetnstr(self->win,y,x,rtn, 1023);
+#endif
     Py_END_ALLOW_THREADS
     break;
   case 3:
     if (!PyArg_ParseTuple(args,"iii;y,x,n", &y, &x, &n))
       return NULL;
 #ifdef STRICT_SYSV_CURSES
- /* Untested */
     Py_BEGIN_ALLOW_THREADS
     rtn2 = wmove(self->win,y,x)==ERR ? ERR :
       wgetnstr(self->win, rtn, MIN(n, 1023));
@@ -838,7 +841,7 @@
 #endif
     break;
   default:
-    PyErr_SetString(PyExc_TypeError, "getstr requires 0 to 2 arguments");
+    PyErr_SetString(PyExc_TypeError, "getstr requires 0 to 3 arguments");
     return NULL;
   }
   if (rtn2 == ERR)

Modified: python/branches/bcannon-sandboxing/Modules/_sqlite/cursor.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_sqlite/cursor.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_sqlite/cursor.c	Wed Aug  2 00:51:44 2006
@@ -621,7 +621,7 @@
                 }
             } else {
                 if (PyErr_Occurred()) {
-                    /* there was an error that occured in a user-defined callback */
+                    /* there was an error that occurred in a user-defined callback */
                     if (_enable_callback_tracebacks) {
                         PyErr_Print();
                     } else {

Modified: python/branches/bcannon-sandboxing/Modules/_sqlite/util.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_sqlite/util.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_sqlite/util.c	Wed Aug  2 00:51:44 2006
@@ -38,7 +38,7 @@
 
 /**
  * Checks the SQLite error code and sets the appropriate DB-API exception.
- * Returns the error code (0 means no error occured).
+ * Returns the error code (0 means no error occurred).
  */
 int _seterror(sqlite3* db)
 {

Modified: python/branches/bcannon-sandboxing/Modules/_sqlite/util.h
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_sqlite/util.h	(original)
+++ python/branches/bcannon-sandboxing/Modules/_sqlite/util.h	Wed Aug  2 00:51:44 2006
@@ -32,7 +32,7 @@
 
 /**
  * Checks the SQLite error code and sets the appropriate DB-API exception.
- * Returns the error code (0 means no error occured).
+ * Returns the error code (0 means no error occurred).
  */
 int _seterror(sqlite3* db);
 #endif

Modified: python/branches/bcannon-sandboxing/Modules/_ssl.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_ssl.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_ssl.c	Wed Aug  2 00:51:44 2006
@@ -26,6 +26,12 @@
 /* Include symbols from _socket module */
 #include "socketmodule.h"
 
+#if defined(HAVE_POLL_H) 
+#include <poll.h>
+#elif defined(HAVE_SYS_POLL_H)
+#include <sys/poll.h>
+#endif
+
 /* Include OpenSSL header files */
 #include "openssl/rsa.h"
 #include "openssl/crypto.h"
@@ -351,7 +357,7 @@
 	PyObject_Del(self);
 }
 
-/* If the socket has a timeout, do a select() on the socket.
+/* If the socket has a timeout, do a select()/poll() on the socket.
    The argument writing indicates the direction.
    Returns one of the possibilities in the timeout_state enum (above).
  */
@@ -373,6 +379,26 @@
 	if (s->sock_fd < 0)
 		return SOCKET_HAS_BEEN_CLOSED;
 
+	/* Prefer poll, if available, since you can poll() any fd
+	 * which can't be done with select(). */
+#ifdef HAVE_POLL
+	{
+		struct pollfd pollfd;
+		int timeout;
+
+		pollfd.fd = s->sock_fd;
+		pollfd.events = writing ? POLLOUT : POLLIN;
+
+		/* s->sock_timeout is in seconds, timeout in ms */
+		timeout = (int)(s->sock_timeout * 1000 + 0.5);
+		Py_BEGIN_ALLOW_THREADS
+		rc = poll(&pollfd, 1, timeout);
+		Py_END_ALLOW_THREADS
+
+		goto normal_return;
+	}
+#endif
+
 	/* Guard against socket too large for select*/
 #ifndef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
 	if (s->sock_fd >= FD_SETSIZE)
@@ -393,6 +419,7 @@
 		rc = select(s->sock_fd+1, &fds, NULL, NULL, &tv);
 	Py_END_ALLOW_THREADS
 
+normal_return:
 	/* Return SOCKET_TIMED_OUT on timeout, SOCKET_OPERATION_OK otherwise
 	   (when we are able to write or when there's something to read) */
 	return rc == 0 ? SOCKET_HAS_TIMED_OUT : SOCKET_OPERATION_OK;

Modified: python/branches/bcannon-sandboxing/Modules/_struct.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_struct.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_struct.c	Wed Aug  2 00:51:44 2006
@@ -214,6 +214,8 @@
 /* Helper routine to get a Python integer and raise the appropriate error
    if it isn't one */
 
+#define INT_OVERFLOW "struct integer overflow masking is deprecated"
+
 static int
 get_wrapped_long(PyObject *v, long *p)
 {
@@ -223,7 +225,7 @@
 			PyObject *wrapped;
 			long x;
 			PyErr_Clear();
-			if (PyErr_Warn(PyExc_DeprecationWarning, "struct integer overflow masking is deprecated") < 0)
+			if (PyErr_WarnEx(PyExc_DeprecationWarning, INT_OVERFLOW, 2) < 0)
 				return -1;
 			wrapped = PyNumber_And(v, pylong_ulong_mask);
 			if (wrapped == NULL)
@@ -250,7 +252,7 @@
 		wrapped = PyNumber_And(v, pylong_ulong_mask);
 		if (wrapped == NULL)
 			return -1;
-		if (PyErr_Warn(PyExc_DeprecationWarning, "struct integer overflow masking is deprecated") < 0) {
+		if (PyErr_WarnEx(PyExc_DeprecationWarning, INT_OVERFLOW, 2) < 0) {
 			Py_DECREF(wrapped);
 			return -1;
 		}
@@ -345,8 +347,8 @@
 		Py_XDECREF(ptraceback);
 		if (msg == NULL)
 			return -1;
-		rval = PyErr_Warn(PyExc_DeprecationWarning,
-				  PyString_AS_STRING(msg));
+		rval = PyErr_WarnEx(PyExc_DeprecationWarning,
+				    PyString_AS_STRING(msg), 2);
 		Py_DECREF(msg);
 		if (rval == 0)
 			return 0;

Modified: python/branches/bcannon-sandboxing/Modules/_testcapimodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_testcapimodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_testcapimodule.c	Wed Aug  2 00:51:44 2006
@@ -294,6 +294,16 @@
 
 #endif	/* ifdef HAVE_LONG_LONG */
 
+/* Test tuple argument processing */
+static PyObject *
+getargs_tuple(PyObject *self, PyObject *args)
+{
+	int a, b, c;
+	if (!PyArg_ParseTuple(args, "i(ii)", &a, &b, &c))
+		return NULL;
+	return Py_BuildValue("iii", a, b, c);
+}
+
 /* Functions to call PyArg_ParseTuple with integer format codes,
    and return the result.
 */
@@ -707,6 +717,7 @@
 	{"test_null_strings",	(PyCFunction)test_null_strings,	 METH_NOARGS},
 	{"test_string_from_format", (PyCFunction)test_string_from_format, METH_NOARGS},
 
+	{"getargs_tuple",	getargs_tuple,			 METH_VARARGS},
 	{"getargs_b",		getargs_b,			 METH_VARARGS},
 	{"getargs_B",		getargs_B,			 METH_VARARGS},
 	{"getargs_H",		getargs_H,			 METH_VARARGS},

Modified: python/branches/bcannon-sandboxing/Modules/_tkinter.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/_tkinter.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/_tkinter.c	Wed Aug  2 00:51:44 2006
@@ -2104,8 +2104,8 @@
 	data = PyMem_NEW(PythonCmd_ClientData, 1);
 	if (!data)
 		return PyErr_NoMemory();
-	Py_XINCREF(self);
-	Py_XINCREF(func);
+	Py_INCREF(self);
+	Py_INCREF(func);
 	data->self = selfptr;
 	data->func = func;
 	

Modified: python/branches/bcannon-sandboxing/Modules/bz2module.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/bz2module.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/bz2module.c	Wed Aug  2 00:51:44 2006
@@ -1311,7 +1311,11 @@
 				break;
 
 			case 'U':
+#ifdef __VMS
+				self->f_univ_newline = 0;
+#else
 				self->f_univ_newline = 1;
+#endif
 				break;
 
 			default:
@@ -1344,8 +1348,10 @@
 
 #ifdef WITH_THREAD
 	self->lock = PyThread_allocate_lock();
-	if (!self->lock)
+	if (!self->lock) {
+		PyErr_SetString(PyExc_MemoryError, "unable to allocate lock");
 		goto error;
+	}
 #endif
 
 	if (mode_char == 'r')
@@ -1367,10 +1373,12 @@
 	return 0;
 
 error:
-	Py_DECREF(self->file);
+	Py_CLEAR(self->file);
 #ifdef WITH_THREAD
-	if (self->lock)
+	if (self->lock) {
 		PyThread_free_lock(self->lock);
+		self->lock = NULL;
+	}
 #endif
 	return -1;
 }
@@ -1678,8 +1686,10 @@
 
 #ifdef WITH_THREAD
 	self->lock = PyThread_allocate_lock();
-	if (!self->lock)
+	if (!self->lock) {
+		PyErr_SetString(PyExc_MemoryError, "unable to allocate lock");
 		goto error;
+	}
 #endif
 
 	memset(&self->bzs, 0, sizeof(bz_stream));
@@ -1694,8 +1704,10 @@
 	return 0;
 error:
 #ifdef WITH_THREAD
-	if (self->lock)
+	if (self->lock) {
 		PyThread_free_lock(self->lock);
+		self->lock = NULL;
+	}
 #endif
 	return -1;
 }
@@ -1890,8 +1902,10 @@
 
 #ifdef WITH_THREAD
 	self->lock = PyThread_allocate_lock();
-	if (!self->lock)
+	if (!self->lock) {
+		PyErr_SetString(PyExc_MemoryError, "unable to allocate lock");
 		goto error;
+	}
 #endif
 
 	self->unused_data = PyString_FromString("");
@@ -1911,10 +1925,12 @@
 
 error:
 #ifdef WITH_THREAD
-	if (self->lock)
+	if (self->lock) {
 		PyThread_free_lock(self->lock);
+		self->lock = NULL;
+	}
 #endif
-	Py_XDECREF(self->unused_data);
+	Py_CLEAR(self->unused_data);
 	return -1;
 }
 

Modified: python/branches/bcannon-sandboxing/Modules/cPickle.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/cPickle.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/cPickle.c	Wed Aug  2 00:51:44 2006
@@ -196,7 +196,7 @@
 	for (i = self->length, p = self->data + clearto;
 	     --i >= clearto;
 	     p++) {
-		Py_DECREF(*p);
+		Py_CLEAR(*p);
 	}
 	self->length = clearto;
 
@@ -208,6 +208,7 @@
 {
 	int bigger;
 	size_t nbytes;
+	PyObject **tmp;
 
 	bigger = self->size << 1;
 	if (bigger <= 0)	/* was 0, or new value overflows */
@@ -217,14 +218,14 @@
 	nbytes = (size_t)bigger * sizeof(PyObject *);
 	if (nbytes / sizeof(PyObject *) != (size_t)bigger)
 		goto nomemory;
-	self->data = realloc(self->data, nbytes);
-	if (self->data == NULL)
+	tmp = realloc(self->data, nbytes);
+	if (tmp == NULL)
 		goto nomemory;
+	self->data = tmp;
 	self->size = bigger;
 	return 0;
 
   nomemory:
-	self->size = 0;
 	PyErr_NoMemory();
 	return -1;
 }
@@ -2636,7 +2637,7 @@
 			if (ik >= lm || ik == 0) {
 				PyErr_SetString(PicklingError,
 						"Invalid get data");
-				return NULL;
+				goto err;
 			}
 			if (have_get[ik]) /* with matching get */
 				rsize += ik < 256 ? 2 : 5;
@@ -2648,7 +2649,7 @@
 			) {
 			PyErr_SetString(PicklingError,
 					"Unexpected data in internal list");
-			return NULL;
+			goto err;
 		}
 
 		else { /* put */
@@ -4163,6 +4164,7 @@
 		int list_len;
 
 		slice=Pdata_popList(self->stack, x);
+		if (! slice) return -1;
 		list_len = PyList_GET_SIZE(list);
 		i=PyList_SetSlice(list, list_len, list_len, slice);
 		Py_DECREF(slice);
@@ -5167,6 +5169,9 @@
 	if (!( self->memo = PyDict_New()))
 		goto err;
 
+	if (!self->stack)
+		goto err;
+
 	Py_INCREF(f);
 	self->file = f;
 

Modified: python/branches/bcannon-sandboxing/Modules/collectionsmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/collectionsmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/collectionsmodule.c	Wed Aug  2 00:51:44 2006
@@ -10,7 +10,7 @@
 /* The block length may be set to any number over 1.  Larger numbers
  * reduce the number of calls to the memory allocator but take more
  * memory.  Ideally, BLOCKLEN should be set with an eye to the
- * length of a cache line.  
+ * length of a cache line.
  */
 
 #define BLOCKLEN 62
@@ -22,9 +22,9 @@
  * element is at d.leftblock[leftindex] and its last element is at
  * d.rightblock[rightindex]; note that, unlike as for Python slice
  * indices, these indices are inclusive on both ends.  By being inclusive
- * on both ends, algorithms for left and right operations become 
+ * on both ends, algorithms for left and right operations become
  * symmetrical which simplifies the design.
- * 
+ *
  * The list of blocks is never empty, so d.leftblock and d.rightblock
  * are never equal to NULL.
  *
@@ -37,11 +37,11 @@
  * d.leftindex == CENTER+1; and d.rightindex == CENTER.
  * Checking for d.len == 0 is the intended way to see whether d is empty.
  *
- * Whenever d.leftblock == d.rightblock, 
+ * Whenever d.leftblock == d.rightblock,
  *     d.leftindex + d.len - 1 == d.rightindex.
- * 
+ *
  * However, when d.leftblock != d.rightblock, d.leftindex and d.rightindex
- * become indices into distinct blocks and either may be larger than the 
+ * become indices into distinct blocks and either may be larger than the
  * other.
  */
 
@@ -381,7 +381,7 @@
 		int cmp = PyObject_RichCompareBool(item, value, Py_EQ);
 
 		if (deque->len != n) {
-			PyErr_SetString(PyExc_IndexError, 
+			PyErr_SetString(PyExc_IndexError,
 				"deque mutated during remove().");
 			return NULL;
 		}
@@ -920,7 +920,7 @@
 				"deque mutated during iteration");
 		return NULL;
 	}
-	assert (!(it->b == it->deque->rightblock && 
+	assert (!(it->b == it->deque->rightblock &&
 		  it->index > it->deque->rightindex));
 
 	item = it->b->data[it->index];
@@ -1016,7 +1016,7 @@
 				"deque mutated during iteration");
 		return NULL;
 	}
-	assert (!(it->b == it->deque->leftblock && 
+	assert (!(it->b == it->deque->leftblock &&
 		  it->index < it->deque->leftindex));
 
 	item = it->b->data[it->index];
@@ -1117,7 +1117,7 @@
 static PyObject *
 defdict_reduce(defdictobject *dd)
 {
-	/* __reduce__ must returns a 5-tuple as follows:
+	/* __reduce__ must return a 5-tuple as follows:
 
 	   - factory function
 	   - tuple of args for the factory function
@@ -1155,6 +1155,7 @@
 	}
 	result = PyTuple_Pack(5, dd->dict.ob_type, args,
 			      Py_None, Py_None, items);
+	Py_DECREF(items);
 	Py_DECREF(args);
 	return result;
 }

Modified: python/branches/bcannon-sandboxing/Modules/config.c.in
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/config.c.in	(original)
+++ python/branches/bcannon-sandboxing/Modules/config.c.in	Wed Aug  2 00:51:44 2006
@@ -28,6 +28,7 @@
 extern void initimp(void);
 extern void initgc(void);
 extern void init_ast(void);
+extern void init_types(void);
 
 struct _inittab _PyImport_Inittab[] = {
 
@@ -42,6 +43,9 @@
 	/* This lives in Python/Python-ast.c */
 	{"_ast", init_ast},
 
+	/* This lives in Python/_types.c */
+	{"_types", init_types},
+
 	/* These entries are here for sys.builtin_module_names */
 	{"__main__", NULL},
 	{"__builtin__", NULL},

Modified: python/branches/bcannon-sandboxing/Modules/cryptmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/cryptmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/cryptmodule.c	Wed Aug  2 00:51:44 2006
@@ -5,6 +5,9 @@
 
 #include <sys/types.h>
 
+#ifdef __VMS
+#include <openssl/des.h>
+#endif
 
 /* Module crypt */
 
@@ -12,7 +15,9 @@
 static PyObject *crypt_crypt(PyObject *self, PyObject *args)
 {
 	char *word, *salt; 
+#ifndef __VMS
 	extern char * crypt(const char *, const char *);
+#endif
 
 	if (!PyArg_ParseTuple(args, "ss:crypt", &word, &salt)) {
 		return NULL;

Modified: python/branches/bcannon-sandboxing/Modules/dlmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/dlmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/dlmodule.c	Wed Aug  2 00:51:44 2006
@@ -5,6 +5,10 @@
 
 #include <dlfcn.h>
 
+#ifdef __VMS
+#include <unistd.h>
+#endif
+
 #ifndef RTLD_LAZY
 #define RTLD_LAZY 1
 #endif
@@ -186,6 +190,24 @@
 		PyErr_SetString(Dlerror, dlerror());
 		return NULL;
 	}
+#ifdef __VMS
+	/*   Under OpenVMS dlopen doesn't do any check, just save the name
+	 * for later use, so we have to check if the file is readable,
+	 * the name can be a logical or a file from SYS$SHARE.
+	 */
+	if (access(name, R_OK)) {
+		char fname[strlen(name) + 20];
+		strcpy(fname, "SYS$SHARE:");
+		strcat(fname, name);
+		strcat(fname, ".EXE");
+		if (access(fname, R_OK)) {
+			dlclose(handle);
+			PyErr_SetString(Dlerror,
+				"File not found or protection violation");
+			return NULL;
+		}
+	}
+#endif
 	return newdlobject(handle);
 }
 

Modified: python/branches/bcannon-sandboxing/Modules/expat/xmlparse.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/expat/xmlparse.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/expat/xmlparse.c	Wed Aug  2 00:51:44 2006
@@ -2552,8 +2552,6 @@
                                  (int)(dataPtr - (ICHAR *)dataBuf));
             if (s == next)
               break;
-            if (ps_parsing == XML_FINISHED || ps_parsing == XML_SUSPENDED)
-              break;
             *eventPP = s;
           }
         }

Modified: python/branches/bcannon-sandboxing/Modules/fcntlmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/fcntlmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/fcntlmodule.c	Wed Aug  2 00:51:44 2006
@@ -290,7 +290,7 @@
 "flock(fd, operation)\n\
 \n\
 Perform the lock operation op on file descriptor fd.  See the Unix \n\
-manual flock(3) for details.  (On some systems, this function is\n\
+manual page for flock(3) for details.  (On some systems, this function is\n\
 emulated using fcntl().)");
 
 
@@ -327,7 +327,7 @@
 			l.l_type = F_WRLCK;
 		else {
 			PyErr_SetString(PyExc_ValueError,
-					"unrecognized flock argument");
+					"unrecognized lockf argument");
 			return NULL;
 		}
 		l.l_start = l.l_len = 0;

Modified: python/branches/bcannon-sandboxing/Modules/fpectlmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/fpectlmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/fpectlmodule.c	Wed Aug  2 00:51:44 2006
@@ -70,6 +70,10 @@
 
 #if defined(__FreeBSD__)
 #  include <ieeefp.h>
+#elif defined(__VMS)
+#define __NEW_STARLET
+#include <starlet.h>
+#include <ieeedef.h>
 #endif
 
 #ifndef WANT_SIGFPE_HANDLER
@@ -190,6 +194,19 @@
 
 /*-- DEC ALPHA VMS --------------------------------------------------------*/
 #elif defined(__ALPHA) && defined(__VMS)
+	IEEE clrmsk;
+	IEEE setmsk;
+	clrmsk.ieee$q_flags =
+		IEEE$M_TRAP_ENABLE_UNF |  IEEE$M_TRAP_ENABLE_INE |
+		 IEEE$M_MAP_UMZ;
+	setmsk.ieee$q_flags =
+		IEEE$M_TRAP_ENABLE_INV | IEEE$M_TRAP_ENABLE_DZE |
+		IEEE$M_TRAP_ENABLE_OVF;
+	sys$ieee_set_fp_control(&clrmsk, &setmsk, 0);
+	PyOS_setsig(SIGFPE, handler);
+
+/*-- HP IA64 VMS --------------------------------------------------------*/
+#elif defined(__ia64) && defined(__VMS)
     PyOS_setsig(SIGFPE, handler);
 
 /*-- Cray Unicos ----------------------------------------------------------*/
@@ -244,6 +261,14 @@
 #ifdef __FreeBSD__
     fpresetsticky(fpgetsticky());
     fpsetmask(0);
+#elif defined(__VMS)
+	IEEE clrmsk;
+	 clrmsk.ieee$q_flags =
+		IEEE$M_TRAP_ENABLE_UNF |  IEEE$M_TRAP_ENABLE_INE |
+		IEEE$M_MAP_UMZ | IEEE$M_TRAP_ENABLE_INV |
+		IEEE$M_TRAP_ENABLE_DZE | IEEE$M_TRAP_ENABLE_OVF |
+		IEEE$M_INHERIT;
+	sys$ieee_set_fp_control(&clrmsk, 0, 0);
 #else
     fputs("Operation not implemented\n", stderr);
 #endif

Modified: python/branches/bcannon-sandboxing/Modules/getpath.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/getpath.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/getpath.c	Wed Aug  2 00:51:44 2006
@@ -97,19 +97,19 @@
 
 
 #ifndef VERSION
-#if defined(__VMS)
-#define VERSION "2_1"
-#else
 #define VERSION "2.1"
 #endif
-#endif
 
 #ifndef VPATH
 #define VPATH "."
 #endif
 
 #ifndef PREFIX
-#define PREFIX "/usr/local"
+#  ifdef __VMS
+#    define PREFIX ""
+#  else
+#    define PREFIX "/usr/local"
+#  endif
 #endif
 
 #ifndef EXEC_PREFIX

Modified: python/branches/bcannon-sandboxing/Modules/itertoolsmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/itertoolsmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/itertoolsmodule.c	Wed Aug  2 00:51:44 2006
@@ -357,7 +357,7 @@
 {
 	if (tdo->nextlink == NULL)
 		tdo->nextlink = teedataobject_new(tdo->it);
-	Py_INCREF(tdo->nextlink);
+	Py_XINCREF(tdo->nextlink);
 	return tdo->nextlink;
 }
 
@@ -468,7 +468,7 @@
 
 	if (to->index >= LINKCELLS) {
 		link = teedataobject_jumplink(to->dataobj);
-		Py_XDECREF(to->dataobj);
+		Py_DECREF(to->dataobj);
 		to->dataobj = (teedataobject *)link;
 		to->index = 0;
 	}
@@ -522,6 +522,12 @@
 	if (to == NULL) 
 		goto done;
 	to->dataobj = (teedataobject *)teedataobject_new(it);
+	if (!to->dataobj) {
+		PyObject_GC_Del(to);
+		to = NULL;
+		goto done;
+	}
+
 	to->index = 0;
 	to->weakreflist = NULL;
 	PyObject_GC_Track(to);

Modified: python/branches/bcannon-sandboxing/Modules/main.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/main.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/main.c	Wed Aug  2 00:51:44 2006
@@ -40,7 +40,7 @@
 static int  orig_argc;
 
 /* command line options */
-#define BASE_OPTS "c:dEhim:OQ:StuUvVW:xX"
+#define BASE_OPTS "c:dEhim:OQ:StuUvVW:xX?"
 
 #ifndef RISCOS
 #define PROGRAM_OPTS BASE_OPTS
@@ -62,7 +62,7 @@
 -c cmd : program passed in as string (terminates option list)\n\
 -d     : debug output from parser (also PYTHONDEBUG=x)\n\
 -E     : ignore environment variables (such as PYTHONPATH)\n\
--h     : print this help message and exit\n\
+-h     : print this help message and exit (also --help)\n\
 -i     : inspect interactively after running script, (also PYTHONINSPECT=x)\n\
          and force prompts, even if stdin does not appear to be a terminal\n\
 ";
@@ -78,7 +78,7 @@
 static char *usage_3 = "\
          see man page for details on internal buffering relating to '-u'\n\
 -v     : verbose (trace import statements) (also PYTHONVERBOSE=x)\n\
--V     : print the Python version number and exit\n\
+-V     : print the Python version number and exit (also --version)\n\
 -W arg : warning control (arg is action:message:category:module:lineno)\n\
 -x     : skip first line of source, allowing use of non-Unix forms of #!cmd\n\
 file   : program read from script file\n\
@@ -313,6 +313,7 @@
 			Py_UnicodeFlag++;
 			break;
 		case 'h':
+		case '?':
 			help++;
 			break;
 		case 'V':

Modified: python/branches/bcannon-sandboxing/Modules/posixmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/posixmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/posixmodule.c	Wed Aug  2 00:51:44 2006
@@ -1862,6 +1862,15 @@
 				Py_BEGIN_ALLOW_THREADS
 				result = FindNextFileW(hFindFile, &wFileData);
 				Py_END_ALLOW_THREADS
+				/* FindNextFile sets error to ERROR_NO_MORE_FILES if
+				   it got to the end of the directory. */
+				if (!result && GetLastError() != ERROR_NO_MORE_FILES) {
+				    Py_DECREF(d);
+				    win32_error_unicode("FindNextFileW", wnamebuf);
+				    FindClose(hFindFile);
+				    free(wnamebuf);
+				    return NULL;
+				}
 			} while (result == TRUE);
 
 			if (FindClose(hFindFile) == FALSE) {
@@ -1921,6 +1930,14 @@
 		Py_BEGIN_ALLOW_THREADS
 		result = FindNextFile(hFindFile, &FileData);
 		Py_END_ALLOW_THREADS
+		/* FindNextFile sets error to ERROR_NO_MORE_FILES if
+		   it got to the end of the directory. */
+		if (!result && GetLastError() != ERROR_NO_MORE_FILES) {
+		    Py_DECREF(d);
+		    win32_error("FindNextFile", namebuf);
+		    FindClose(hFindFile);
+		    return NULL;
+		}
 	} while (result == TRUE);
 
 	if (FindClose(hFindFile) == FALSE) {
@@ -7882,6 +7899,42 @@
 }
 #endif
 
+#ifdef __VMS
+/* Use openssl random routine */
+#include <openssl/rand.h>
+PyDoc_STRVAR(vms_urandom__doc__,
+"urandom(n) -> str\n\n\
+Return a string of n random bytes suitable for cryptographic use.");
+
+static PyObject*
+vms_urandom(PyObject *self, PyObject *args)
+{
+	int howMany;
+	PyObject* result;
+
+	/* Read arguments */
+	if (! PyArg_ParseTuple(args, "i:urandom", &howMany))
+		return NULL;
+	if (howMany < 0)
+		return PyErr_Format(PyExc_ValueError,
+				    "negative argument not allowed");
+
+	/* Allocate bytes */
+	result = PyString_FromStringAndSize(NULL, howMany);
+	if (result != NULL) {
+		/* Get random data */
+		if (RAND_pseudo_bytes((unsigned char*)
+				      PyString_AS_STRING(result),
+				      howMany) < 0) {
+			Py_DECREF(result);
+			return PyErr_Format(PyExc_ValueError,
+					    "RAND_pseudo_bytes");
+		}
+	}
+	return result;
+}
+#endif
+
 static PyMethodDef posix_methods[] = {
 	{"access",	posix_access, METH_VARARGS, posix_access__doc__},
 #ifdef HAVE_TTYNAME
@@ -8175,6 +8228,9 @@
  #ifdef MS_WINDOWS
  	{"urandom", win32_urandom, METH_VARARGS, win32_urandom__doc__},
  #endif
+ #ifdef __VMS
+ 	{"urandom", vms_urandom, METH_VARARGS, vms_urandom__doc__},
+ #endif
 	{NULL,		NULL}		 /* Sentinel */
 };
 

Modified: python/branches/bcannon-sandboxing/Modules/pyexpat.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/pyexpat.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/pyexpat.c	Wed Aug  2 00:51:44 2006
@@ -238,6 +238,18 @@
     return 0;
 }
 
+/* Dummy character data handler used when an error (exception) has
+   been detected, and the actual parsing can be terminated early.
+   This is needed since character data handler can't be safely removed
+   from within the character data handler, but can be replaced.  It is
+   used only from the character data handler trampoline, and must be
+   used right after `flag_error()` is called. */
+static void
+noop_character_data_handler(void *userData, const XML_Char *data, int len) 
+{
+    /* Do nothing. */
+}
+
 static void
 flag_error(xmlparseobject *self)
 {
@@ -457,6 +469,8 @@
     if (temp == NULL) {
         Py_DECREF(args);
         flag_error(self);
+        XML_SetCharacterDataHandler(self->itself,
+                                    noop_character_data_handler);
         return -1;
     }
     PyTuple_SET_ITEM(args, 0, temp);
@@ -469,6 +483,8 @@
     Py_DECREF(args);
     if (temp == NULL) {
         flag_error(self);
+        XML_SetCharacterDataHandler(self->itself,
+                                    noop_character_data_handler);
         return -1;
     }
     Py_DECREF(temp);
@@ -1542,8 +1558,22 @@
         xmlhandler c_handler = NULL;
         PyObject *temp = self->handlers[handlernum];
 
-        if (v == Py_None)
+        if (v == Py_None) {
+            /* If this is the character data handler, and a character
+               data handler is already active, we need to be more
+               careful.  What we can safely do is replace the existing
+               character data handler callback function with a no-op
+               function that will refuse to call Python.  The downside
+               is that this doesn't completely remove the character
+               data handler from the C layer if there's any callback
+               active, so Expat does a little more work than it
+               otherwise would, but that's really an odd case.  A more
+               elaborate system of handlers and state could remove the
+               C handler more effectively. */
+            if (handlernum == CharacterData && self->in_callback)
+                c_handler = noop_character_data_handler;
             v = NULL;
+        }
         else if (v != NULL) {
             Py_INCREF(v);
             c_handler = handler_info[handlernum].handler;

Modified: python/branches/bcannon-sandboxing/Modules/readline.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/readline.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/readline.c	Wed Aug  2 00:51:44 2006
@@ -20,6 +20,12 @@
 #include <locale.h>
 #endif
 
+#ifdef SAVE_LOCALE
+#  define RESTORE_LOCALE(sl) { setlocale(LC_CTYPE, sl); free(sl); }
+#else
+#  define RESTORE_LOCALE(sl) 
+#endif
+
 /* GNU readline definitions */
 #undef HAVE_CONFIG_H /* Else readline/chardefs.h includes strings.h */
 #include <readline/readline.h>
@@ -723,10 +729,7 @@
 	 */
 	rl_initialize();
 
-#ifdef SAVE_LOCALE
-	setlocale(LC_CTYPE, saved_locale); /* Restore locale */
-	free(saved_locale);
-#endif
+	RESTORE_LOCALE(saved_locale)
 }
 
 /* Wrapper around GNU readline that handles signals differently. */
@@ -864,7 +867,8 @@
 	p = readline_until_enter_or_signal(prompt, &signal);
 	
 	/* we got an interrupt signal */
-	if(signal) {
+	if (signal) {
+		RESTORE_LOCALE(saved_locale)
 		return NULL;
 	}
 
@@ -873,6 +877,7 @@
 		p = PyMem_Malloc(1);
 		if (p != NULL)
 			*p = '\0';
+		RESTORE_LOCALE(saved_locale)
 		return p;
 	}
 
@@ -905,10 +910,7 @@
 		p[n+1] = '\0';
 	}
 	free(q);
-#ifdef SAVE_LOCALE
-	setlocale(LC_CTYPE, saved_locale); /* Restore locale */
-	free(saved_locale);
-#endif
+	RESTORE_LOCALE(saved_locale)
 	return p;
 }
 

Modified: python/branches/bcannon-sandboxing/Modules/selectmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/selectmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/selectmodule.c	Wed Aug  2 00:51:44 2006
@@ -46,14 +46,14 @@
 #endif
 
 #ifdef MS_WINDOWS
-#include <winsock.h>
+#  include <winsock.h>
 #else
-#ifdef __BEOS__
-#include <net/socket.h>
-#define SOCKET int
-#else
-#define SOCKET int
-#endif
+#  define SOCKET int
+#  ifdef __BEOS__
+#    include <net/socket.h>
+#  elif defined(__VMS)
+#    include <socket.h>
+#  endif
 #endif
 
 
@@ -668,7 +668,7 @@
 that are ready.\n\
 \n\
 *** IMPORTANT NOTICE ***\n\
-On Windows, only sockets are supported; on Unix, all file descriptors.");
+On Windows and OpenVMS, only sockets are supported; on Unix, all file descriptors.");
 
 static PyMethodDef select_methods[] = {
     {"select",	select_select, METH_VARARGS, select_doc},
@@ -682,7 +682,7 @@
 "This module supports asynchronous I/O on multiple file descriptors.\n\
 \n\
 *** IMPORTANT NOTICE ***\n\
-On Windows, only sockets are supported; on Unix, all file descriptors.");
+On Windows and OpenVMS, only sockets are supported; on Unix, all file descriptors.");
 
 PyMODINIT_FUNC
 initselect(void)

Modified: python/branches/bcannon-sandboxing/Modules/socketmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/socketmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/socketmodule.c	Wed Aug  2 00:51:44 2006
@@ -161,7 +161,8 @@
    (this includes the getaddrinfo emulation) protect access with a lock. */
 #if defined(WITH_THREAD) && (defined(__APPLE__) || \
     (defined(__FreeBSD__) && __FreeBSD_version+0 < 503000) || \
-    defined(__OpenBSD__) || defined(__NetBSD__) || !defined(HAVE_GETADDRINFO))
+    defined(__OpenBSD__) || defined(__NetBSD__) || \
+    defined(__VMS) || !defined(HAVE_GETADDRINFO))
 #define USE_GETADDRINFO_LOCK
 #endif
 
@@ -186,15 +187,8 @@
 #endif
 
 #if defined(__VMS)
-#if ! defined(_SOCKADDR_LEN)
-#   ifdef getaddrinfo
-#      undef getaddrinfo
-#   endif
-#  include "TCPIP_IOCTL_ROUTINE"
-#else
 #  include <ioctl.h>
 #endif
-#endif
 
 #if defined(PYOS_OS2)
 # define  INCL_DOS
@@ -363,11 +357,6 @@
 #define SOCKETCLOSE close
 #endif
 
-#ifdef __VMS
-/* TCP/IP Services for VMS uses a maximum send/revc buffer length of 65535 */
-#define SEGMENT_SIZE 65535
-#endif
-
 #if defined(HAVE_BLUETOOTH_H) || defined(HAVE_BLUETOOTH_BLUETOOTH_H)
 #define USE_BLUETOOTH 1
 #if defined(__FreeBSD__)
@@ -378,6 +367,14 @@
 #define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr)
 #define _BT_L2_MEMB(sa, memb) ((sa)->l2cap_##memb)
 #define _BT_RC_MEMB(sa, memb) ((sa)->rfcomm_##memb)
+#elif defined(__NetBSD__)
+#define sockaddr_l2 sockaddr_bt
+#define sockaddr_rc sockaddr_bt
+#define sockaddr_sco sockaddr_bt
+#define _BT_SOCKADDR_MEMB(s, proto) &((s)->sock_addr)
+#define _BT_L2_MEMB(sa, memb) ((sa)->bt_##memb)
+#define _BT_RC_MEMB(sa, memb) ((sa)->bt_##memb)
+#define _BT_SCO_MEMB(sa, memb) ((sa)->bt_##memb)
 #else
 #define _BT_SOCKADDR_MEMB(s, proto) (&((s)->sock_addr).bt_##proto)
 #define _BT_L2_MEMB(sa, memb) ((sa)->l2_##memb)
@@ -386,6 +383,11 @@
 #endif
 #endif
 
+#ifdef __VMS
+/* TCP/IP Services for VMS uses a maximum send/recv buffer length */
+#define SEGMENT_SIZE (32 * 1024 -1)
+#endif
+
 /*
  * Constants for getnameinfo()
  */
@@ -417,14 +419,24 @@
    there has to be a circular reference. */
 static PyTypeObject sock_type;
 
-/* Can we call select() with this socket without a buffer overrun? */
+#if defined(HAVE_POLL_H)
+#include <poll.h>
+#elif defined(HAVE_SYS_POLL_H)
+#include <sys/poll.h>
+#endif
+
 #ifdef Py_SOCKET_FD_CAN_BE_GE_FD_SETSIZE
 /* Platform can select file descriptors beyond FD_SETSIZE */
 #define IS_SELECTABLE(s) 1
+#elif defined(HAVE_POLL)
+/* Instead of select(), we'll use poll() since poll() works on any fd. */
+#define IS_SELECTABLE(s) 1
+/* Can we call select() with this socket without a buffer overrun? */
 #else
 /* POSIX says selecting file descriptors beyond FD_SETSIZE
-   has undefined behaviour. */
-#define IS_SELECTABLE(s) ((s)->sock_fd < FD_SETSIZE)
+   has undefined behaviour.  If there's no timeout left, we don't have to
+   call select, so it's a safe, little white lie. */
+#define IS_SELECTABLE(s) ((s)->sock_fd < FD_SETSIZE || s->sock_timeout <= 0.0)
 #endif
 
 static PyObject*
@@ -620,6 +632,30 @@
 	return NULL;
 }
 
+#ifdef __VMS
+/* Function to send in segments */
+static int
+sendsegmented(int sock_fd, char *buf, int len, int flags)
+{
+	int n = 0;
+	int remaining = len;
+
+	while (remaining > 0) {
+		unsigned int segment;
+
+		segment = (remaining >= SEGMENT_SIZE ? SEGMENT_SIZE : remaining);
+		n = send(sock_fd, buf, segment, flags);
+		if (n < 0) {
+			return n;
+		}
+		remaining -= segment;
+		buf += segment;
+	} /* end while */
+
+	return len;
+}
+#endif
+
 /* Function to perform the setting of socket blocking mode
    internally. block = (1 | 0). */
 static int
@@ -644,8 +680,8 @@
 	ioctl(s->sock_fd, FIONBIO, (caddr_t)&block, sizeof(block));
 #elif defined(__VMS)
 	block = !block;
-	ioctl(s->sock_fd, FIONBIO, (char *)&block);
-#else  /* !PYOS_OS2 && !_VMS */
+	ioctl(s->sock_fd, FIONBIO, (unsigned int *)&block);
+#else  /* !PYOS_OS2 && !__VMS */
 	delay_flag = fcntl(s->sock_fd, F_GETFL, 0);
 	if (block)
 		delay_flag &= (~O_NONBLOCK);
@@ -668,7 +704,7 @@
 	return 1;
 }
 
-/* Do a select() on the socket, if necessary (sock_timeout > 0).
+/* Do a select()/poll() on the socket, if necessary (sock_timeout > 0).
    The argument writing indicates the direction.
    This does not raise an exception; we'll let our caller do that
    after they've reacquired the interpreter lock.
@@ -676,8 +712,6 @@
 static int
 internal_select(PySocketSockObject *s, int writing)
 {
-	fd_set fds;
-	struct timeval tv;
 	int n;
 
 	/* Nothing to do unless we're in timeout mode (not non-blocking) */
@@ -688,17 +722,37 @@
 	if (s->sock_fd < 0)
 		return 0;
 
-	/* Construct the arguments to select */
-	tv.tv_sec = (int)s->sock_timeout;
-	tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6);
-	FD_ZERO(&fds);
-	FD_SET(s->sock_fd, &fds);
-
-	/* See if the socket is ready */
-	if (writing)
-		n = select(s->sock_fd+1, NULL, &fds, NULL, &tv);
-	else
-		n = select(s->sock_fd+1, &fds, NULL, NULL, &tv);
+	/* Prefer poll, if available, since you can poll() any fd
+	 * which can't be done with select(). */
+#ifdef HAVE_POLL
+	{
+		struct pollfd pollfd;
+		int timeout;
+
+		pollfd.fd = s->sock_fd;
+		pollfd.events = writing ? POLLOUT : POLLIN;
+
+		/* s->sock_timeout is in seconds, timeout in ms */
+		timeout = (int)(s->sock_timeout * 1000 + 0.5); 
+		n = poll(&pollfd, 1, timeout);
+	}
+#else
+	{
+		/* Construct the arguments to select */
+		fd_set fds;
+		struct timeval tv;
+		tv.tv_sec = (int)s->sock_timeout;
+		tv.tv_usec = (int)((s->sock_timeout - tv.tv_sec) * 1e6);
+		FD_ZERO(&fds);
+		FD_SET(s->sock_fd, &fds);
+
+		/* See if the socket is ready */
+		if (writing)
+			n = select(s->sock_fd+1, NULL, &fds, NULL, &tv);
+		else
+			n = select(s->sock_fd+1, &fds, NULL, NULL, &tv);
+	}
+#endif
 	if (n == 0)
 		return 1;
 	return 0;
@@ -1725,6 +1779,8 @@
 		return PyInt_FromLong(flag);
 	}
 #ifdef __VMS
+	/* socklen_t is unsigned so no negative test is needed,
+	   test buflen == 0 is previously done */
 	if (buflen > 1024) {
 #else
 	if (buflen <= 0 || buflen > 1024) {
@@ -2251,7 +2307,7 @@
 	/* Call the guts */
 	outlen = sock_recv_guts(s, PyString_AS_STRING(buf), recvlen, flags);
 	if (outlen < 0) {
-		/* An error occured, release the string and return an
+		/* An error occurred, release the string and return an
 		   error. */
 		Py_DECREF(buf);
 		return NULL;
@@ -2498,9 +2554,6 @@
 {
 	char *buf;
 	int len, n = 0, flags = 0, timeout;
-#ifdef __VMS
-	int send_length;
-#endif
 
 	if (!PyArg_ParseTuple(args, "s#|i:send", &buf, &len, &flags))
 		return NULL;
@@ -2508,11 +2561,14 @@
 	if (!IS_SELECTABLE(s))
 		return select_error();
 
-#ifndef __VMS
 	Py_BEGIN_ALLOW_THREADS
 	timeout = internal_select(s, 1);
 	if (!timeout)
+#ifdef __VMS
+		n = sendsegmented(s->sock_fd, buf, len, flags);
+#else
 		n = send(s->sock_fd, buf, len, flags);
+#endif
 	Py_END_ALLOW_THREADS
 
 	if (timeout) {
@@ -2521,36 +2577,6 @@
 	}
 	if (n < 0)
 		return s->errorhandler();
-#else
-	/* Divide packet into smaller segments for	*/
-	/*  TCP/IP Services for OpenVMS			*/
-	send_length = len;
-	while (send_length != 0) {
-		unsigned int segment;
-
-		segment = send_length / SEGMENT_SIZE;
-		if (segment != 0) {
-			segment = SEGMENT_SIZE;
-		}
-		else {
-			segment = send_length;
-		}
-		Py_BEGIN_ALLOW_THREADS
-		timeout = internal_select(s, 1);
-		if (!timeout)
-			n = send(s->sock_fd, buf, segment, flags);
-		Py_END_ALLOW_THREADS
-		if (timeout) {
-			PyErr_SetString(socket_timeout, "timed out");
-			return NULL;
-		}
-		if (n < 0) {
-			return s->errorhandler();
-		}
-		send_length -= segment;
-		buf += segment;
-	} /* end while */
-#endif /* !__VMS */
 	return PyInt_FromLong((long)n);
 }
 
@@ -2581,7 +2607,11 @@
 		timeout = internal_select(s, 1);
 		if (timeout)
 			break;
+#ifdef __VMS
+		n = sendsegmented(s->sock_fd, buf, len, flags);
+#else
 		n = send(s->sock_fd, buf, len, flags);
+#endif
 		if (n < 0)
 			break;
 		buf += n;

Modified: python/branches/bcannon-sandboxing/Modules/timemodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/timemodule.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/timemodule.c	Wed Aug  2 00:51:44 2006
@@ -406,13 +406,35 @@
             indexing blindly into some array for a textual representation
             by some bad index (fixes bug #897625).
 
-            No check for year since handled in gettmarg().
+	    Also support values of zero from Python code for arguments in which
+	    that is out of range by forcing that value to the lowest value that
+	    is valid (fixed bug #1520914).
+
+	    Valid ranges based on what is allowed in struct tm:
+
+	    - tm_year: [0, max(int)] (1)
+	    - tm_mon: [0, 11] (2)
+	    - tm_mday: [1, 31]
+	    - tm_hour: [0, 23]
+	    - tm_min: [0, 59]
+	    - tm_sec: [0, 60]
+	    - tm_wday: [0, 6] (1)
+	    - tm_yday: [0, 365] (2)
+	    - tm_isdst: [-max(int), max(int)]
+
+	    (1) gettmarg() handles bounds-checking.
+	    (2) Python's acceptable range is one greater than the range in C,
+	        thus need to check against automatic decrement by gettmarg().
         */
-        if (buf.tm_mon < 0 || buf.tm_mon > 11) {
+	if (buf.tm_mon == -1)
+	    buf.tm_mon = 0;
+	else if (buf.tm_mon < 0 || buf.tm_mon > 11) {
             PyErr_SetString(PyExc_ValueError, "month out of range");
                         return NULL;
         }
-        if (buf.tm_mday < 1 || buf.tm_mday > 31) {
+	if (buf.tm_mday == 0)
+	    buf.tm_mday = 1;
+	else if (buf.tm_mday < 0 || buf.tm_mday > 31) {
             PyErr_SetString(PyExc_ValueError, "day of month out of range");
                         return NULL;
         }
@@ -434,7 +456,9 @@
             PyErr_SetString(PyExc_ValueError, "day of week out of range");
             return NULL;
         }
-        if (buf.tm_yday < 0 || buf.tm_yday > 365) {
+	if (buf.tm_yday == -1)
+	    buf.tm_yday = 0;
+	else if (buf.tm_yday < 0 || buf.tm_yday > 365) {
             PyErr_SetString(PyExc_ValueError, "day of year out of range");
             return NULL;
         }

Modified: python/branches/bcannon-sandboxing/Modules/unicodedata.c
==============================================================================
--- python/branches/bcannon-sandboxing/Modules/unicodedata.c	(original)
+++ python/branches/bcannon-sandboxing/Modules/unicodedata.c	Wed Aug  2 00:51:44 2006
@@ -395,6 +395,7 @@
     PyUnicodeObject *v;
     char decomp[256];
     int code, index, count, i;
+    unsigned int prefix_index;
 
     if (!PyArg_ParseTuple(args, "O!:decomposition",
 			  &PyUnicode_Type, &v))
@@ -428,9 +429,15 @@
     /* XXX: could allocate the PyString up front instead
        (strlen(prefix) + 5 * count + 1 bytes) */
 
+    /* Based on how index is calculated above and decomp_data is generated
+       from Tools/unicode/makeunicodedata.py, it should not be possible
+       to overflow decomp_prefix. */
+    prefix_index = decomp_data[index] & 255;
+    assert(prefix_index < (sizeof(decomp_prefix)/sizeof(*decomp_prefix)));
+
     /* copy prefix */
-    i = strlen(decomp_prefix[decomp_data[index] & 255]);
-    memcpy(decomp, decomp_prefix[decomp_data[index] & 255], i);
+    i = strlen(decomp_prefix[prefix_index]);
+    memcpy(decomp, decomp_prefix[prefix_index], i);
 
     while (count-- > 0) {
         if (i)

Modified: python/branches/bcannon-sandboxing/Objects/codeobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/codeobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/codeobject.c	Wed Aug  2 00:51:44 2006
@@ -556,6 +556,7 @@
            the line increments here, treating them as byte
            increments gets confusing, to say the least. */
 
+        bounds->ap_lower = 0;
         while (size > 0) {
                 if (addr + *p > lasti)
                         break;

Modified: python/branches/bcannon-sandboxing/Objects/complexobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/complexobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/complexobject.c	Wed Aug  2 00:51:44 2006
@@ -275,16 +275,16 @@
 {
 	char format[32];
 	if (v->cval.real == 0.) {
-		PyOS_snprintf(format, 32, "%%.%ig", precision);
-		PyOS_ascii_formatd(buf, bufsz, format, v->cval.imag);
-		strncat(buf, "j", bufsz);
+		PyOS_snprintf(format, sizeof(format), "%%.%ig", precision);
+		PyOS_ascii_formatd(buf, bufsz - 1, format, v->cval.imag);
+		strncat(buf, "j", 1);
 	} else {
 		char re[64], im[64];
 		/* Format imaginary part with sign, real part without */
-		PyOS_snprintf(format, 32, "%%.%ig", precision);
-		PyOS_ascii_formatd(re, 64, format, v->cval.real);
-		PyOS_snprintf(format, 32, "%%+.%ig", precision);
-		PyOS_ascii_formatd(im, 64, format, v->cval.imag);
+		PyOS_snprintf(format, sizeof(format), "%%.%ig", precision);
+		PyOS_ascii_formatd(re, sizeof(re), format, v->cval.real);
+		PyOS_snprintf(format, sizeof(format), "%%+.%ig", precision);
+		PyOS_ascii_formatd(im, sizeof(im), format, v->cval.imag);
 		PyOS_snprintf(buf, bufsz, "(%s%sj)", re, im);
 	}
 }

Modified: python/branches/bcannon-sandboxing/Objects/dictobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/dictobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/dictobject.c	Wed Aug  2 00:51:44 2006
@@ -599,6 +599,8 @@
 		PyErr_BadInternalCall();
 		return -1;
 	}
+	assert(key);
+	assert(value);
 	mp = (dictobject *)op;
 	if (PyString_CheckExact(key)) {
 		hash = ((PyStringObject *)key)->ob_shash;
@@ -647,6 +649,7 @@
 		PyErr_BadInternalCall();
 		return -1;
 	}
+	assert(key);
 	if (!PyString_CheckExact(key) ||
 	    (hash = ((PyStringObject *) key)->ob_shash) == -1) {
 		hash = PyObject_Hash(key);

Modified: python/branches/bcannon-sandboxing/Objects/fileobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/fileobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/fileobject.c	Wed Aug  2 00:51:44 2006
@@ -103,6 +103,7 @@
 fill_file_fields(PyFileObject *f, FILE *fp, PyObject *name, char *mode,
 		 int (*close)(FILE *))
 {
+	assert(name != NULL);
 	assert(f != NULL);
 	assert(PyFile_Check(f));
 	assert(f->f_fp == NULL);
@@ -111,7 +112,7 @@
 	Py_DECREF(f->f_mode);
 	Py_DECREF(f->f_encoding);
 
-        Py_INCREF (name);
+        Py_INCREF(name);
         f->f_name = name;
 
 	f->f_mode = PyString_FromString(mode);
@@ -126,7 +127,7 @@
 	Py_INCREF(Py_None);
 	f->f_encoding = Py_None;
 
-	if (f->f_name == NULL || f->f_mode == NULL)
+	if (f->f_mode == NULL)
 		return NULL;
 	f->f_fp = fp;
         f = dircheck(f);
@@ -278,7 +279,9 @@
 	PyFileObject *f = (PyFileObject *)PyFile_Type.tp_new(&PyFile_Type,
 							     NULL, NULL);
 	if (f != NULL) {
-                PyObject *o_name = PyString_FromString(name);
+		PyObject *o_name = PyString_FromString(name);
+		if (o_name == NULL)
+			return NULL;
 		if (fill_file_fields(f, fp, o_name, mode, close) == NULL) {
 			Py_DECREF(f);
 			f = NULL;
@@ -411,11 +414,11 @@
 	if (PyUnicode_Check(f->f_name)) {
 #ifdef Py_USING_UNICODE
 		PyObject *ret = NULL;
-		PyObject *name;
-		name = PyUnicode_AsUnicodeEscapeString(f->f_name);
+		PyObject *name = PyUnicode_AsUnicodeEscapeString(f->f_name);
+		const char *name_str = name ? PyString_AsString(name) : "?";
 		ret = PyString_FromFormat("<%s file u'%s', mode '%s' at %p>",
 				   f->f_fp == NULL ? "closed" : "open",
-				   PyString_AsString(name),
+				   name_str,
 				   PyString_AsString(f->f_mode),
 				   f);
 		Py_XDECREF(name);

Modified: python/branches/bcannon-sandboxing/Objects/frameobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/frameobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/frameobject.c	Wed Aug  2 00:51:44 2006
@@ -642,6 +642,7 @@
 		f->f_trace = NULL;
                 f->f_exc_type = f->f_exc_value = f->f_exc_traceback = NULL;
 	}
+	f->f_stacktop = f->f_valuestack;
 	f->f_builtins = builtins;
 	Py_XINCREF(back);
 	f->f_back = back;
@@ -672,7 +673,6 @@
 	f->f_lineno = code->co_firstlineno;
 	f->f_iblock = 0;
 
-        f->f_stacktop = f->f_valuestack;
 	_PyObject_GC_TRACK(f);
 	return f;
 }

Modified: python/branches/bcannon-sandboxing/Objects/funcobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/funcobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/funcobject.c	Wed Aug  2 00:51:44 2006
@@ -109,8 +109,8 @@
 	}
 	if (defaults == Py_None)
 		defaults = NULL;
-	else if (PyTuple_Check(defaults)) {
-		Py_XINCREF(defaults);
+	else if (defaults && PyTuple_Check(defaults)) {
+		Py_INCREF(defaults);
 	}
 	else {
 		PyErr_SetString(PyExc_SystemError, "non-tuple default args");
@@ -141,7 +141,7 @@
 	if (closure == Py_None)
 		closure = NULL;
 	else if (PyTuple_Check(closure)) {
-		Py_XINCREF(closure);
+		Py_INCREF(closure);
 	}
 	else {
 		PyErr_Format(PyExc_SystemError, 

Modified: python/branches/bcannon-sandboxing/Objects/listsort.txt
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/listsort.txt	(original)
+++ python/branches/bcannon-sandboxing/Objects/listsort.txt	Wed Aug  2 00:51:44 2006
@@ -494,7 +494,7 @@
    467-474, Austin, Texas, 25-27 January 1993.
 
 and it probably dates back to an earlier paper by Bentley and Yao.  The
-McIlory paper in particular has good analysis of a mergesort that's
+McIlroy paper in particular has good analysis of a mergesort that's
 probably strongly related to this one in its galloping strategy.
 
 

Modified: python/branches/bcannon-sandboxing/Objects/longobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/longobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/longobject.c	Wed Aug  2 00:51:44 2006
@@ -1203,7 +1203,7 @@
 	register PyLongObject *a = (PyLongObject *)aa;
 	PyStringObject *str;
 	Py_ssize_t i;
-	const Py_ssize_t size_a = ABS(a->ob_size);
+	Py_ssize_t size_a;
 	char *p;
 	int bits;
 	char sign = '\0';
@@ -1213,6 +1213,7 @@
 		return NULL;
 	}
 	assert(base >= 2 && base <= 36);
+	size_a = ABS(a->ob_size);
 
 	/* Compute a rough upper bound for the length of the string */
 	i = base;
@@ -3149,9 +3150,8 @@
 		: MAX(size_a, size_b);
 	z = _PyLong_New(size_z);
 	if (z == NULL) {
-		Py_XDECREF(a);
-		Py_XDECREF(b);
-		Py_XDECREF(z);
+		Py_DECREF(a);
+		Py_DECREF(b);
 		return NULL;
 	}
 

Modified: python/branches/bcannon-sandboxing/Objects/setobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/setobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/setobject.c	Wed Aug  2 00:51:44 2006
@@ -1380,12 +1380,12 @@
 	while (set_next(otherset, &pos, &entry)) {
 		int rv = set_discard_entry(so, entry);
 		if (rv == -1) {
-			Py_XDECREF(otherset);
+			Py_DECREF(otherset);
 			return NULL;
 		}
 		if (rv == DISCARD_NOTFOUND) {
 			if (set_add_entry(so, entry) == -1) {
-				Py_XDECREF(otherset);
+				Py_DECREF(otherset);
 				return NULL;
 			}
 		}
@@ -1797,7 +1797,7 @@
 PyDoc_STRVAR(set_doc,
 "set(iterable) --> set object\n\
 \n\
-Build an unordered collection.");
+Build an unordered collection of unique elements.");
 
 PyTypeObject PySet_Type = {
 	PyObject_HEAD_INIT(&PyType_Type)
@@ -1892,7 +1892,7 @@
 PyDoc_STRVAR(frozenset_doc,
 "frozenset(iterable) --> frozenset object\n\
 \n\
-Build an immutable unordered collection.");
+Build an immutable unordered collection of unique elements.");
 
 PyTypeObject PyFrozenSet_Type = {
 	PyObject_HEAD_INIT(&PyType_Type)

Modified: python/branches/bcannon-sandboxing/Objects/stringobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/stringobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/stringobject.c	Wed Aug  2 00:51:44 2006
@@ -1493,7 +1493,6 @@
 		j = i+pos;
 		SPLIT_ADD(s, i, j);
 		i = j + n;
-		
 	}
 #else
 	i = j = 0;
@@ -1589,7 +1588,7 @@
 		return NULL;
 
 	i = j = len-1;
-	
+
 	while (maxsplit-- > 0) {
 		RSKIP_SPACE(s, i);
 		if (i<0) break;
@@ -2465,11 +2464,11 @@
 }
 
 Py_LOCAL_INLINE(Py_ssize_t)
-countchar(char *target, int target_len, char c, Py_ssize_t maxcount)
+countchar(const char *target, int target_len, char c, Py_ssize_t maxcount)
 {
 	Py_ssize_t count=0;
-	char *start=target;
-	char *end=target+target_len;
+	const char *start=target;
+	const char *end=target+target_len;
 
 	while ( (start=findchar(start, end-start, c)) != NULL ) {
 		count++;
@@ -2481,8 +2480,8 @@
 }
 
 Py_LOCAL(Py_ssize_t)
-findstring(char *target, Py_ssize_t target_len,
-	   char *pattern, Py_ssize_t pattern_len,
+findstring(const char *target, Py_ssize_t target_len,
+	   const char *pattern, Py_ssize_t pattern_len,
 	   Py_ssize_t start,
 	   Py_ssize_t end,
 	   int direction)
@@ -2519,8 +2518,8 @@
 }
 
 Py_LOCAL_INLINE(Py_ssize_t)
-countstring(char *target, Py_ssize_t target_len,
-	    char *pattern, Py_ssize_t pattern_len,
+countstring(const char *target, Py_ssize_t target_len,
+	    const char *pattern, Py_ssize_t pattern_len,
 	    Py_ssize_t start,
 	    Py_ssize_t end,
 	    int direction, Py_ssize_t maxcount)
@@ -2573,22 +2572,21 @@
 /* len(self)>=1, from="", len(to)>=1, maxcount>=1 */
 Py_LOCAL(PyStringObject *)
 replace_interleave(PyStringObject *self,
-		   PyStringObject *to,
+		   const char *to_s, Py_ssize_t to_len,
 		   Py_ssize_t maxcount)
 {
-	char *self_s, *to_s, *result_s;
-	Py_ssize_t self_len, to_len, result_len;
+	char *self_s, *result_s;
+	Py_ssize_t self_len, result_len;
 	Py_ssize_t count, i, product;
 	PyStringObject *result;
 
 	self_len = PyString_GET_SIZE(self);
-	to_len = PyString_GET_SIZE(to);
-	
+
 	/* 1 at the end plus 1 after every character */
 	count = self_len+1;
 	if (maxcount < count) 
 		count = maxcount;
-	
+
 	/* Check for overflow */
 	/*   result_len = count * to_len + self_len; */
 	product = count * to_len;
@@ -2609,8 +2607,6 @@
 		return NULL;
 
 	self_s = PyString_AS_STRING(self);
-	to_s = PyString_AS_STRING(to);
-	to_len = PyString_GET_SIZE(to);
 	result_s = PyString_AS_STRING(result);
 
 	/* TODO: special case single character, which doesn't need memcpy */
@@ -2671,25 +2667,24 @@
 		start = next+1;
 	}
 	Py_MEMCPY(result_s, start, end-start);
-	
+
 	return result;
 }
 
 /* len(self)>=1, len(from)>=2, to="", maxcount>=1 */
 
 Py_LOCAL(PyStringObject *)
-replace_delete_substring(PyStringObject *self, PyStringObject *from,
+replace_delete_substring(PyStringObject *self,
+			 const char *from_s, Py_ssize_t from_len,
 			 Py_ssize_t maxcount) {
-	char *self_s, *from_s, *result_s;
+	char *self_s, *result_s;
 	char *start, *next, *end;
-	Py_ssize_t self_len, from_len, result_len;
+	Py_ssize_t self_len, result_len;
 	Py_ssize_t count, offset;
 	PyStringObject *result;
 
 	self_len = PyString_GET_SIZE(self);
 	self_s = PyString_AS_STRING(self);
-	from_len = PyString_GET_SIZE(from);
-	from_s = PyString_AS_STRING(from);
 
 	count = countstring(self_s, self_len,
 			    from_s, from_len,
@@ -2703,13 +2698,13 @@
 
 	result_len = self_len - (count * from_len);
 	assert (result_len>=0);
-	
+
 	if ( (result = (PyStringObject *)
 	      PyString_FromStringAndSize(NULL, result_len)) == NULL )
 		return NULL;
-	
+
 	result_s = PyString_AS_STRING(result);
-	
+
 	start = self_s;
 	end = self_s + self_len;
 	while (count-- > 0) {
@@ -2719,9 +2714,9 @@
 		if (offset == -1)
 			break;
 		next = start + offset;
-		
+
 		Py_MEMCPY(result_s, start, next-start);
-		
+
 		result_s += (next-start);
 		start = next+from_len;
 	}
@@ -2738,31 +2733,31 @@
 	char *self_s, *result_s, *start, *end, *next;
 	Py_ssize_t self_len;
 	PyStringObject *result;
-	
+
 	/* The result string will be the same size */
 	self_s = PyString_AS_STRING(self);
 	self_len = PyString_GET_SIZE(self);
-	
+
 	next = findchar(self_s, self_len, from_c);
-	
+
 	if (next == NULL) {
 		/* No matches; return the original string */
 		return return_self(self);
 	}
-	
+
 	/* Need to make a new string */
 	result = (PyStringObject *) PyString_FromStringAndSize(NULL, self_len);
 	if (result == NULL)
 		return NULL;
 	result_s = PyString_AS_STRING(result);
 	Py_MEMCPY(result_s, self_s, self_len);
-	
+
 	/* change everything in-place, starting with this one */
 	start =  result_s + (next-self_s);
 	*start = to_c;
 	start++;
 	end = result_s + self_len;
-	
+
 	while (--maxcount > 0) {
 		next = findchar(start, end-start, from_c);
 		if (next == NULL)
@@ -2770,40 +2765,35 @@
 		*next = to_c;
 		start = next+1;
 	}
-	
+
 	return result;
 }
 
 /* len(self)>=1, len(from)==len(to)>=2, maxcount>=1 */
 Py_LOCAL(PyStringObject *)
 replace_substring_in_place(PyStringObject *self,
-			   PyStringObject *from,
-			   PyStringObject *to,
+			   const char *from_s, Py_ssize_t from_len,
+			   const char *to_s, Py_ssize_t to_len,
 			   Py_ssize_t maxcount)
 {
 	char *result_s, *start, *end;
-	char *self_s, *from_s, *to_s;
-	Py_ssize_t self_len, from_len, offset;
+	char *self_s;
+	Py_ssize_t self_len, offset;
 	PyStringObject *result;
-	
+
 	/* The result string will be the same size */
-	
+
 	self_s = PyString_AS_STRING(self);
 	self_len = PyString_GET_SIZE(self);
-	
-	from_s = PyString_AS_STRING(from);
-	from_len = PyString_GET_SIZE(from);
-	to_s = PyString_AS_STRING(to);
-	
+
 	offset = findstring(self_s, self_len,
 			    from_s, from_len,
 			    0, self_len, FORWARD);
-	
 	if (offset == -1) {
 		/* No matches; return the original string */
 		return return_self(self);
 	}
-	
+
 	/* Need to make a new string */
 	result = (PyStringObject *) PyString_FromStringAndSize(NULL, self_len);
 	if (result == NULL)
@@ -2811,13 +2801,12 @@
 	result_s = PyString_AS_STRING(result);
 	Py_MEMCPY(result_s, self_s, self_len);
 
-	
 	/* change everything in-place, starting with this one */
 	start =  result_s + offset;
 	Py_MEMCPY(start, to_s, from_len);
 	start += from_len;
 	end = result_s + self_len;
-	
+
 	while ( --maxcount > 0) {
 		offset = findstring(start, end-start,
 				    from_s, from_len,
@@ -2827,7 +2816,7 @@
 		Py_MEMCPY(start+offset, to_s, from_len);
 		start += offset+from_len;
 	}
-	
+
 	return result;
 }
 
@@ -2835,28 +2824,24 @@
 Py_LOCAL(PyStringObject *)
 replace_single_character(PyStringObject *self,
 			 char from_c,
-			 PyStringObject *to,
+			 const char *to_s, Py_ssize_t to_len,
 			 Py_ssize_t maxcount)
 {
-	char *self_s, *to_s, *result_s;
+	char *self_s, *result_s;
 	char *start, *next, *end;
-	Py_ssize_t self_len, to_len, result_len;
+	Py_ssize_t self_len, result_len;
 	Py_ssize_t count, product;
 	PyStringObject *result;
-	
+
 	self_s = PyString_AS_STRING(self);
 	self_len = PyString_GET_SIZE(self);
-	
+
 	count = countchar(self_s, self_len, from_c, maxcount);
-	
 	if (count == 0) {
 		/* no matches, return unchanged */
 		return return_self(self);
 	}
-	
-	to_s = PyString_AS_STRING(to);
-	to_len = PyString_GET_SIZE(to);
-	
+
 	/* use the difference between current and new, hence the "-1" */
 	/*   result_len = self_len + count * (to_len-1)  */
 	product = count * (to_len-1);
@@ -2869,19 +2854,19 @@
 		PyErr_SetString(PyExc_OverflowError, "replace string is too long");
 		return NULL;
 	}
-	
+
 	if ( (result = (PyStringObject *)
 	      PyString_FromStringAndSize(NULL, result_len)) == NULL)
 		return NULL;
 	result_s = PyString_AS_STRING(result);
-	
+
 	start = self_s;
 	end = self_s + self_len;
 	while (count-- > 0) {
 		next = findchar(start, end-start, from_c);
 		if (next == NULL) 
 			break;
-		
+
 		if (next == start) {
 			/* replace with the 'to' */
 			Py_MEMCPY(result_s, to_s, to_len);
@@ -2898,27 +2883,25 @@
 	}
 	/* Copy the remainder of the remaining string */
 	Py_MEMCPY(result_s, start, end-start);
-	
+
 	return result;
 }
 
 /* len(self)>=1, len(from)>=2, len(to)>=2, maxcount>=1 */
 Py_LOCAL(PyStringObject *)
 replace_substring(PyStringObject *self,
-		  PyStringObject *from,
-		  PyStringObject *to,
+		  const char *from_s, Py_ssize_t from_len,
+		  const char *to_s, Py_ssize_t to_len,
 		  Py_ssize_t maxcount) {
-	char *self_s, *from_s, *to_s, *result_s;
+	char *self_s, *result_s;
 	char *start, *next, *end;
-	Py_ssize_t self_len, from_len, to_len, result_len;
+	Py_ssize_t self_len, result_len;
 	Py_ssize_t count, offset, product;
 	PyStringObject *result;
-	
+
 	self_s = PyString_AS_STRING(self);
 	self_len = PyString_GET_SIZE(self);
-	from_s = PyString_AS_STRING(from);
-	from_len = PyString_GET_SIZE(from);
-	
+
 	count = countstring(self_s, self_len,
 			    from_s, from_len,
 			    0, self_len, FORWARD, maxcount);
@@ -2926,10 +2909,7 @@
 		/* no matches, return unchanged */
 		return return_self(self);
 	}
-	
-	to_s = PyString_AS_STRING(to);
-	to_len = PyString_GET_SIZE(to);
-	
+
 	/* Check for overflow */
 	/*    result_len = self_len + count * (to_len-from_len) */
 	product = count * (to_len-from_len);
@@ -2942,12 +2922,12 @@
 		PyErr_SetString(PyExc_OverflowError, "replace string is too long");
 		return NULL;
 	}
-	
+
 	if ( (result = (PyStringObject *)
 	      PyString_FromStringAndSize(NULL, result_len)) == NULL)
 		return NULL;
 	result_s = PyString_AS_STRING(result);
-	
+
 	start = self_s;
 	end = self_s + self_len;
 	while (count-- > 0) {
@@ -2973,29 +2953,24 @@
 	}
 	/* Copy the remainder of the remaining string */
 	Py_MEMCPY(result_s, start, end-start);
-	
+
 	return result;
 }
 
 
 Py_LOCAL(PyStringObject *)
 replace(PyStringObject *self,
-	PyStringObject *from,
-	PyStringObject *to,
+	const char *from_s, Py_ssize_t from_len,
+	const char *to_s, Py_ssize_t to_len,
 	Py_ssize_t maxcount)
 {
-	Py_ssize_t from_len, to_len;
-	
 	if (maxcount < 0) {
 		maxcount = PY_SSIZE_T_MAX;
 	} else if (maxcount == 0 || PyString_GET_SIZE(self) == 0) {
 		/* nothing to do; return the original string */
 		return return_self(self);
 	}
-	
-	from_len = PyString_GET_SIZE(from);
-	to_len = PyString_GET_SIZE(to);
-	
+
 	if (maxcount == 0 ||
 	    (from_len == 0 && to_len == 0)) {
 		/* nothing to do; return the original string */
@@ -3003,12 +2978,12 @@
 	}
 
 	/* Handle zero-length special cases */
-	
+
 	if (from_len == 0) {
 		/* insert the 'to' string everywhere.   */
 		/*    >>> "Python".replace("", ".")     */
 		/*    '.P.y.t.h.o.n.'                   */
-		return replace_interleave(self, to, maxcount);
+		return replace_interleave(self, to_s, to_len, maxcount);
 	}
 
 	/* Except for "".replace("", "A") == "A" there is no way beyond this */
@@ -3022,9 +2997,9 @@
 		/* delete all occurances of 'from' string */
 		if (from_len == 1) {
 			return replace_delete_single_character(
-				self, PyString_AS_STRING(from)[0], maxcount);
+				self, from_s[0], maxcount);
 		} else {
-			return replace_delete_substring(self, from, maxcount);
+			return replace_delete_substring(self, from_s, from_len, maxcount);
 		}
 	}
 
@@ -3034,22 +3009,22 @@
 		if (from_len == 1) {
 			return replace_single_character_in_place(
 				self,
-				PyString_AS_STRING(from)[0],
-				PyString_AS_STRING(to)[0],
+				from_s[0],
+				to_s[0],
 				maxcount);
 		} else {
 			return replace_substring_in_place(
-				self, from, to, maxcount);
+				self, from_s, from_len, to_s, to_len, maxcount);
 		}
 	}
 
 	/* Otherwise use the more generic algorithms */
 	if (from_len == 1) {
-		return replace_single_character(self, PyString_AS_STRING(from)[0],
-						to, maxcount);
+		return replace_single_character(self, from_s[0],
+						to_s, to_len, maxcount);
 	} else {
 		/* len('from')>=2, len('to')>=1 */
-		return replace_substring(self, from, to, maxcount);
+		return replace_substring(self, from_s, from_len, to_s, to_len, maxcount);
 	}
 }
 
@@ -3065,37 +3040,39 @@
 {
 	Py_ssize_t count = -1;
 	PyObject *from, *to;
-	const char *tmp_s;
-	Py_ssize_t tmp_len;
+	const char *from_s, *to_s;
+	Py_ssize_t from_len, to_len;
 
 	if (!PyArg_ParseTuple(args, "OO|n:replace", &from, &to, &count))
 		return NULL;
 
 	if (PyString_Check(from)) {
-	  /* Can this be made a '!check' after the Unicode check? */
+		from_s = PyString_AS_STRING(from);
+		from_len = PyString_GET_SIZE(from);
 	}
 #ifdef Py_USING_UNICODE
 	if (PyUnicode_Check(from))
 		return PyUnicode_Replace((PyObject *)self,
 					 from, to, count);
 #endif
-	else if (PyObject_AsCharBuffer(from, &tmp_s, &tmp_len))
+	else if (PyObject_AsCharBuffer(from, &from_s, &from_len))
 		return NULL;
 
 	if (PyString_Check(to)) {
-	  /* Can this be made a '!check' after the Unicode check? */
+		to_s = PyString_AS_STRING(to);
+		to_len = PyString_GET_SIZE(to);
 	}
 #ifdef Py_USING_UNICODE
 	else if (PyUnicode_Check(to))
 		return PyUnicode_Replace((PyObject *)self,
 					 from, to, count);
 #endif
-	else if (PyObject_AsCharBuffer(to, &tmp_s, &tmp_len))
+	else if (PyObject_AsCharBuffer(to, &to_s, &to_len))
 		return NULL;
 
 	return (PyObject *)replace((PyStringObject *) self,
-				   (PyStringObject *) from,
-				   (PyStringObject *) to, count);
+				   from_s, from_len,
+				   to_s, to_len, count);
 }
 
 /** End DALKE **/

Modified: python/branches/bcannon-sandboxing/Objects/typeobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/typeobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/typeobject.c	Wed Aug  2 00:51:44 2006
@@ -3260,6 +3260,8 @@
 	if (PyDict_GetItemString(type->tp_dict, "__doc__") == NULL) {
 		if (type->tp_doc != NULL) {
 			PyObject *doc = PyString_FromString(type->tp_doc);
+			if (doc == NULL)
+				goto error;
 			PyDict_SetItemString(type->tp_dict, "__doc__", doc);
 			Py_DECREF(doc);
 		} else {

Modified: python/branches/bcannon-sandboxing/Objects/unicodeobject.c
==============================================================================
--- python/branches/bcannon-sandboxing/Objects/unicodeobject.c	(original)
+++ python/branches/bcannon-sandboxing/Objects/unicodeobject.c	Wed Aug  2 00:51:44 2006
@@ -7918,6 +7918,9 @@
     unicode_freelist = NULL;
     unicode_freelist_size = 0;
     unicode_empty = _PyUnicode_New(0);
+    if (!unicode_empty)
+	return;
+
     strcpy(unicode_default_encoding, "ascii");
     for (i = 0; i < 256; i++)
 	unicode_latin1[i] = NULL;

Modified: python/branches/bcannon-sandboxing/PC/_winreg.c
==============================================================================
--- python/branches/bcannon-sandboxing/PC/_winreg.c	(original)
+++ python/branches/bcannon-sandboxing/PC/_winreg.c	Wed Aug  2 00:51:44 2006
@@ -960,7 +960,9 @@
 		return NULL;
 	if (!PyHKEY_AsHKEY(obKey, &hKey, FALSE))
 		return NULL;
+	Py_BEGIN_ALLOW_THREADS
 	rc = RegConnectRegistry(szCompName, hKey, &retKey);
+	Py_END_ALLOW_THREADS
 	if (rc != ERROR_SUCCESS)
 		return PyErr_SetFromWindowsErrWithFunction(rc,
 							   "ConnectRegistry");

Modified: python/branches/bcannon-sandboxing/PC/config.c
==============================================================================
--- python/branches/bcannon-sandboxing/PC/config.c	(original)
+++ python/branches/bcannon-sandboxing/PC/config.c	Wed Aug  2 00:51:44 2006
@@ -67,6 +67,7 @@
 extern void init_subprocess(void);
 extern void init_lsprof(void);
 extern void init_ast(void);
+extern void init_types(void);
 
 /* tools/freeze/makeconfig.py marker for additional "extern" */
 /* -- ADDMODULE MARKER 1 -- */
@@ -161,6 +162,8 @@
         {"__builtin__", NULL},
         {"sys", NULL},
 	{"exceptions", NULL},
+        
+        {"_types", init_types},
 
         /* Sentinel */
         {0, 0}

Modified: python/branches/bcannon-sandboxing/PC/getpathp.c
==============================================================================
--- python/branches/bcannon-sandboxing/PC/getpathp.c	(original)
+++ python/branches/bcannon-sandboxing/PC/getpathp.c	Wed Aug  2 00:51:44 2006
@@ -297,6 +297,10 @@
 		}
 		RegCloseKey(subKey);
 	}
+
+	/* return null if no path to return */
+	if (dataSize == 0) goto done;
+
 	/* original datasize from RegQueryInfo doesn't include the \0 */
 	dataBuf = malloc((dataSize+1) * sizeof(TCHAR));
 	if (dataBuf) {

Modified: python/branches/bcannon-sandboxing/PC/os2emx/Makefile
==============================================================================
--- python/branches/bcannon-sandboxing/PC/os2emx/Makefile	(original)
+++ python/branches/bcannon-sandboxing/PC/os2emx/Makefile	Wed Aug  2 00:51:44 2006
@@ -2,15 +2,15 @@
 #
 # Top-Level Makefile for Building Python 2.4 for OS/2 using GCC/EMX
 # Originally written by Andrew Zabolotny, <bit at eltech.ru> for Python 1.5.2
-# Modified by Andrew MacIntyre, <andymac at pcug.org.au> for Python 2.4
+# Modified by Andrew MacIntyre, <andymac at pcug.org.au> for Python 2.5
 #
 # This makefile was developed for use with [P]GCC/EMX compiler any
 # version and GNU Make.
 #
-# The output of the build is a largish Python24.DLL containing the
+# The output of the build is a largish Python25.DLL containing the
 # essential modules of Python and a small Python.exe program to start
 # the interpreter. When embedding Python within another program, only
-# Python24.DLL is needed. We also build python_s.a static library (which
+# Python25.DLL is needed. We also build python_s.a static library (which
 # can be converted into OMF (.lib) format using emxomf tool) and both
 # python.a and python.lib import libraries.  Then the optional 
 # extension modules, which are OS/2 DLLs renamed with a PYD file extension.
@@ -64,7 +64,7 @@
 
 # === install locations ===
 # default value of PYTHONHOME
-LIB_DIR=C:/Python24
+LIB_DIR=C:/Python25
 # default is to have everything in or under PYTHONHOME
 EXE_DIR=$(LIB_DIR)
 DLL_DIR=$(EXE_DIR)
@@ -236,8 +236,8 @@
 	@echo STACKSIZE 2097152 >>$@
 
 # Output file names
-PYTHON_VER=	2.4
-PYTHON_LIB=	python24
+PYTHON_VER=	2.5
+PYTHON_LIB=	python25
 PYTHON.LIB=	$(PYTHON_LIB)_s$A
 PYTHON.IMPLIB=	$(PYTHON_LIB)$A
 ifeq ($(EXEOMF),yes)
@@ -295,20 +295,23 @@
 		Modules/dlmodule.c \
 		Modules/errnomodule.c \
 		Modules/fcntlmodule.c \
+		Modules/_functoolsmodule.c \
 		Modules/_heapqmodule.c \
 		Modules/imageop.c \
 		Modules/itertoolsmodule.c \
 		Modules/_localemodule.c \
 		Modules/mathmodule.c \
-		Modules/md5c.c \
+		Modules/md5.c \
 		Modules/md5module.c \
 		Modules/operator.c \
 		Modules/_randommodule.c \
 		Modules/rgbimgmodule.c \
 		Modules/shamodule.c \
+		Modules/sha256module.c \
+		Modules/sha512module.c \
 		Modules/_sre.c \
 		Modules/stropmodule.c \
-		Modules/structmodule.c \
+		Modules/_struct.c \
 		Modules/symtablemodule.c \
 		Modules/termios.c \
 		Modules/timemodule.c \
@@ -331,6 +334,9 @@
 SRC.PARSER=	$(SRC.PARSE1) \
 		$(SRC.PARSE2)
 SRC.PYTHON=	$(addprefix $(TOP), \
+		Python/Python-ast.c \
+		Python/asdl.c \
+		Python/ast.c \
 		Python/bltinmodule.c \
 		Python/exceptions.c \
 		Python/ceval.c \
@@ -353,6 +359,7 @@
 		Python/modsupport.c \
 		Python/mysnprintf.c \
 		Python/mystrtoul.c \
+		Python/pyarena.c \
 		Python/pyfpe.c \
 		Python/pystate.c \
 		Python/pystrtod.c \
@@ -371,6 +378,7 @@
 		Objects/cellobject.c \
 		Objects/classobject.c \
 		Objects/cobject.c \
+		Objects/codeobject.c \
 		Objects/complexobject.c \
 		Objects/descrobject.c \
 		Objects/dictobject.c \

Modified: python/branches/bcannon-sandboxing/PC/os2emx/README.os2emx
==============================================================================
--- python/branches/bcannon-sandboxing/PC/os2emx/README.os2emx	(original)
+++ python/branches/bcannon-sandboxing/PC/os2emx/README.os2emx	Wed Aug  2 00:51:44 2006
@@ -612,22 +612,11 @@
 
 test_posixpath should skip these tests on EMX.
 
-24.  I have had a report that attempting to use the Bittorrent package
-(http://bitconjurer.org/BitTorrent/) with this port causes traps not
-long after starting the download; this using the "headless" download
-script on eCS v1.1.  I have not been able to duplicate this myself,
-but the indications I have suggest a failure in the 32 bit TCP/IP
-stack (v4.3.2? on eCS v1.1) - on my v4.0 FP12 system with MPTS fixpack
-WR8425 applied (16 bit TCP/IP stack v4.02), BitTorrent appears to work
-normally in testing on a 100Mbit LAN.  With the curses.panel fix (see
-item 13 above), the BitTorrent curses downloader works too.  I'd
-appreciate any success or failure reports with BitTorrent, though
-I've regretfully recommended that the person who reported the failure
-take this up with eCS support.  Since this report, I have received a 
-followup which suggests that the problem may be addressed by TCP/IP 
-fixes (IC35005+PJ29457, contained in NEWSTACK.ZIP in the Hobbes 
-archive).  I think it suffices to say that BitTorrent is a fair stress 
-test of a system's networking capability.
+24.  I have reports of BitTorrent not working.  It appears that the
+EMX select() emulation, possibly in concert with bugs in the TCP/IP
+stack, runs into problems under the stress imposed by this application.
+I think it suffices to say that BitTorrent is a fair stress test of a
+system's networking capability.
 
 25.  In the absence of an EMX implementation of the link() function, I've 
 implemented a crude Python emulation, in the file 
@@ -659,14 +648,16 @@
 
 29.  The default stack size for threads has been 64k.  This is proving
 insufficient for some codebases, such as Zope.  The thread stack size
-still defaults to 64k, but this can now be increased by defining
+still defaults to 64k, but this can now be increased via the stack_size()
+function exposed by the threading & thread modules as well as by defining
 THREAD_STACK_SIZE to an appropriate value in the Makefile (which contains
 a commented out definition for 128kB thread stacks).  I have seen
 references to heavy Zope/Plone usage requiring 1MB thread stacks on
 FreeBSD and Linux, but doubt that for most likely usage on OS/2 that
 more than 256kB is necessary.  The size of the required stacks (main 
 and thread) can vary significantly depending on which version of gcc
-is used along with the compiler optimisations selected.
+is used along with the compiler optimisations selected.  Note that the
+main thread stack size is set during linking and is currently 2MB.
 
 ... probably other issues that I've not encountered, or don't remember :-(
 
@@ -707,4 +698,4 @@
 E-mail: andymac at bullseye.apana.org.au, or andymac at pcug.org.au
 Web:    http://www.andymac.org/
 
-17 February, 2005.
+23 July, 2006.

Modified: python/branches/bcannon-sandboxing/PC/os2emx/config.c
==============================================================================
--- python/branches/bcannon-sandboxing/PC/os2emx/config.c	(original)
+++ python/branches/bcannon-sandboxing/PC/os2emx/config.c	Wed Aug  2 00:51:44 2006
@@ -58,16 +58,19 @@
 extern void initdl();
 extern void initerrno();
 extern void initfcntl();
+extern void init_functools();
 extern void init_heapq();
 extern void initimageop();
 extern void inititertools();
 extern void initmath();
-extern void initmd5();
+extern void init_md5();
 extern void initoperator();
 extern void initrgbimg();
-extern void initsha();
+extern void init_sha();
+extern void init_sha256();
+extern void init_sha512();
 extern void initstrop();
-extern void initstruct();
+extern void init_struct();
 extern void inittermios();
 extern void inittime();
 extern void inittiming();
@@ -121,16 +124,19 @@
 	{"dl", initdl},
 	{"errno", initerrno},
 	{"fcntl", initfcntl},
+	{"_functools", init_functools},
 	{"_heapq", init_heapq},
 	{"imageop", initimageop},
 	{"itertools", inititertools},
 	{"math", initmath},
-	{"md5", initmd5},
+	{"_md5", init_md5},
 	{"operator", initoperator},
 	{"rgbimg", initrgbimg},
-	{"sha", initsha},
+	{"_sha", init_sha},
+	{"_sha256", init_sha256},
+	{"_sha512", init_sha512},
 	{"strop", initstrop},
-	{"struct", initstruct},
+	{"_struct", init_struct},
 	{"termios", inittermios},
 	{"time", inittime},
 	{"timing", inittiming},

Modified: python/branches/bcannon-sandboxing/PC/os2emx/pyconfig.h
==============================================================================
--- python/branches/bcannon-sandboxing/PC/os2emx/pyconfig.h	(original)
+++ python/branches/bcannon-sandboxing/PC/os2emx/pyconfig.h	Wed Aug  2 00:51:44 2006
@@ -46,6 +46,7 @@
 #define TCPIPV4		1
 #define USE_SOCKET	1
 #define socklen_t	int
+#define FD_SETSIZE	1024
 
 /* enable the Python object allocator */
 #define	WITH_PYMALLOC	1
@@ -61,6 +62,9 @@
 #define PY_UNICODE_TYPE	wchar_t
 #define Py_UNICODE_SIZE SIZEOF_SHORT
 
+/* EMX defines ssize_t */
+#define HAVE_SSIZE_T	1
+
 /* system capabilities */
 #define HAVE_TTYNAME	1
 #define HAVE_WAIT	1
@@ -137,6 +141,9 @@
 /* The number of bytes in a void *. */
 #define SIZEOF_VOID_P 4
 
+/* The number of bytes in a size_t. */
+#define SIZEOF_SIZE_T 4
+
 /* Define if you have the alarm function. */
 #define HAVE_ALARM 1
 

Deleted: /python/branches/bcannon-sandboxing/PC/os2emx/python24.def
==============================================================================
--- /python/branches/bcannon-sandboxing/PC/os2emx/python24.def	Wed Aug  2 00:51:44 2006
+++ (empty file)
@@ -1,1173 +0,0 @@
-LIBRARY python24 INITINSTANCE TERMINSTANCE 
-DESCRIPTION "Python 2.4 Core DLL" 
-PROTMODE 
-DATA MULTIPLE NONSHARED 
-EXPORTS 
-
-; From python24_s.lib(config)
-  "_PyImport_Inittab"
-
-; From python24_s.lib(dlfcn)
-;  "dlopen"
-;  "dlsym"
-;  "dlclose"
-;  "dlerror"
-
-; From python24_s.lib(getpathp)
-  "Py_GetProgramFullPath"
-  "Py_GetPrefix"
-  "Py_GetExecPrefix"
-  "Py_GetPath"
-
-; From python24_s.lib(getbuildinfo)
-  "Py_GetBuildInfo"
-
-; From python24_s.lib(main)
-  "Py_Main"
-  "Py_GetArgcArgv"
-
-; From python24_s.lib(acceler)
-  "PyGrammar_AddAccelerators"
-  "PyGrammar_RemoveAccelerators"
-
-; From python24_s.lib(grammar1)
-  "PyGrammar_FindDFA"
-  "PyGrammar_LabelRepr"
-
-; From python24_s.lib(listnode)
-  "PyNode_ListTree"
-
-; From python24_s.lib(node)
-  "PyNode_AddChild"
-  "PyNode_New"
-  "PyNode_Free"
-
-; From python24_s.lib(parser)
-  "PyParser_AddToken"
-  "PyParser_New"
-  "PyParser_Delete"
-
-; From python24_s.lib(parsetok)
-  "Py_TabcheckFlag"
-  "PyParser_ParseString"
-  "PyParser_ParseStringFlags"
-  "PyParser_ParseFile"
-  "PyParser_ParseFileFlags"
-  "PyParser_ParseStringFlagsFilename"
-
-; From python24_s.lib(bitset)
-  "_Py_newbitset"
-  "_Py_delbitset"
-  "_Py_addbit"
-  "_Py_samebitset"
-  "_Py_mergebitset"
-
-; From python24_s.lib(metagrammar)
-  "_Py_meta_grammar"
-  "Py_meta_grammar"
-
-; From python24_s.lib(tokenizer)
-  "PyToken_OneChar"
-  "PyToken_TwoChars"
-  "PyToken_ThreeChars"
-  "PyTokenizer_FromString"
-  "PyTokenizer_FromFile"
-  "PyTokenizer_Free"
-  "PyTokenizer_Get"
-  "_PyParser_TokenNames"
-
-; From python24_s.lib(myreadline)
-  "_PyOS_ReadlineTState"
-  "PyOS_ReadlineFunctionPointer"
-  "PyOS_StdioReadline"
-  "PyOS_Readline"
-  "PyOS_InputHook"
-
-; From python24_s.lib(abstract)
-  "PyObject_GetItem"
-  "PySequence_GetItem"
-  "PyObject_SetItem"
-  "PySequence_SetItem"
-  "PyObject_DelItem"
-  "PySequence_DelItem"
-  "PyNumber_Multiply"
-  "PyNumber_InPlaceAdd"
-  "PyNumber_InPlaceMultiply"
-  "PyNumber_Int"
-  "PyNumber_Long"
-  "PyNumber_Float"
-  "PySequence_GetSlice"
-  "PySequence_SetSlice"
-  "PySequence_Tuple"
-  "PyObject_GetIter"
-  "PyMapping_Size"
-  "PyIter_Next"
-  "_PySequence_IterSearch"
-  "PyObject_CallFunction"
-  "PyObject_CallMethod"
-  "PyObject_CallMethodObjArgs"
-  "PyObject_CallFunctionObjArgs"
-  "PyObject_Cmp"
-  "PyObject_Call"
-  "PyObject_CallObject"
-  "PyObject_Type"
-  "PyObject_Size"
-  "PyObject_Length"
-  "PyObject_DelItemString"
-  "PyObject_AsCharBuffer"
-  "PyObject_CheckReadBuffer"
-  "PyObject_AsReadBuffer"
-  "PyObject_AsWriteBuffer"
-  "PyNumber_Check"
-  "PyNumber_Add"
-  "PyNumber_Subtract"
-  "PyNumber_Divide"
-  "PyNumber_FloorDivide"
-  "PyNumber_TrueDivide"
-  "PyNumber_Remainder"
-  "PyNumber_Divmod"
-  "PyNumber_Power"
-  "PyNumber_Negative"
-  "PyNumber_Positive"
-  "PyNumber_Absolute"
-  "PyNumber_Invert"
-  "PyNumber_Lshift"
-  "PyNumber_Rshift"
-  "PyNumber_And"
-  "PyNumber_Xor"
-  "PyNumber_Or"
-  "PyNumber_InPlaceSubtract"
-  "PyNumber_InPlaceDivide"
-  "PyNumber_InPlaceFloorDivide"
-  "PyNumber_InPlaceTrueDivide"
-  "PyNumber_InPlaceRemainder"
-  "PyNumber_InPlacePower"
-  "PyNumber_InPlaceLshift"
-  "PyNumber_InPlaceRshift"
-  "PyNumber_InPlaceAnd"
-  "PyNumber_InPlaceXor"
-  "PyNumber_InPlaceOr"
-  "PySequence_Check"
-  "PySequence_Size"
-  "PySequence_Length"
-  "PySequence_Concat"
-  "PySequence_Repeat"
-  "PySequence_DelSlice"
-  "PySequence_List"
-  "PySequence_Fast"
-  "PySequence_Count"
-  "PySequence_Contains"
-  "PySequence_In"
-  "PySequence_Index"
-  "PySequence_InPlaceConcat"
-  "PySequence_InPlaceRepeat"
-  "PyMapping_Check"
-  "PyMapping_Length"
-  "PyMapping_HasKeyString"
-  "PyMapping_HasKey"
-  "PyMapping_GetItemString"
-  "PyMapping_SetItemString"
-  "PyObject_IsInstance"
-  "PyObject_IsSubclass"
-
-; From python24_s.lib(boolobject)
-  "PyBool_FromLong"
-  "PyBool_Type"
-  "_Py_ZeroStruct"
-  "_Py_TrueStruct"
-
-; From python24_s.lib(bufferobject)
-  "PyBuffer_FromObject"
-  "PyBuffer_FromReadWriteObject"
-  "PyBuffer_FromMemory"
-  "PyBuffer_FromReadWriteMemory"
-  "PyBuffer_New"
-  "PyBuffer_Type"
-
-; From python24_s.lib(cellobject)
-  "PyCell_New"
-  "PyCell_Get"
-  "PyCell_Set"
-  "PyCell_Type"
-
-; From python24_s.lib(classobject)
-  "PyClass_New"
-  "PyClass_IsSubclass"
-  "PyInstance_New"
-  "PyInstance_NewRaw"
-  "PyMethod_New"
-  "PyMethod_Function"
-  "PyMethod_Self"
-  "PyMethod_Class"
-  "_PyInstance_Lookup"
-  "PyMethod_Fini"
-  "PyClass_Type"
-  "PyInstance_Type"
-  "PyMethod_Type"
-
-; From python24_s.lib(cobject)
-  "PyCObject_FromVoidPtr"
-  "PyCObject_FromVoidPtrAndDesc"
-  "PyCObject_AsVoidPtr"
-  "PyCObject_GetDesc"
-  "PyCObject_Import"
-  "PyCObject_SetVoidPtr"
-  "PyCObject_Type"
-
-; From python24_s.lib(complexobject)
-  "_Py_c_pow"
-  "_Py_c_sum"
-  "_Py_c_diff"
-  "_Py_c_neg"
-  "_Py_c_prod"
-  "_Py_c_quot"
-  "PyComplex_FromCComplex"
-  "PyComplex_FromDoubles"
-  "PyComplex_RealAsDouble"
-  "PyComplex_ImagAsDouble"
-  "PyComplex_AsCComplex"
-  "PyComplex_Type"
-
-; From python24_s.lib(descrobject)
-  "PyWrapper_New"
-  "PyDescr_NewMethod"
-  "PyDescr_NewClassMethod"
-  "PyDescr_NewMember"
-  "PyDescr_NewGetSet"
-  "PyDescr_NewWrapper"
-  "PyDictProxy_New"
-  "PyWrapperDescr_Type"
-  "PyProperty_Type"
-
-; From python24_s.lib(dictobject)
-  "PyDict_New"
-  "PyDict_SetItem"
-  "PyDict_DelItem"
-  "PyDict_Clear"
-  "PyDict_MergeFromSeq2"
-  "PyDict_Merge"
-  "PyDict_Keys"
-  "PyDict_Values"
-  "PyDict_Contains"
-  "PyDict_GetItem"
-  "PyDict_Next"
-  "PyDict_Items"
-  "PyDict_Size"
-  "PyDict_Copy"
-  "PyDict_Update"
-  "PyDict_GetItemString"
-  "PyDict_SetItemString"
-  "PyDict_DelItemString"
-  "PyDict_Type"
-  "PyDictIterKey_Type"
-  "PyDictIterValue_Type"
-  "PyDictIterItem_Type"
-
-; From python24_s.lib(enumobject)
-  "PyEnum_Type"
-  "PyReversed_Type"
-
-; From python24_s.lib(fileobject)
-  "Py_UniversalNewlineFread"
-  "PyFile_GetLine"
-  "PyFile_SoftSpace"
-  "PyFile_WriteObject"
-  "PyFile_WriteString"
-  "PyObject_AsFileDescriptor"
-  "Py_UniversalNewlineFgets"
-  "PyFile_FromString"
-  "PyFile_SetBufSize"
-  "PyFile_SetEncoding"
-  "PyFile_FromFile"
-  "PyFile_AsFile"
-  "PyFile_Name"
-  "PyFile_Type"
-
-; From python24_s.lib(floatobject)
-  "PyFloat_FromString"
-  "PyFloat_AsDouble"
-  "PyFloat_Fini"
-  "_PyFloat_Pack4"
-  "_PyFloat_Pack8"
-  "PyFloat_FromDouble"
-  "PyFloat_AsReprString"
-  "PyFloat_AsString"
-  "_PyFloat_Unpack4"
-  "_PyFloat_Unpack8"
-  "PyFloat_AsStringEx"
-  "PyFloat_Type"
-
-; From python24_s.lib(frameobject)
-  "PyFrame_New"
-  "PyFrame_FastToLocals"
-  "PyFrame_LocalsToFast"
-  "_PyFrame_Init"
-  "PyFrame_Fini"
-  "PyFrame_BlockSetup"
-  "PyFrame_BlockPop"
-  "PyFrame_Type"
-
-; From python24_s.lib(funcobject)
-  "PyFunction_New"
-  "PyFunction_GetCode"
-  "PyFunction_GetGlobals"
-  "PyFunction_GetModule"
-  "PyFunction_GetDefaults"
-  "PyFunction_SetDefaults"
-  "PyFunction_GetClosure"
-  "PyFunction_SetClosure"
-  "PyClassMethod_New"
-  "PyStaticMethod_New"
-  "PyFunction_Type"
-  "PyClassMethod_Type"
-  "PyStaticMethod_Type"
-
-; From python24_s.lib(genobject)
-  "PyGen_New"
-  "PyGen_Type"
-
-; From python24_s.lib(intobject)
-  "PyInt_AsLong"
-  "PyInt_AsUnsignedLongMask"
-  "PyInt_AsUnsignedLongLongMask"
-  "PyInt_FromString"
-  "PyInt_Fini"
-  "PyInt_FromUnicode"
-  "PyInt_FromLong"
-  "PyInt_GetMax"
-  "_PyInt_Init"
-  "PyInt_Type"
-
-; From python24_s.lib(iterobject)
-  "PySeqIter_New"
-  "PyCallIter_New"
-  "PySeqIter_Type"
-  "PyCallIter_Type"
-
-; From python24_s.lib(listobject)
-  "PyList_New"
-  "PyList_Append"
-  "PyList_Size"
-  "PyList_GetItem"
-  "PyList_SetItem"
-  "PyList_Insert"
-  "PyList_GetSlice"
-  "PyList_SetSlice"
-  "PyList_Sort"
-  "PyList_Reverse"
-  "PyList_AsTuple"
-  "_PyList_Extend"
-  "PyList_Type"
-  "PyListIter_Type"
-  "PyListRevIter_Type"
-
-; From python24_s.lib(longobject)
-  "PyLong_FromDouble"
-  "PyLong_AsLong"
-  "PyLong_AsUnsignedLong"
-  "_PyLong_FromByteArray"
-  "_PyLong_AsByteArray"
-  "PyLong_AsDouble"
-  "PyLong_FromString"
-  "PyLong_FromLong"
-  "PyLong_FromUnsignedLong"
-  "PyLong_AsUnsignedLongMask"
-  "_PyLong_AsScaledDouble"
-  "PyLong_FromVoidPtr"
-  "PyLong_AsVoidPtr"
-  "PyLong_FromLongLong"
-  "PyLong_FromUnsignedLongLong"
-  "PyLong_AsLongLong"
-  "PyLong_AsUnsignedLongLong"
-  "PyLong_AsUnsignedLongLongMask"
-  "PyLong_FromUnicode"
-  "_PyLong_Sign"
-  "_PyLong_NumBits"
-  "_PyLong_New"
-  "_PyLong_Copy"
-  "PyLong_Type"
-
-; From python24_s.lib(methodobject)
-  "PyCFunction_Call"
-  "Py_FindMethodInChain"
-  "PyCFunction_GetFunction"
-  "PyCFunction_GetSelf"
-  "PyCFunction_GetFlags"
-  "Py_FindMethod"
-  "PyCFunction_NewEx"
-  "PyCFunction_Fini"
-  "PyCFunction_New"
-  "PyCFunction_Type"
-
-; From python24_s.lib(moduleobject)
-  "PyModule_New"
-  "_PyModule_Clear"
-  "PyModule_GetDict"
-  "PyModule_GetName"
-  "PyModule_GetFilename"
-  "PyModule_Type"
-
-; From python24_s.lib(object)
-  "Py_DivisionWarningFlag"
-  "PyObject_Str"
-  "PyObject_Repr"
-  "PyObject_Unicode"
-  "PyObject_GetAttr"
-  "PyObject_IsTrue"
-  "PyNumber_CoerceEx"
-  "PyObject_Compare"
-  "PyObject_RichCompare"
-  "_Py_HashDouble"
-  "PyObject_Hash"
-  "PyObject_SetAttr"
-  "PyObject_GenericGetAttr"
-  "PyObject_GenericSetAttr"
-  "PyCallable_Check"
-  "PyObject_Dir"
-  "PyMem_Malloc"
-  "PyMem_Realloc"
-  "PyMem_Free"
-  "PyObject_Print"
-  "_PyObject_Dump"
-  "PyObject_RichCompareBool"
-  "PyObject_GetAttrString"
-  "PyObject_SetAttrString"
-  "PyObject_HasAttrString"
-  "PyObject_HasAttr"
-  "_PyObject_GetDictPtr"
-  "PyObject_SelfIter"
-  "PyObject_Not"
-  "PyNumber_Coerce"
-  "Py_ReprEnter"
-  "Py_ReprLeave"
-  "_Py_HashPointer"
-  "Py_IncRef"
-  "Py_DecRef"
-  "_PyTrash_deposit_object"
-  "_PyTrash_destroy_chain"
-  "PyObject_Init"
-  "PyObject_InitVar"
-  "_PyObject_New"
-  "_PyObject_NewVar"
-  "_PyObject_Del"
-  "_Py_ReadyTypes"
-  "_Py_SwappedOp"
-  "_Py_NotImplementedStruct"
-  "_Py_NoneStruct"
-  "_Py_cobject_hack"
-  "_Py_abstract_hack"
-  "_PyTrash_delete_nesting"
-  "_PyTrash_delete_later"
-
-; From python24_s.lib(obmalloc)
-  "PyObject_Malloc"
-  "PyObject_Realloc"
-  "PyObject_Free"
-
-; From python24_s.lib(rangeobject)
-  "PyRange_New"
-  "PyRange_Type"
-
-; From python24_s.lib(setobject)
-  "PySet_Type"
-  "PyFrozenSet_Type"
-
-; From python24_s.lib(sliceobject)
-  "PySlice_GetIndices"
-  "PySlice_GetIndicesEx"
-  "PySlice_New"
-  "_Py_EllipsisObject"
-  "PySlice_Type"
-
-; From python24_s.lib(stringobject)
-  "PyString_FromStringAndSize"
-  "PyString_InternInPlace"
-  "PyString_FromString"
-  "PyString_FromFormatV"
-  "PyString_AsString"
-  "_PyString_Resize"
-  "PyString_FromFormat"
-  "PyString_AsDecodedString"
-  "PyString_AsEncodedString"
-  "PyString_DecodeEscape"
-  "PyString_Size"
-  "PyString_Repr"
-  "PyString_AsStringAndSize"
-  "_PyString_FormatLong"
-  "PyString_Format"
-  "_Py_ReleaseInternedStrings"
-  "PyString_Concat"
-  "PyString_ConcatAndDel"
-  "_PyString_Eq"
-  "PyString_InternImmortal"
-  "PyString_InternFromString"
-  "_PyString_Join"
-  "PyString_Decode"
-  "PyString_Encode"
-  "PyString_AsEncodedObject"
-  "PyString_AsDecodedObject"
-  "PyString_Fini"
-  "PyString_Type"
-  "PyBaseString_Type"
-
-; From python24_s.lib(structseq)
-  "PyStructSequence_InitType"
-  "PyStructSequence_New"
-  "PyStructSequence_UnnamedField"
-
-; From python24_s.lib(tupleobject)
-  "PyTuple_New"
-  "PyTuple_Pack"
-  "_PyTuple_Resize"
-  "PyTuple_Size"
-  "PyTuple_GetItem"
-  "PyTuple_SetItem"
-  "PyTuple_GetSlice"
-  "PyTuple_Fini"
-  "PyTuple_Type"
-  "PyTupleIter_Type"
-
-; From python24_s.lib(typeobject)
-  "PyType_IsSubtype"
-  "_PyType_Lookup"
-  "PyType_Ready"
-  "PyType_GenericAlloc"
-  "_PyObject_SlotCompare"
-  "PyType_GenericNew"
-  "PyType_Type"
-  "PyBaseObject_Type"
-  "PySuper_Type"
-
-; From python24_s.lib(unicodeobject)
-  "PyUnicodeUCS2_Resize"
-  "PyUnicodeUCS2_FromOrdinal"
-  "PyUnicodeUCS2_FromObject"
-  "PyUnicodeUCS2_FromEncodedObject"
-  "PyUnicodeUCS2_Decode"
-  "PyUnicodeUCS2_GetDefaultEncoding"
-  "PyUnicodeUCS2_DecodeUTF8"
-  "PyUnicodeUCS2_DecodeLatin1"
-  "PyUnicodeUCS2_DecodeASCII"
-  "PyUnicodeUCS2_AsEncodedString"
-  "PyUnicodeUCS2_AsUTF8String"
-  "PyUnicodeUCS2_AsLatin1String"
-  "PyUnicodeUCS2_AsASCIIString"
-  "PyUnicode_DecodeUTF7"
-  "PyUnicode_EncodeUTF7"
-  "PyUnicodeUCS2_DecodeUTF8Stateful"
-  "PyUnicodeUCS2_EncodeUTF8"
-  "PyUnicodeUCS2_DecodeUTF16Stateful"
-  "PyUnicodeUCS2_AsUTF16String"
-  "PyUnicodeUCS2_DecodeUnicodeEscape"
-  "PyUnicodeUCS2_DecodeRawUnicodeEscape"
-  "PyUnicodeUCS2_EncodeRawUnicodeEscape"
-  "PyUnicodeUCS2_DecodeCharmap"
-  "PyUnicodeUCS2_EncodeCharmap"
-  "PyUnicodeUCS2_TranslateCharmap"
-  "PyUnicodeUCS2_EncodeDecimal"
-  "PyUnicodeUCS2_Count"
-  "PyUnicodeUCS2_Find"
-  "PyUnicodeUCS2_Tailmatch"
-  "PyUnicodeUCS2_Join"
-  "PyUnicodeUCS2_Splitlines"
-  "PyUnicodeUCS2_Compare"
-  "PyUnicodeUCS2_Contains"
-  "PyUnicodeUCS2_Concat"
-  "_PyUnicode_XStrip"
-  "PyUnicodeUCS2_Replace"
-  "PyUnicodeUCS2_Split"
-  "PyUnicodeUCS2_RSplit"
-  "PyUnicodeUCS2_Format"
-  "_PyUnicodeUCS2_Fini"
-  "PyUnicodeUCS2_FromUnicode"
-  "PyUnicodeUCS2_AsUnicode"
-  "PyUnicodeUCS2_GetSize"
-  "PyUnicodeUCS2_GetMax"
-  "_PyUnicodeUCS2_AsDefaultEncodedString"
-  "PyUnicodeUCS2_SetDefaultEncoding"
-  "PyUnicodeUCS2_Encode"
-  "PyUnicodeUCS2_AsEncodedObject"
-  "PyUnicodeUCS2_DecodeUTF16"
-  "PyUnicodeUCS2_EncodeUTF16"
-  "PyUnicodeUCS2_AsUnicodeEscapeString"
-  "PyUnicodeUCS2_EncodeUnicodeEscape"
-  "PyUnicodeUCS2_AsRawUnicodeEscapeString"
-  "PyUnicodeUCS2_EncodeLatin1"
-  "PyUnicodeUCS2_EncodeASCII"
-  "PyUnicodeUCS2_AsCharmapString"
-  "PyUnicodeUCS2_Translate"
-  "PyUnicode_AsDecodedObject"
-  "_PyUnicodeUCS2_Init"
-  "PyUnicode_Type"
-
-; From python24_s.lib(unicodectype)
-  "_PyUnicode_TypeRecords"
-  "_PyUnicodeUCS2_ToNumeric"
-  "_PyUnicodeUCS2_IsLowercase"
-  "_PyUnicodeUCS2_IsUppercase"
-  "_PyUnicodeUCS2_IsTitlecase"
-  "_PyUnicodeUCS2_IsWhitespace"
-  "_PyUnicodeUCS2_IsLinebreak"
-  "_PyUnicodeUCS2_ToLowercase"
-  "_PyUnicodeUCS2_ToUppercase"
-  "_PyUnicodeUCS2_ToTitlecase"
-  "_PyUnicodeUCS2_ToDecimalDigit"
-  "_PyUnicodeUCS2_ToDigit"
-  "_PyUnicodeUCS2_IsDecimalDigit"
-  "_PyUnicodeUCS2_IsDigit"
-  "_PyUnicodeUCS2_IsNumeric"
-  "_PyUnicodeUCS2_IsAlpha"
-
-; From python24_s.lib(weakrefobject)
-  "PyWeakref_NewRef"
-  "PyWeakref_NewProxy"
-  "PyObject_ClearWeakRefs"
-  "PyWeakref_GetObject"
-  "_PyWeakref_GetWeakrefCount"
-  "_PyWeakref_ClearRef"
-  "_PyWeakref_RefType"
-  "_PyWeakref_ProxyType"
-  "_PyWeakref_CallableProxyType"
-
-; From python24_s.lib(bltinmodule)
-  "_PyBuiltin_Init"
-  "Py_FileSystemDefaultEncoding"
-
-; From python24_s.lib(exceptions)
-  "PyExc_Exception"
-  "PyExc_TypeError"
-  "PyExc_StopIteration"
-  "PyExc_StandardError"
-  "PyExc_SystemExit"
-  "PyExc_KeyboardInterrupt"
-  "PyExc_ImportError"
-  "PyExc_EnvironmentError"
-  "PyExc_IOError"
-  "PyExc_OSError"
-  "PyExc_EOFError"
-  "PyExc_RuntimeError"
-  "PyExc_NotImplementedError"
-  "PyExc_NameError"
-  "PyExc_UnboundLocalError"
-  "PyExc_AttributeError"
-  "PyExc_SyntaxError"
-  "PyExc_IndentationError"
-  "PyExc_TabError"
-  "PyExc_AssertionError"
-  "PyExc_LookupError"
-  "PyExc_IndexError"
-  "PyExc_KeyError"
-  "PyExc_ArithmeticError"
-  "PyExc_OverflowError"
-  "PyExc_ZeroDivisionError"
-  "PyExc_FloatingPointError"
-  "PyExc_ValueError"
-  "PyExc_UnicodeError"
-  "PyExc_UnicodeEncodeError"
-  "PyExc_UnicodeDecodeError"
-  "PyExc_UnicodeTranslateError"
-  "PyExc_ReferenceError"
-  "PyExc_SystemError"
-  "PyExc_MemoryError"
-  "PyExc_Warning"
-  "PyExc_UserWarning"
-  "PyExc_DeprecationWarning"
-  "PyExc_PendingDeprecationWarning"
-  "PyExc_SyntaxWarning"
-  "PyExc_OverflowWarning"
-  "PyExc_RuntimeWarning"
-  "PyExc_FutureWarning"
-  "PyExc_MemoryErrorInst"
-  "PyUnicodeEncodeError_GetStart"
-  "PyUnicodeDecodeError_GetStart"
-  "PyUnicodeEncodeError_GetEnd"
-  "PyUnicodeDecodeError_GetEnd"
-  "_PyExc_Init"
-  "_PyExc_Fini"
-  "PyUnicodeDecodeError_Create"
-  "PyUnicodeEncodeError_Create"
-  "PyUnicodeTranslateError_Create"
-  "PyUnicodeEncodeError_GetEncoding"
-  "PyUnicodeDecodeError_GetEncoding"
-  "PyUnicodeEncodeError_GetObject"
-  "PyUnicodeDecodeError_GetObject"
-  "PyUnicodeTranslateError_GetObject"
-  "PyUnicodeTranslateError_GetStart"
-  "PyUnicodeEncodeError_SetStart"
-  "PyUnicodeDecodeError_SetStart"
-  "PyUnicodeTranslateError_SetStart"
-  "PyUnicodeTranslateError_GetEnd"
-  "PyUnicodeEncodeError_SetEnd"
-  "PyUnicodeDecodeError_SetEnd"
-  "PyUnicodeTranslateError_SetEnd"
-  "PyUnicodeEncodeError_GetReason"
-  "PyUnicodeDecodeError_GetReason"
-  "PyUnicodeTranslateError_GetReason"
-  "PyUnicodeEncodeError_SetReason"
-  "PyUnicodeDecodeError_SetReason"
-  "PyUnicodeTranslateError_SetReason"
-
-; From python24_s.lib(ceval)
-  "PyEval_EvalFrame"
-  "PyEval_CallObjectWithKeywords"
-  "PyEval_EvalCodeEx"
-  "_PyEval_SliceIndex"
-  "PyEval_GetFrame"
-  "PyEval_CallObject"
-  "PyEval_SetProfile"
-  "PyEval_SetTrace"
-  "PyEval_GetBuiltins"
-  "PyEval_GetGlobals"
-  "PyEval_GetLocals"
-  "PyEval_GetRestricted"
-  "PyEval_MergeCompilerFlags"
-  "Py_FlushLine"
-  "Py_AddPendingCall"
-  "Py_MakePendingCalls"
-  "Py_SetRecursionLimit"
-  "Py_GetRecursionLimit"
-  "_Py_CheckRecursiveCall"
-  "PyEval_GetFuncName"
-  "PyEval_GetFuncDesc"
-  "PyEval_GetCallStats"
-  "PyEval_SaveThread"
-  "PyEval_RestoreThread"
-  "PyEval_InitThreads"
-  "PyEval_AcquireLock"
-  "PyEval_ReleaseLock"
-  "PyEval_AcquireThread"
-  "PyEval_ReleaseThread"
-  "PyEval_ReInitThreads"
-  "PyEval_EvalCode"
-  "_PyEval_CallTracing"
-  "_Py_CheckRecursionLimit"
-  "_Py_CheckInterval"
-  "_Py_Ticker"
-
-; From python24_s.lib(compile)
-  "PyCode_New"
-  "PySymtable_Free"
-  "PyNode_Compile"
-  "PyNode_CompileFlags"
-  "PyCode_Addr2Line"
-  "_Py_Mangle"
-  "PyNode_CompileSymtable"
-  "Py_OptimizeFlag"
-  "PyCode_Type"
-
-; From python24_s.lib(codecs)
-  "_PyCodec_Lookup"
-  "PyCodec_StreamReader"
-  "PyCodec_StreamWriter"
-  "PyCodec_Encode"
-  "PyCodec_Decode"
-  "PyCodec_IgnoreErrors"
-  "PyCodec_ReplaceErrors"
-  "PyCodec_XMLCharRefReplaceErrors"
-  "PyCodec_BackslashReplaceErrors"
-  "PyCodec_Register"
-  "PyCodec_Encoder"
-  "PyCodec_Decoder"
-  "PyCodec_RegisterError"
-  "PyCodec_LookupError"
-  "PyCodec_StrictErrors"
-
-; From python24_s.lib(errors)
-  "PyErr_SetNone"
-  "PyErr_SetString"
-  "PyErr_ExceptionMatches"
-  "PyErr_GivenExceptionMatches"
-  "PyErr_NormalizeException"
-  "PyErr_Fetch"
-  "PyErr_Clear"
-  "PyErr_NoMemory"
-  "PyErr_SetFromErrnoWithFilenameObject"
-  "PyErr_Format"
-  "PyErr_NewException"
-  "PyErr_WriteUnraisable"
-  "PyErr_SyntaxLocation"
-  "PyErr_ProgramText"
-  "PyErr_SetObject"
-  "PyErr_Occurred"
-  "PyErr_Restore"
-  "PyErr_BadArgument"
-  "PyErr_SetFromErrno"
-  "PyErr_SetFromErrnoWithFilename"
-  "PyErr_BadInternalCall"
-  "_PyErr_BadInternalCall"
-  "PyErr_Warn"
-  "PyErr_WarnExplicit"
-
-; From python24_s.lib(frozen)
-  "PyImport_FrozenModules"
-
-; From python24_s.lib(frozenmain)
-  "Py_FrozenMain"
-
-; From python24_s.lib(future)
-  "PyNode_Future"
-
-; From python24_s.lib(getargs)
-  "PyArg_Parse"
-  "PyArg_ParseTuple"
-  "PyArg_ParseTupleAndKeywords"
-  "PyArg_UnpackTuple"
-  "PyArg_VaParse"
-  "PyArg_VaParseTupleAndKeywords"
-
-; From python24_s.lib(getcompiler)
-  "Py_GetCompiler"
-
-; From python24_s.lib(getcopyright)
-  "Py_GetCopyright"
-
-; From python24_s.lib(getmtime)
-  "PyOS_GetLastModificationTime"
-
-; From python24_s.lib(getplatform)
-  "Py_GetPlatform"
-
-; From python24_s.lib(getversion)
-  "Py_GetVersion"
-
-; From python24_s.lib(graminit)
-  "_PyParser_Grammar"
-
-; From python24_s.lib(import)
-  "_PyImport_Init"
-  "_PyImportHooks_Init"
-  "PyImport_ImportModule"
-  "PyImport_Cleanup"
-  "_PyImport_FixupExtension"
-  "PyImport_AddModule"
-  "PyImport_ExecCodeModuleEx"
-  "PyImport_ImportFrozenModule"
-  "PyImport_ImportModuleEx"
-  "PyImport_ReloadModule"
-  "PyImport_Import"
-;  "initimp"
-  "_PyImport_Fini"
-  "PyImport_GetMagicNumber"
-  "PyImport_ExecCodeModule"
-  "PyImport_GetModuleDict"
-  "_PyImport_FindExtension"
-  "PyImport_AppendInittab"
-  "PyImport_ExtendInittab"
-  "PyImport_Inittab"
-  "_PyImport_Filetab"
-
-; From python24_s.lib(importdl)
-  "_PyImport_LoadDynamicModule"
-
-; From python24_s.lib(marshal)
-  "PyMarshal_ReadLongFromFile"
-  "PyMarshal_WriteObjectToString"
-  "PyMarshal_WriteLongToFile"
-  "PyMarshal_WriteObjectToFile"
-  "PyMarshal_ReadShortFromFile"
-  "PyMarshal_ReadObjectFromFile"
-  "PyMarshal_ReadLastObjectFromFile"
-  "PyMarshal_ReadObjectFromString"
-  "PyMarshal_Init"
-
-; From python24_s.lib(modsupport)
-  "Py_InitModule4"
-  "Py_BuildValue"
-  "Py_VaBuildValue"
-  "PyEval_CallFunction"
-  "PyEval_CallMethod"
-  "PyModule_AddObject"
-  "PyModule_AddIntConstant"
-  "PyModule_AddStringConstant"
-  "_Py_PackageContext"
-
-; From python24_s.lib(mysnprintf)
-  "PyOS_snprintf"
-  "PyOS_vsnprintf"
-
-; From python24_s.lib(mystrtoul)
-  "PyOS_strtoul"
-  "PyOS_strtol"
-
-; From python24_s.lib(pyfpe)
-  "PyFPE_dummy"
-
-; From python24_s.lib(pystate)
-  "PyInterpreterState_Clear"
-  "PyThreadState_Clear"
-  "PyGILState_Ensure"
-  "PyGILState_Release"
-  "PyInterpreterState_New"
-  "PyInterpreterState_Delete"
-  "PyThreadState_Delete"
-  "PyThreadState_New"
-  "PyThreadState_DeleteCurrent"
-  "PyThreadState_Get"
-  "PyThreadState_Swap"
-  "PyThreadState_GetDict"
-  "PyThreadState_SetAsyncExc"
-  "PyGILState_GetThisThreadState"
-  "PyInterpreterState_Head"
-  "PyInterpreterState_Next"
-  "PyInterpreterState_ThreadHead"
-  "PyThreadState_Next"
-  "_PyGILState_Init"
-  "_PyGILState_Fini"
-  "_PyThreadState_Current"
-  "_PyThreadState_GetFrame"
-
-; From python24_s.lib(pystrtod)
-  "PyOS_ascii_strtod"
-  "PyOS_ascii_formatd"
-  "PyOS_ascii_atof"
-
-; From python24_s.lib(pythonrun)
-  "Py_IgnoreEnvironmentFlag"
-  "Py_DebugFlag"
-  "Py_VerboseFlag"
-  "Py_NoSiteFlag"
-  "Py_InteractiveFlag"
-  "Py_FrozenFlag"
-  "Py_InitializeEx"
-  "Py_FatalError"
-  "Py_NewInterpreter"
-  "PyErr_Print"
-  "PyRun_InteractiveOneFlags"
-  "PyRun_SimpleFileExFlags"
-  "PyRun_FileExFlags"
-  "Py_Exit"
-  "PyErr_PrintEx"
-  "PyErr_Display"
-  "Py_SetProgramName"
-  "Py_GetProgramName"
-  "Py_SetPythonHome"
-  "Py_GetPythonHome"
-  "Py_Initialize"
-  "Py_Finalize"
-  "Py_IsInitialized"
-  "Py_EndInterpreter"
-  "PyRun_AnyFile"
-  "PyRun_AnyFileExFlags"
-  "PyRun_AnyFileEx"
-  "PyRun_AnyFileFlags"
-  "Py_FdIsInteractive"
-  "PyRun_InteractiveLoopFlags"
-  "PyRun_SimpleString"
-  "PyRun_SimpleStringFlags"
-  "PyRun_StringFlags"
-  "PyRun_SimpleFile"
-  "PyRun_SimpleFileEx"
-  "PyRun_InteractiveOne"
-  "PyRun_InteractiveLoop"
-  "PyParser_SimpleParseString"
-  "PyParser_SimpleParseFile"
-  "PyParser_SimpleParseStringFlags"
-  "PyParser_SimpleParseStringFlagsFilename"
-  "PyParser_SimpleParseFileFlags"
-  "PyRun_String"
-  "PyRun_File"
-  "PyRun_FileEx"
-  "PyRun_FileFlags"
-  "Py_CompileString"
-  "Py_CompileStringFlags"
-  "Py_SymtableString"
-  "Py_AtExit"
-  "PyOS_getsig"
-  "PyOS_setsig"
-  "PyParser_SetError"
-  "PyModule_GetWarningsModule"
-  "PyParser_SimpleParseStringFilename"
-  "Py_UseClassExceptionsFlag"
-  "Py_UnicodeFlag"
-  "_Py_QnewFlag"
-
-; From python24_s.lib(structmember)
-  "PyMember_Get"
-  "PyMember_GetOne"
-  "PyMember_SetOne"
-  "PyMember_Set"
-
-; From python24_s.lib(symtable)
-  "PySymtableEntry_New"
-  "PySymtableEntry_Type"
-
-; From python24_s.lib(sysmodule)
-  "_PySys_Init"
-  "PySys_SetPath"
-  "PySys_SetArgv"
-  "PySys_WriteStdout"
-  "PySys_WriteStderr"
-  "PySys_GetObject"
-  "PySys_SetObject"
-  "PySys_GetFile"
-  "PySys_ResetWarnOptions"
-  "PySys_AddWarnOption"
-
-; From python24_s.lib(traceback)
-  "PyTraceBack_Here"
-  "PyTraceBack_Print"
-  "PyTraceBack_Type"
-
-; From python24_s.lib(getopt)
-  "_PyOS_GetOpt"
-  "_PyOS_opterr"
-  "_PyOS_optind"
-  "_PyOS_optarg"
-
-; From python24_s.lib(dynload_shlib)
-  "_PyImport_DynLoadFiletab"
-  "_PyImport_GetDynLoadFunc"
-
-; From python24_s.lib(thread)
-  "PyThread_delete_key_value"
-  "PyThread_init_thread"
-  "PyThread_start_new_thread"
-  "PyThread_exit_thread"
-  "PyThread_get_thread_ident"
-  "PyThread_allocate_lock"
-  "PyThread_free_lock"
-  "PyThread_acquire_lock"
-  "PyThread_release_lock"
-  "PyThread_create_key"
-  "PyThread_delete_key"
-  "PyThread_set_key_value"
-  "PyThread_get_key_value"
-  "PyThread__exit_thread"
-
-; From python24_s.lib(gcmodule)
-;  "initgc"
-  "_PyObject_GC_New"
-  "_PyObject_GC_NewVar"
-  "PyGC_Collect"
-  "_PyObject_GC_Resize"
-  "_PyObject_GC_Malloc"
-  "PyObject_GC_Track"
-  "PyObject_GC_UnTrack"
-  "PyObject_GC_Del"
-  "_PyGC_Dump"
-  "_PyObject_GC_Track"
-  "_PyObject_GC_UnTrack"
-  "_PyObject_GC_Del"
-  "_PyGC_generation0"
-
-; From python24_s.lib(signalmodule)
-;  "initsignal"
-  "PyErr_CheckSignals"
-  "PyErr_SetInterrupt"
-  "PyOS_FiniInterrupts"
-  "PyOS_InterruptOccurred"
-  "PyOS_InitInterrupts"
-  "PyOS_AfterFork"
-
-; From python24_s.lib(posixmodule)
-;  "initos2"
-
-; From python24_s.lib(threadmodule)
-;  "initthread"
-
-; From python24_s.lib(arraymodule)
-;  "initarray"
-;  "array_methods"
-
-; From python24_s.lib(binascii)
-;  "initbinascii"
-
-; From python24_s.lib(cmathmodule)
-;  "initcmath"
-
-; From python24_s.lib(_codecsmodule)
-;  "init_codecs"
-
-; From python24_s.lib(collectionsmodule)
-;  "initcollections"
-  "dequeiter_type"
-  "dequereviter_type"
-
-; From python24_s.lib(cPickle)
-;  "initcPickle"
-;  "fast_save_leave"
-
-; From python24_s.lib(cStringIO)
-;  "initcStringIO"
-
-; From python24_s.lib(_csv)
-;  "init_csv"
-
-; From python24_s.lib(datetimemodule)
-;  "initdatetime"
-
-; From python24_s.lib(dlmodule)
-;  "initdl"
-
-; From python24_s.lib(errnomodule)
-;  "initerrno"
-
-; From python24_s.lib(fcntlmodule)
-;  "initfcntl"
-
-; From python24_s.lib(_heapqmodule)
-;  "init_heapq"
-
-; From python24_s.lib(imageop)
-;  "initimageop"
-
-; From python24_s.lib(itertoolsmodule)
-;  "inititertools"
-
-; From python24_s.lib(_localemodule)
-;  "init_locale"
-
-; From python24_s.lib(mathmodule)
-;  "initmath"
-
-; From python24_s.lib(md5c)
-;  "_Py_MD5Final"
-;  "_Py_MD5Init"
-;  "_Py_MD5Update"
-
-; From python24_s.lib(md5module)
-;  "initmd5"
-
-; From python24_s.lib(operator)
-;  "initoperator"
-
-; From python24_s.lib(_randommodule)
-;  "init_random"
-
-; From python24_s.lib(rgbimgmodule)
-;  "initrgbimg"
-
-; From python24_s.lib(shamodule)
-;  "initsha"
-
-; From python24_s.lib(_sre)
-;  "init_sre"
-
-; From python24_s.lib(stropmodule)
-;  "initstrop"
-
-; From python24_s.lib(structmodule)
-;  "initstruct"
-
-; From python24_s.lib(symtablemodule)
-;  "init_symtable"
-
-; From python24_s.lib(termios)
-;  "inittermios"
-
-; From python24_s.lib(timemodule)
-;  "inittime"
-  "_PyTime_DoubleToTimet"
-;  "inittimezone"
-
-; From python24_s.lib(timingmodule)
-;  "inittiming"
-
-; From python24_s.lib(_weakref)
-;  "init_weakref"
-
-; From python24_s.lib(xxsubtype)
-;  "initxxsubtype"
-
-; From python24_s.lib(zipimport)
-;  "initzipimport"

Modified: python/branches/bcannon-sandboxing/PC/winsound.c
==============================================================================
--- python/branches/bcannon-sandboxing/PC/winsound.c	(original)
+++ python/branches/bcannon-sandboxing/PC/winsound.c	Wed Aug  2 00:51:44 2006
@@ -37,10 +37,10 @@
 
 #include <windows.h>
 #include <mmsystem.h>
+#include <Python.h>
 #ifdef HAVE_CONIO_H
 #include <conio.h>	/* port functions on Win9x */
 #endif
-#include <Python.h>
 
 PyDoc_STRVAR(sound_playsound_doc,
 "PlaySound(sound, flags) - a wrapper around the Windows PlaySound API\n"
@@ -147,7 +147,7 @@
 			return NULL;
 		}
 	}
-#ifdef _M_IX86
+#if defined(_M_IX86) && defined(HAVE_CONIO_H)
 	else if (whichOS == Win9X) {
 		int speaker_state;
 		/* Force timer into oscillator mode via timer control port. */
@@ -172,7 +172,7 @@
 		/* Restore speaker control to original state. */
 		_outp(0x61, speaker_state);
 	}
-#endif /* _M_IX86 */
+#endif /* _M_IX86 && HAVE_CONIO_H */
 	else {
 		assert(!"winsound's whichOS has insane value");
 	}

Modified: python/branches/bcannon-sandboxing/PCbuild/_ssl.vcproj
==============================================================================
--- python/branches/bcannon-sandboxing/PCbuild/_ssl.vcproj	(original)
+++ python/branches/bcannon-sandboxing/PCbuild/_ssl.vcproj	Wed Aug  2 00:51:44 2006
@@ -21,8 +21,8 @@
 			ATLMinimizesCRunTimeLibraryUsage="FALSE">
 			<Tool
 				Name="VCNMakeTool"
-				BuildCommandLine="python build_ssl.py"
-				ReBuildCommandLine="python build_ssl.py -a"
+				BuildCommandLine="build_ssl.bat $(ConfigurationName)"
+				ReBuildCommandLine="build_ssl.bat $(ConfigurationName) -a"
 				CleanCommandLine="echo Nothing to do"
 				Output="_ssl.pyd"/>
 		</Configuration>
@@ -35,8 +35,8 @@
 			ATLMinimizesCRunTimeLibraryUsage="FALSE">
 			<Tool
 				Name="VCNMakeTool"
-				BuildCommandLine="python_d -u build_ssl.py -d"
-				ReBuildCommandLine="python_d -u build_ssl.py -d -a"
+				BuildCommandLine="build_ssl.bat $(ConfigurationName)"
+				ReBuildCommandLine="build_ssl.bat $(ConfigurationName) -a"
 				CleanCommandLine="echo Nothing to do"
 				Output="_ssl_d.pyd"/>
 		</Configuration>
@@ -49,8 +49,9 @@
 			ATLMinimizesCRunTimeLibraryUsage="FALSE">
 			<Tool
 				Name="VCNMakeTool"
-				BuildCommandLine="python build_ssl.py"
-				ReBuildCommandLine="python build_ssl.py -a"
+				BuildCommandLine="build_ssl.bat $(ConfigurationName)"
+				ReBuildCommandLine="build_ssl.bat $(ConfigurationName) -a"
+				CleanCommandLine="echo Nothing to do"
 				Output="_ssl.pyd"/>
 		</Configuration>
 		<Configuration
@@ -62,8 +63,9 @@
 			ATLMinimizesCRunTimeLibraryUsage="FALSE">
 			<Tool
 				Name="VCNMakeTool"
-				BuildCommandLine="python build_ssl.py"
-				ReBuildCommandLine="python build_ssl.py -a"
+				BuildCommandLine="build_ssl.bat $(ConfigurationName)"
+				ReBuildCommandLine="build_ssl.bat $(ConfigurationName) -a"
+				CleanCommandLine="echo Nothing to do"
 				Output="_ssl.pyd"/>
 		</Configuration>
 	</Configurations>

Modified: python/branches/bcannon-sandboxing/PCbuild/build_ssl.py
==============================================================================
--- python/branches/bcannon-sandboxing/PCbuild/build_ssl.py	(original)
+++ python/branches/bcannon-sandboxing/PCbuild/build_ssl.py	Wed Aug  2 00:51:44 2006
@@ -84,9 +84,59 @@
         print "Could not find an SSL directory in '%s'" % (sources,)
     return best_name
 
+def run_32all_py():
+    # ms\32all.bat will reconfigure OpenSSL and then try to build
+    # all outputs (debug/nondebug/dll/lib).  So we filter the file
+    # to exclude any "nmake" commands and then execute.
+    tempname = "ms\\32all_py.bat"
+
+    in_bat  = open("ms\\32all.bat")
+    temp_bat = open(tempname,"w")
+    while 1:
+        cmd = in_bat.readline()
+        print 'cmd', repr(cmd)
+        if not cmd: break
+        if cmd.strip()[:5].lower() == "nmake":
+            continue
+        temp_bat.write(cmd)
+    in_bat.close()
+    temp_bat.close()
+    os.system(tempname)
+    try:
+        os.remove(tempname)
+    except:
+        pass
+
+def run_configure(configure, do_script):
+    os.system("perl Configure "+configure)
+    os.system(do_script)
+
 def main():
-    debug = "-d" in sys.argv
     build_all = "-a" in sys.argv
+    if sys.argv[1] == "Release":
+        arch = "x86"
+        debug = False
+        configure = "VC-WIN32"
+        makefile = "32.mak"
+    elif sys.argv[1] == "Debug":
+        arch = "x86"
+        debug = True
+        configure = "VC-WIN32"
+        makefile="d32.mak"
+    elif sys.argv[1] == "ReleaseItanium":
+        arch = "ia64"
+        debug = False
+        configure = "VC-WIN64I"
+        do_script = "ms\\do_win64i"
+        makefile = "ms\\nt.mak"
+        os.environ["VSEXTCOMP_USECL"] = "MS_ITANIUM"
+    elif sys.argv[1] == "ReleaseAMD64":
+        arch="amd64"
+        debug=False
+        configure = "VC-WIN64A"
+        do_script = "ms\\do_win64a"
+        makefile = "ms\\nt.mak"
+        os.environ["VSEXTCOMP_USECL"] = "MS_OPTERON"
     make_flags = ""
     if build_all:
         make_flags = "-a"
@@ -107,49 +157,24 @@
     try:
         os.chdir(ssl_dir)
         # If the ssl makefiles do not exist, we invoke Perl to generate them.
-        if not os.path.isfile(os.path.join(ssl_dir, "32.mak")) or \
-           not os.path.isfile(os.path.join(ssl_dir, "d32.mak")):
+        if not os.path.isfile(makefile):
             print "Creating the makefiles..."
             # Put our working Perl at the front of our path
             os.environ["PATH"] = os.path.split(perl)[0] + \
                                           os.pathsep + \
                                           os.environ["PATH"]
-            # ms\32all.bat will reconfigure OpenSSL and then try to build
-            # all outputs (debug/nondebug/dll/lib).  So we filter the file
-            # to exclude any "nmake" commands and then execute.
-            tempname = "ms\\32all_py.bat"
-
-            in_bat  = open("ms\\32all.bat")
-            temp_bat = open(tempname,"w")
-            while 1:
-                cmd = in_bat.readline()
-                print 'cmd', repr(cmd)
-                if not cmd: break
-                if cmd.strip()[:5].lower() == "nmake":
-                    continue
-                temp_bat.write(cmd)
-            in_bat.close()
-            temp_bat.close()
-            os.system(tempname)
-            try:
-                os.remove(tempname)
-            except:
-                pass
+            if arch=="x86":
+                run_32all_py()
+            else:
+                run_configure(configure, do_script)
 
         # Now run make.
         print "Executing nmake over the ssl makefiles..."
-        if debug:
-            rc = os.system("nmake /nologo -f d32.mak")
-            if rc:
-                print "Executing d32.mak failed"
-                print rc
-                sys.exit(rc)
-        else:
-            rc = os.system("nmake /nologo -f 32.mak")
-            if rc:
-                print "Executing 32.mak failed"
-                print rc
-                sys.exit(rc)
+        rc = os.system("nmake /nologo -f "+makefile)
+        if rc:
+            print "Executing d32.mak failed"
+            print rc
+            sys.exit(rc)
     finally:
         os.chdir(old_cd)
     # And finally, we can build the _ssl module itself for Python.

Modified: python/branches/bcannon-sandboxing/PCbuild/pythoncore.vcproj
==============================================================================
--- python/branches/bcannon-sandboxing/PCbuild/pythoncore.vcproj	(original)
+++ python/branches/bcannon-sandboxing/PCbuild/pythoncore.vcproj	Wed Aug  2 00:51:44 2006
@@ -344,9 +344,6 @@
 			RelativePath="..\Modules\_bisectmodule.c">
 		</File>
 		<File
-			RelativePath="..\Modules\_struct.c">
-		</File>
-		<File
 			RelativePath="..\Modules\cjkcodecs\_codecs_cn.c">
 		</File>
 		<File
@@ -371,6 +368,9 @@
 			RelativePath="..\Modules\_csv.c">
 		</File>
 		<File
+			RelativePath="..\Modules\_functoolsmodule.c">
+		</File>
+		<File
 			RelativePath="..\Modules\_heapqmodule.c">
 		</File>
 		<File
@@ -389,9 +389,15 @@
 			RelativePath="..\Modules\_sre.c">
 		</File>
 		<File
+			RelativePath="..\Modules\_struct.c">
+		</File>
+		<File
 			RelativePath="..\Pc\_subprocess.c">
 		</File>
 		<File
+			RelativePath="..\Modules\_typesmodule.c">
+		</File>
+		<File
 			RelativePath="..\Modules\_weakref.c">
 		</File>
 		<File
@@ -515,9 +521,6 @@
 			RelativePath="..\Objects\funcobject.c">
 		</File>
 		<File
-			RelativePath="..\Modules\_functoolsmodule.c">
-		</File>
-		<File
 			RelativePath="..\Python\future.c">
 		</File>
 		<File

Modified: python/branches/bcannon-sandboxing/PCbuild/readme.txt
==============================================================================
--- python/branches/bcannon-sandboxing/PCbuild/readme.txt	(original)
+++ python/branches/bcannon-sandboxing/PCbuild/readme.txt	Wed Aug  2 00:51:44 2006
@@ -264,7 +264,7 @@
 In addition, you need the Visual Studio plugin for external C compilers,
 from http://sf.net/projects/vsextcomp. The plugin will wrap cl.exe, to
 locate the proper target compiler, and convert compiler options
-accordingly. The project files require atleast version 0.8.
+accordingly. The project files require atleast version 0.9.
 
 Building for AMD64
 ------------------

Modified: python/branches/bcannon-sandboxing/Python/ast.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/ast.c	(original)
+++ python/branches/bcannon-sandboxing/Python/ast.c	Wed Aug  2 00:51:44 2006
@@ -339,7 +339,7 @@
     /* The ast defines augmented store and load contexts, but the
        implementation here doesn't actually use them.  The code may be
        a little more complex than necessary as a result.  It also means
-       that expressions in an augmented assignment have no context.
+       that expressions in an augmented assignment have a Store context.
        Consider restructuring so that augmented assignment uses
        set_context(), too.
     */
@@ -387,6 +387,9 @@
         case GeneratorExp_kind:
             expr_name = "generator expression";
             break;
+        case Yield_kind:
+            expr_name = "yield expression";
+            break;
         case ListComp_kind:
             expr_name = "list comprehension";
             break;
@@ -619,10 +622,10 @@
     }
     args = (n_args ? asdl_seq_new(n_args, c->c_arena) : NULL);
     if (!args && n_args)
-    	return NULL; /* Don't need to go to NULL; nothing allocated */
+    	return NULL; /* Don't need to goto error; no objects allocated */
     defaults = (n_defaults ? asdl_seq_new(n_defaults, c->c_arena) : NULL);
     if (!defaults && n_defaults)
-        goto error;
+    	return NULL; /* Don't need to goto error; no objects allocated */
 
     /* fpdef: NAME | '(' fplist ')'
        fplist: fpdef (',' fpdef)* [',']
@@ -638,8 +641,11 @@
                    anything other than EQUAL or a comma? */
                 /* XXX Should NCH(n) check be made a separate check? */
                 if (i + 1 < NCH(n) && TYPE(CHILD(n, i + 1)) == EQUAL) {
-                    asdl_seq_SET(defaults, j++, 
-				    ast_for_expr(c, CHILD(n, i + 2)));
+                    expr_ty expression = ast_for_expr(c, CHILD(n, i + 2));
+                    if (!expression)
+                            goto error;
+                    assert(defaults != NULL);
+                    asdl_seq_SET(defaults, j++, expression);
                     i += 2;
 		    found_default = 1;
                 }
@@ -1484,6 +1490,57 @@
 }
 
 static expr_ty
+ast_for_factor(struct compiling *c, const node *n)
+{
+    node *pfactor, *ppower, *patom, *pnum;
+    expr_ty expression;
+
+    /* If the unary - operator is applied to a constant, don't generate
+       a UNARY_NEGATIVE opcode.  Just store the approriate value as a
+       constant.  The peephole optimizer already does something like
+       this but it doesn't handle the case where the constant is
+       (sys.maxint - 1).  In that case, we want a PyIntObject, not a
+       PyLongObject.
+    */
+    if (TYPE(CHILD(n, 0)) == MINUS
+        && NCH(n) == 2
+        && TYPE((pfactor = CHILD(n, 1))) == factor
+        && NCH(pfactor) == 1
+        && TYPE((ppower = CHILD(pfactor, 0))) == power
+        && NCH(ppower) == 1
+        && TYPE((patom = CHILD(ppower, 0))) == atom
+        && TYPE((pnum = CHILD(patom, 0))) == NUMBER) {
+        char *s = PyObject_MALLOC(strlen(STR(pnum)) + 2);
+        if (s == NULL)
+            return NULL;
+        s[0] = '-';
+        strcpy(s + 1, STR(pnum));
+        PyObject_FREE(STR(pnum));
+        STR(pnum) = s;
+        return ast_for_atom(c, patom);
+    }
+
+    expression = ast_for_expr(c, CHILD(n, 1));
+    if (!expression)
+        return NULL;
+
+    switch (TYPE(CHILD(n, 0))) {
+        case PLUS:
+            return UnaryOp(UAdd, expression, LINENO(n), n->n_col_offset,
+                           c->c_arena);
+        case MINUS:
+            return UnaryOp(USub, expression, LINENO(n), n->n_col_offset,
+                           c->c_arena);
+        case TILDE:
+            return UnaryOp(Invert, expression, LINENO(n),
+                           n->n_col_offset, c->c_arena);
+    }
+    PyErr_Format(PyExc_SystemError, "unhandled factor: %d",
+                 TYPE(CHILD(n, 0)));
+    return NULL;
+}
+
+static expr_ty
 ast_for_power(struct compiling *c, const node *n)
 {
     /* power: atom trailer* ('**' factor)*
@@ -1662,30 +1719,12 @@
 	    }
 	    return Yield(exp, LINENO(n), n->n_col_offset, c->c_arena);
 	}
-        case factor: {
-            expr_ty expression;
-            
+        case factor:
             if (NCH(n) == 1) {
                 n = CHILD(n, 0);
                 goto loop;
             }
-
-            expression = ast_for_expr(c, CHILD(n, 1));
-            if (!expression)
-                return NULL;
-
-            switch (TYPE(CHILD(n, 0))) {
-                case PLUS:
-                    return UnaryOp(UAdd, expression, LINENO(n), n->n_col_offset, c->c_arena);
-                case MINUS:
-                    return UnaryOp(USub, expression, LINENO(n), n->n_col_offset, c->c_arena);
-                case TILDE:
-                    return UnaryOp(Invert, expression, LINENO(n), n->n_col_offset, c->c_arena);
-            }
-            PyErr_Format(PyExc_SystemError, "unhandled factor: %d",
-	    		 TYPE(CHILD(n, 0)));
-            break;
-        }
+	    return ast_for_factor(c, n);
         case power:
             return ast_for_power(c, n);
         default:
@@ -1893,20 +1932,19 @@
         operator_ty newoperator;
 	node *ch = CHILD(n, 0);
 
-	if (TYPE(ch) == testlist)
-	    expr1 = ast_for_testlist(c, ch);
-	else
-	    expr1 = Yield(ast_for_expr(c, CHILD(ch, 0)), LINENO(ch), n->n_col_offset,
-                          c->c_arena);
-
+	expr1 = ast_for_testlist(c, ch);
         if (!expr1)
             return NULL;
-        /* TODO(jhylton): Figure out why set_context() can't be used here. */
+        /* TODO(nas): Remove duplicated error checks (set_context does it) */
         switch (expr1->kind) {
             case GeneratorExp_kind:
                 ast_error(ch, "augmented assignment to generator "
                           "expression not possible");
                 return NULL;
+            case Yield_kind:
+                ast_error(ch, "augmented assignment to yield "
+                          "expression not possible");
+                return NULL;
             case Name_kind: {
                 const char *var_name = PyString_AS_STRING(expr1->v.Name.id);
                 if (var_name[0] == 'N' && !strcmp(var_name, "None")) {
@@ -1923,12 +1961,13 @@
                           "assignment");
                 return NULL;
         }
+	set_context(expr1, Store, ch);
 
 	ch = CHILD(n, 2);
 	if (TYPE(ch) == testlist)
 	    expr2 = ast_for_testlist(c, ch);
 	else
-	    expr2 = Yield(ast_for_expr(c, ch), LINENO(ch), ch->n_col_offset, c->c_arena);
+	    expr2 = ast_for_expr(c, ch);
         if (!expr2)
             return NULL;
 
@@ -2142,7 +2181,14 @@
  loop:
     switch (TYPE(n)) {
         case import_as_name:
-            str = (NCH(n) == 3) ? NEW_IDENTIFIER(CHILD(n, 2)) : NULL;
+            str = NULL;
+            if (NCH(n) == 3) {
+                if (strcmp(STR(CHILD(n, 1)), "as") != 0) {
+                    ast_error(n, "must use 'as' in import");
+                    return NULL;
+                }
+                str = NEW_IDENTIFIER(CHILD(n, 2));
+            }
             return alias(NEW_IDENTIFIER(CHILD(n, 0)), str, c->c_arena);
         case dotted_as_name:
             if (NCH(n) == 1) {
@@ -2151,6 +2197,10 @@
             }
             else {
                 alias_ty a = alias_for_import_name(c, CHILD(n, 0));
+                if (strcmp(STR(CHILD(n, 1)), "as") != 0) {
+                    ast_error(n, "must use 'as' in import");
+                    return NULL;
+                }
                 assert(!a->asname);
                 a->asname = NEW_IDENTIFIER(CHILD(n, 2));
                 return a;
@@ -2621,6 +2671,7 @@
     asdl_seq *_target, *seq = NULL, *suite_seq;
     expr_ty expression;
     expr_ty target;
+    const node *node_target;
     /* for_stmt: 'for' exprlist 'in' testlist ':' suite ['else' ':' suite] */
     REQ(n, for_stmt);
 
@@ -2630,10 +2681,13 @@
             return NULL;
     }
 
-    _target = ast_for_exprlist(c, CHILD(n, 1), Store);
+    node_target = CHILD(n, 1);
+    _target = ast_for_exprlist(c, node_target, Store);
     if (!_target)
         return NULL;
-    if (asdl_seq_LEN(_target) == 1)
+    /* Check the # of children rather than the length of _target, since
+       for x, in ... has 1 element in _target, but still requires a Tuple. */
+    if (NCH(node_target) == 1)
 	target = (expr_ty)asdl_seq_GET(_target, 0);
     else
 	target = Tuple(_target, Store, LINENO(n), n->n_col_offset, c->c_arena);

Modified: python/branches/bcannon-sandboxing/Python/compile.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/compile.c	(original)
+++ python/branches/bcannon-sandboxing/Python/compile.c	Wed Aug  2 00:51:44 2006
@@ -300,8 +300,11 @@
 PyNode_Compile(struct _node *n, const char *filename)
 {
 	PyCodeObject *co = NULL;
+	mod_ty mod;
 	PyArena *arena = PyArena_New();
-	mod_ty mod = PyAST_FromNode(n, NULL, filename, arena);
+	if (!arena)
+		return NULL;
+	mod = PyAST_FromNode(n, NULL, filename, arena);
 	if (mod)
 		co = PyAST_Compile(mod, filename, NULL, arena);
 	PyArena_Free(arena);
@@ -615,8 +618,10 @@
 	unsigned int *blocks = (unsigned int *)PyMem_Malloc(len*sizeof(int));
 	int i,j, opcode, blockcnt = 0;
 
-	if (blocks == NULL)
+	if (blocks == NULL) {
+		PyErr_NoMemory();
 		return NULL;
+	}
 	memset(blocks, 0, len*sizeof(int));
 
 	/* Mark labels in the first pass */
@@ -1071,14 +1076,14 @@
 		PyObject_T_FREE("compiler", (void *)b);
 		b = next;
 	}
-	Py_XDECREF(u->u_ste);
-	Py_XDECREF(u->u_name);
-	Py_XDECREF(u->u_consts);
-	Py_XDECREF(u->u_names);
-	Py_XDECREF(u->u_varnames);
-	Py_XDECREF(u->u_freevars);
-	Py_XDECREF(u->u_cellvars);
-	Py_XDECREF(u->u_private);
+	Py_CLEAR(u->u_ste);
+	Py_CLEAR(u->u_name);
+	Py_CLEAR(u->u_consts);
+	Py_CLEAR(u->u_names);
+	Py_CLEAR(u->u_varnames);
+	Py_CLEAR(u->u_freevars);
+	Py_CLEAR(u->u_cellvars);
+	Py_CLEAR(u->u_private);
 	PyObject_T_FREE("compiler", u);
 }
 
@@ -1105,8 +1110,17 @@
 	u->u_name = name;
 	u->u_varnames = list2dict(u->u_ste->ste_varnames);
 	u->u_cellvars = dictbytype(u->u_ste->ste_symbols, CELL, 0, 0);
+	if (!u->u_varnames || !u->u_cellvars) {
+		compiler_unit_free(u);
+		return 0;
+	}
+
 	u->u_freevars = dictbytype(u->u_ste->ste_symbols, FREE, DEF_FREE_CLASS,
 				   PyDict_Size(u->u_cellvars));
+	if (!u->u_freevars) {
+		compiler_unit_free(u);
+		return 0;
+	}
 
 	u->u_blocks = NULL;
 	u->u_tmpname = 0;
@@ -1130,7 +1144,8 @@
 	/* Push the old compiler_unit on the stack. */
 	if (c->u) {
 		PyObject *wrapper = PyCObject_FromVoidPtr(c->u, NULL);
-		if (PyList_Append(c->c_stack, wrapper) < 0) {
+		if (!wrapper || PyList_Append(c->c_stack, wrapper) < 0) {
+			Py_XDECREF(wrapper);
 			compiler_unit_free(u);
 			return 0;
 		}
@@ -1256,6 +1271,7 @@
 		       sizeof(struct instr) * DEFAULT_BLOCK_SIZE);
 	}
 	else if (b->b_iused == b->b_ialloc) {
+		struct instr *tmp;
 		size_t oldsize, newsize;
 		oldsize = b->b_ialloc * sizeof(struct instr);
 		newsize = oldsize << 1;
@@ -1264,10 +1280,13 @@
 			return -1;
 		}
 		b->b_ialloc <<= 1;
-		b->b_instr = (struct instr *)PyObject_T_REALLOC("compiler",
+		tmp = (struct instr *)PyObject_T_REALLOC("compiler",
                                                 (void *)b->b_instr, newsize);
-		if (b->b_instr == NULL)
+		if (tmp == NULL) {
+			PyErr_NoMemory();
 			return -1;
+		}
+		b->b_instr = tmp;
 		memset((char *)b->b_instr + oldsize, 0, newsize - oldsize);
 	}
 	return b->b_iused++;
@@ -1776,7 +1795,8 @@
 		if (!module)
 			return NULL;
 	}
-	if (!compiler_enter_scope(c, module, mod, 1))
+	/* Use 0 for firstlineno initially, will fixup in assemble(). */
+	if (!compiler_enter_scope(c, module, mod, 0))
 		return NULL;
 	switch (mod->kind) {
 	case Module_kind: 
@@ -3011,6 +3031,7 @@
 		return 0;
 	s = e->v.BoolOp.values;
 	n = asdl_seq_LEN(s) - 1;
+	assert(n >= 0);
 	for (i = 0; i < n; ++i) {
 		VISIT(c, expr, (expr_ty)asdl_seq_GET(s, i));
 		ADDOP_JREL(c, jumpi, end);
@@ -3688,7 +3709,8 @@
 		VISIT(c, expr, auge);
 		break;
 	case Name_kind:
-		VISIT(c, expr, s->v.AugAssign.target);
+		if (!compiler_nameop(c, e->v.Name.id, Load))
+		    return 0;
 		VISIT(c, expr, s->v.AugAssign.value);
 		ADDOP(c, inplace_binop(c, s->v.AugAssign.op));
 		return compiler_nameop(c, e->v.Name.id, Store);
@@ -4001,6 +4023,8 @@
 		b->b_startdepth = INT_MIN;
 		entryblock = b;
 	}
+	if (!entryblock)
+		return 0;
 	return stackdepth_walk(c, entryblock, 0, 0);
 }
 
@@ -4096,9 +4120,10 @@
 
 In order for this to work, when the addr field increments by more than 255,
 the line # increment in each pair generated must be 0 until the remaining addr
-increment is < 256.  So, in the example above, com_set_lineno should not (as
-was actually done until 2.2) expand 300, 300 to 255, 255,  45, 45, but to
-255, 0,	 45, 255,  0, 45.
+increment is < 256.  So, in the example above, assemble_lnotab (it used
+to be called com_set_lineno) should not (as was actually done until 2.2)
+expand 300, 300 to 255, 255, 45, 45, 
+            but to 255,   0, 45, 255, 0, 45.
 */
 
 static int
@@ -4153,12 +4178,12 @@
 		}
 		lnotab = (unsigned char *)
 			   PyString_AS_STRING(a->a_lnotab) + a->a_lnotab_off;
-		*lnotab++ = 255;
 		*lnotab++ = d_bytecode;
+		*lnotab++ = 255;
 		d_bytecode = 0;
 		for (j = 1; j < ncodes; j++) {
-			*lnotab++ = 255;
 			*lnotab++ = 0;
+			*lnotab++ = 255;
 		}
 		d_lineno -= ncodes * 255;
 		a->a_lnotab_off += ncodes * 2;
@@ -4445,6 +4470,13 @@
 		entryblock = b; 
 	}
 
+	/* Set firstlineno if it wasn't explicitly set. */
+	if (!c->u->u_firstlineno) {
+		if (entryblock && entryblock->b_instr)
+			c->u->u_firstlineno = entryblock->b_instr->i_lineno;
+		else
+			c->u->u_firstlineno = 1;
+	}
 	if (!assemble_init(&a, nblocks, c->u->u_firstlineno))
 		goto error;
 	dfs(c, entryblock, &a);

Modified: python/branches/bcannon-sandboxing/Python/errors.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/errors.c	(original)
+++ python/branches/bcannon-sandboxing/Python/errors.c	Wed Aug  2 00:51:44 2006
@@ -632,7 +632,7 @@
 
 /* Function to issue a warning message; may raise an exception. */
 int
-PyErr_Warn(PyObject *category, char *message)
+PyErr_WarnEx(PyObject *category, const char *message, Py_ssize_t stack_level)
 {
 	PyObject *dict, *func = NULL;
 	PyObject *warnings_module = PyModule_GetWarningsModule();
@@ -650,7 +650,8 @@
 
 		if (category == NULL)
 			category = PyExc_RuntimeWarning;
-		res = PyObject_CallFunction(func, "sO", message, category);
+		res = PyObject_CallFunction(func, "sOn",
+					    message, category, stack_level);
 		if (res == NULL)
 			return -1;
 		Py_DECREF(res);
@@ -658,6 +659,16 @@
 	}
 }
 
+/* PyErr_Warn is only for backwards compatability and will be removed.
+   Use PyErr_WarnEx instead. */
+
+#undef PyErr_Warn
+
+int
+PyErr_Warn(PyObject *category, char *message)
+{
+	return PyErr_WarnEx(category, message, 1);
+}
 
 /* Warning with explicit origin */
 int

Modified: python/branches/bcannon-sandboxing/Python/future.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/future.c	(original)
+++ python/branches/bcannon-sandboxing/Python/future.c	Wed Aug  2 00:51:44 2006
@@ -122,8 +122,10 @@
 
 	ff = (PyFutureFeatures *)PyObject_T_MALLOC("compiler",
 						    sizeof(PyFutureFeatures));
-	if (ff == NULL)
+	if (ff == NULL) {
+		PyErr_NoMemory();
 		return NULL;
+	}
 	ff->ff_features = 0;
 	ff->ff_lineno = -1;
 

Modified: python/branches/bcannon-sandboxing/Python/getargs.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/getargs.c	(original)
+++ python/branches/bcannon-sandboxing/Python/getargs.c	Wed Aug  2 00:51:44 2006
@@ -351,8 +351,8 @@
 				      "argument %d", iarg);
 			i = 0;
 			p += strlen(p);
-			while (levels[i] > 0 && (int)(p-buf) < 220) {
-				PyOS_snprintf(p, sizeof(buf) - (buf - p),
+			while (levels[i] > 0 && i < 32 && (int)(p-buf) < 220) {
+				PyOS_snprintf(p, sizeof(buf) - (p - buf),
 					      ", item %d", levels[i]-1);
 				p += strlen(p);
 				i++;
@@ -439,6 +439,13 @@
 		char *msg;
 		PyObject *item;
 		item = PySequence_GetItem(arg, i);
+		if (item == NULL) {
+			PyErr_Clear();
+			levels[0] = i+1;
+			levels[1] = 0;
+			strncpy(msgbuf, "is not retrievable", bufsize);
+			return msgbuf;
+		}
 		msg = convertitem(item, &format, p_va, flags, levels+1, 
 				  msgbuf, bufsize, freelist);
 		/* PySequence_GetItem calls tp->sq_item, which INCREFs */
@@ -1509,6 +1516,7 @@
 		else {
 			msg = skipitem(&format, p_va, flags);
 			if (msg) {
+				levels[0] = 0;
 				seterror(i+1, msg, levels, fname, message);
 				return cleanreturn(0, freelist);
 			}

Modified: python/branches/bcannon-sandboxing/Python/getopt.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/getopt.c	(original)
+++ python/branches/bcannon-sandboxing/Python/getopt.c	Wed Aug  2 00:51:44 2006
@@ -24,6 +24,9 @@
  * davegottner at delphi.com.
  *---------------------------------------------------------------------------*/
 
+/* Modified to support --help and --version, as well as /? on Windows
+ * by Georg Brandl. */
+
 #include <stdio.h>
 #include <string.h>
 
@@ -43,8 +46,17 @@
 
 	if (*opt_ptr == '\0') {
 
-		if (_PyOS_optind >= argc || argv[_PyOS_optind][0] != '-' ||
-		    argv[_PyOS_optind][1] == '\0' /* lone dash */ )
+		if (_PyOS_optind >= argc)
+			return -1;
+#ifdef MS_WINDOWS
+		else if (strcmp(argv[_PyOS_optind], "/?") == 0) {
+			++_PyOS_optind;
+			return 'h';
+		}
+#endif
+
+		else if (argv[_PyOS_optind][0] != '-' ||
+		         argv[_PyOS_optind][1] == '\0' /* lone dash */ )
 			return -1;
 
 		else if (strcmp(argv[_PyOS_optind], "--") == 0) {
@@ -52,6 +64,17 @@
 			return -1;
 		}
 
+		else if (strcmp(argv[_PyOS_optind], "--help") == 0) {
+			++_PyOS_optind;
+			return 'h';
+		}
+
+		else if (strcmp(argv[_PyOS_optind], "--version") == 0) {
+			++_PyOS_optind;
+			return 'V';
+		}
+
+
 		opt_ptr = &argv[_PyOS_optind++][1]; 
 	}
 
@@ -62,7 +85,7 @@
 		if (_PyOS_opterr)
 			fprintf(stderr, "Unknown option: -%c\n", option);
 
-		return '?';
+		return '_';
 	}
 
 	if (*(ptr + 1) == ':') {
@@ -76,7 +99,7 @@
 				if (_PyOS_opterr)
 					fprintf(stderr,
 			    "Argument expected for the -%c option\n", option);
-				return '?';
+				return '_';
 			}
 
 			_PyOS_optarg = argv[_PyOS_optind++];

Modified: python/branches/bcannon-sandboxing/Python/import.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/import.c	(original)
+++ python/branches/bcannon-sandboxing/Python/import.c	Wed Aug  2 00:51:44 2006
@@ -60,9 +60,11 @@
        Python 2.5a0: 62081 (ast-branch)
        Python 2.5a0: 62091 (with)
        Python 2.5a0: 62092 (changed WITH_CLEANUP opcode)
+       Python 2.5b3: 62101 (fix wrong code: for x, in ...)
+       Python 2.5b3: 62111 (fix wrong code: x += yield)
 .
 */
-#define MAGIC (62092 | ((long)'\r'<<16) | ((long)'\n'<<24))
+#define MAGIC (62111 | ((long)'\r'<<16) | ((long)'\n'<<24))
 
 /* Magic word as global; note that _PyImport_Init() can change the
    value of this global to accommodate for alterations of how the
@@ -97,6 +99,8 @@
 };
 #endif
 
+static PyTypeObject NullImporterType;	/* Forward reference */
+
 /* Initialize things */
 
 void
@@ -115,6 +119,8 @@
 	for (scan = _PyImport_StandardFiletab; scan->suffix != NULL; ++scan)
 		++countS;
 	filetab = PyMem_NEW(struct filedescr, countD + countS + 1);
+	if (filetab == NULL)
+		Py_FatalError("Can't initialize import file table.");
 	memcpy(filetab, _PyImport_DynLoadFiletab,
 	       countD * sizeof(struct filedescr));
 	memcpy(filetab + countD, _PyImport_StandardFiletab,
@@ -152,6 +158,8 @@
 
 	/* adding sys.path_hooks and sys.path_importer_cache, setting up
 	   zipimport */
+	if (PyType_Ready(&NullImporterType) < 0)
+		goto error;
 
 	if (Py_VerboseFlag)
 		PySys_WriteStderr("# installing zipimport hook\n");
@@ -177,9 +185,11 @@
 	if (err) {
   error:
 		PyErr_Print();
-		Py_FatalError("initializing sys.meta_path, sys.path_hooks or "
-			      "path_importer_cache failed");
+		Py_FatalError("initializing sys.meta_path, sys.path_hooks, "
+			      "path_importer_cache, or NullImporter failed"
+			      );
 	}
+
 	zimpimport = PyImport_ImportModule("zipimport");
 	if (zimpimport == NULL) {
 		PyErr_Clear(); /* No zip import module -- okay */
@@ -238,8 +248,11 @@
 	long me = PyThread_get_thread_ident();
 	if (me == -1)
 		return; /* Too bad */
-	if (import_lock == NULL)
+	if (import_lock == NULL) {
 		import_lock = PyThread_allocate_lock();
+		if (import_lock == NULL)
+			return;  /* Nothing much we can do. */
+	}
 	if (import_lock_thread == me) {
 		import_lock_level++;
 		return;
@@ -258,7 +271,7 @@
 unlock_import(void)
 {
 	long me = PyThread_get_thread_ident();
-	if (me == -1)
+	if (me == -1 || import_lock == NULL)
 		return 0; /* Too bad */
 	if (import_lock_thread != me)
 		return -1;
@@ -1052,9 +1065,18 @@
 		}
 		PyErr_Clear();
 	}
-	if (importer == NULL)
-		importer = Py_None;
-	else if (importer != Py_None) {
+	if (importer == NULL) {
+		importer = PyObject_CallFunctionObjArgs(
+			(PyObject *)&NullImporterType, p, NULL
+		);
+		if (importer == NULL) {
+			if (PyErr_ExceptionMatches(PyExc_ImportError)) {
+				PyErr_Clear();
+				return Py_None;
+			}
+		}
+	}
+	if (importer != NULL) {
 		int err = PyDict_SetItem(path_importer_cache, p, importer);
 		Py_DECREF(importer);
 		if (err != 0)
@@ -1237,42 +1259,17 @@
 
 			importer = get_path_importer(path_importer_cache,
 						     path_hooks, v);
-			if (importer == NULL)
-				return NULL;
-			/* Note: importer is a borrowed reference */
-			if (importer == Py_False) {
-				/* Cached as not being a valid dir. */
+			if (importer == NULL) {
 				Py_XDECREF(copy);
-				continue;
-			}
-			else if (importer == Py_True) {
-				/* Cached as being a valid dir, so just
-				 * continue below. */
-			}
-			else if (importer == Py_None) {
-				/* No importer was found, so it has to be a file.
-				 * Check if the directory is valid.
-				 * Note that the empty string is a valid path, but
-				 * not stat'able, hence the check for len. */
-#ifdef HAVE_STAT
-				if (len && stat(buf, &statbuf) != 0) {
-					/* Directory does not exist. */
-					PyDict_SetItem(path_importer_cache,
-					               v, Py_False);
-					Py_XDECREF(copy);
-					continue;
-				} else {
-					PyDict_SetItem(path_importer_cache,
-					               v, Py_True);
-				}
-#endif
+				return NULL;
 			}
-			else {
-				/* A real import hook importer was found. */
+			/* Note: importer is a borrowed reference */
+			if (importer != Py_None) {
 				PyObject *loader;
 				loader = PyObject_CallMethod(importer,
 							     "find_module",
 							     "s", fullname);
+				Py_XDECREF(copy);
 				if (loader == NULL)
 					return NULL;  /* error */
 				if (loader != Py_None) {
@@ -1281,7 +1278,6 @@
 					return &importhookdescr;
 				}
 				Py_DECREF(loader);
-				Py_XDECREF(copy);
 				continue;
 			}
 		}
@@ -1903,11 +1899,10 @@
 	if (co == NULL)
 		return -1;
 	if (!PyCode_Check(co)) {
-		Py_DECREF(co);
 		PyErr_Format(PyExc_TypeError,
 			     "frozen object %.200s is not a code object",
 			     name);
-		return -1;
+		goto err_return;
 	}
 	if (ispackage) {
 		/* Set __path__ to the package name */
@@ -1915,22 +1910,25 @@
 		int err;
 		m = PyImport_AddModule(name);
 		if (m == NULL)
-			return -1;
+			goto err_return;
 		d = PyModule_GetDict(m);
 		s = PyString_InternFromString(name);
 		if (s == NULL)
-			return -1;
+			goto err_return;
 		err = PyDict_SetItemString(d, "__path__", s);
 		Py_DECREF(s);
 		if (err != 0)
-			return err;
+			goto err_return;
 	}
 	m = PyImport_ExecCodeModuleEx(name, co, "<frozen>");
-	Py_DECREF(co);
 	if (m == NULL)
-		return -1;
+		goto err_return;
+	Py_DECREF(co);
 	Py_DECREF(m);
 	return 1;
+err_return:
+	Py_DECREF(co);
+	return -1;
 }
 
 
@@ -2925,11 +2923,120 @@
 	return err;
 }
 
+typedef struct {
+    PyObject_HEAD
+} NullImporter;
+
+static int
+NullImporter_init(NullImporter *self, PyObject *args, PyObject *kwds)
+{
+	char *path;
+
+	if (!_PyArg_NoKeywords("NullImporter()", kwds))
+		return -1;
+
+	if (!PyArg_ParseTuple(args, "s:NullImporter",
+			      &path))
+		return -1;
+
+	if (strlen(path) == 0) {
+		PyErr_SetString(PyExc_ImportError, "empty pathname");
+		return -1;
+	} else {
+#ifndef RISCOS
+		struct stat statbuf;
+		int rv;
+
+		rv = stat(path, &statbuf);
+		if (rv == 0) {
+			/* it exists */
+			if (S_ISDIR(statbuf.st_mode)) {
+				/* it's a directory */
+				PyErr_SetString(PyExc_ImportError,
+						"existing directory");
+				return -1;
+			}
+		}
+#else
+		if (object_exists(path)) {
+			/* it exists */
+			if (isdir(path)) {
+				/* it's a directory */
+				PyErr_SetString(PyExc_ImportError,
+						"existing directory");
+				return -1;
+			}
+		}
+#endif
+	}
+	return 0;
+}
+
+static PyObject *
+NullImporter_find_module(NullImporter *self, PyObject *args)
+{
+	Py_RETURN_NONE;
+}
+
+static PyMethodDef NullImporter_methods[] = {
+	{"find_module", (PyCFunction)NullImporter_find_module, METH_VARARGS,
+	 "Always return None"
+	},
+	{NULL}  /* Sentinel */
+};
+
+
+static PyTypeObject NullImporterType = {
+	PyObject_HEAD_INIT(NULL)
+	0,                         /*ob_size*/
+	"imp.NullImporter",        /*tp_name*/
+	sizeof(NullImporter),      /*tp_basicsize*/
+	0,                         /*tp_itemsize*/
+	0,                         /*tp_dealloc*/
+	0,                         /*tp_print*/
+	0,                         /*tp_getattr*/
+	0,                         /*tp_setattr*/
+	0,                         /*tp_compare*/
+	0,                         /*tp_repr*/
+	0,                         /*tp_as_number*/
+	0,                         /*tp_as_sequence*/
+	0,                         /*tp_as_mapping*/
+	0,                         /*tp_hash */
+	0,                         /*tp_call*/
+	0,                         /*tp_str*/
+	0,                         /*tp_getattro*/
+	0,                         /*tp_setattro*/
+	0,                         /*tp_as_buffer*/
+	Py_TPFLAGS_DEFAULT,        /*tp_flags*/
+	"Null importer object",    /* tp_doc */
+	0,	                   /* tp_traverse */
+	0,	                   /* tp_clear */
+	0,	                   /* tp_richcompare */
+	0,	                   /* tp_weaklistoffset */
+	0,	                   /* tp_iter */
+	0,	                   /* tp_iternext */
+	NullImporter_methods,      /* tp_methods */
+	0,                         /* tp_members */
+	0,                         /* tp_getset */
+	0,                         /* tp_base */
+	0,                         /* tp_dict */
+	0,                         /* tp_descr_get */
+	0,                         /* tp_descr_set */
+	0,                         /* tp_dictoffset */
+	(initproc)NullImporter_init,      /* tp_init */
+	0,                         /* tp_alloc */
+	PyType_GenericNew          /* tp_new */
+};
+
+
 PyMODINIT_FUNC
 initimp(void)
 {
 	PyObject *m, *d;
 
+	if (PyType_Ready(&NullImporterType) < 0)
+		goto failure;
+
 	m = Py_InitModule4("imp", imp_methods, doc_imp,
 			   NULL, PYTHON_API_VERSION);
 	if (m == NULL)
@@ -2947,6 +3054,8 @@
 	if (setint(d, "PY_CODERESOURCE", PY_CODERESOURCE) < 0) goto failure;
 	if (setint(d, "IMP_HOOK", IMP_HOOK) < 0) goto failure;
 
+	Py_INCREF(&NullImporterType);
+	PyModule_AddObject(m, "NullImporter", (PyObject *)&NullImporterType);
   failure:
 	;
 }

Modified: python/branches/bcannon-sandboxing/Python/mactoolboxglue.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/mactoolboxglue.c	(original)
+++ python/branches/bcannon-sandboxing/Python/mactoolboxglue.c	Wed Aug  2 00:51:44 2006
@@ -60,8 +60,9 @@
 			strncpy(buf, input, sizeof(buf) - 1);
 			buf[sizeof(buf) - 1] = '\0';
 		}
+		Py_DECREF(rv);
 	}
-	
+	Py_XDECREF(m);
 	return buf;
 }
 

Modified: python/branches/bcannon-sandboxing/Python/mystrtoul.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/mystrtoul.c	(original)
+++ python/branches/bcannon-sandboxing/Python/mystrtoul.c	Wed Aug  2 00:51:44 2006
@@ -69,11 +69,22 @@
  * calculated by [int(math.floor(math.log(2**32, i))) for i in range(2, 37)].
  * Note that this is pessimistic if sizeof(long) > 4.
  */
+#if SIZEOF_LONG == 4
 static int digitlimit[] = {
 	0,  0, 32, 20, 16, 13, 12, 11, 10, 10,  /*  0 -  9 */
 	9,  9,  8,  8,  8,  8,  8,  7,  7,  7,  /* 10 - 19 */
 	7,  7,  7,  7,  6,  6,  6,  6,  6,  6,  /* 20 - 29 */
 	6,  6,  6,  6,  6,  6,  6};             /* 30 - 36 */
+#elif SIZEOF_LONG == 8
+/* [int(math.floor(math.log(2**64, i))) for i in range(2, 37)] */
+static int digitlimit[] = {
+	 0,   0, 64, 40, 32, 27, 24, 22, 21, 20,  /*  0 -  9 */
+	19,  18, 17, 17, 16, 16, 16, 15, 15, 15,  /* 10 - 19 */
+	14,  14, 14, 14, 13, 13, 13, 13, 13, 13,  /* 20 - 29 */
+	13,  12, 12, 12, 12, 12, 12};             /* 30 - 36 */
+#else
+#error "Need table for SIZEOF_LONG"
+#endif
 
 /*
 **	strtoul
@@ -184,10 +195,19 @@
 	return (unsigned long)-1;
 }
 
+/* Checking for overflow in PyOS_strtol is a PITA since C doesn't define
+ * anything about what happens when a signed integer operation overflows,
+ * and some compilers think they're doing you a favor by being "clever"
+ * then.  Python assumes a 2's-complement representation, so that the bit
+ * pattern for the largest postive signed long is LONG_MAX, and for
+ * the smallest negative signed long is LONG_MAX + 1.
+ */
+
 long
 PyOS_strtol(char *str, char **ptr, int base)
 {
 	long result;
+	unsigned long uresult;
 	char sign;
 
 	while (*str && isspace(Py_CHARMASK(*str)))
@@ -197,17 +217,20 @@
 	if (sign == '+' || sign == '-')
 		str++;
 
-	result = (long) PyOS_strtoul(str, ptr, base);
+	uresult = PyOS_strtoul(str, ptr, base);
 
-	/* Signal overflow if the result appears negative,
-	   except for the largest negative integer */
-	if (result < 0 && !(sign == '-' && result == -result)) {
+	if (uresult <= (unsigned long)LONG_MAX) {
+		result = (long)uresult;
+		if (sign == '-')
+			result = -result;
+	}
+	else if (sign == '-' && uresult == (unsigned long)LONG_MAX + 1) {
+		assert(LONG_MIN == -LONG_MAX-1);
+		result = LONG_MIN;
+	}
+	else {
 		errno = ERANGE;
-		result = 0x7fffffff;
+		result = LONG_MAX;
 	}
-
-	if (sign == '-')
-		result = -result;
-
 	return result;
 }

Modified: python/branches/bcannon-sandboxing/Python/pyarena.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/pyarena.c	(original)
+++ python/branches/bcannon-sandboxing/Python/pyarena.c	Wed Aug  2 00:51:44 2006
@@ -132,19 +132,19 @@
 {
 	PyArena* arena = (PyArena *)malloc(sizeof(PyArena));
 	if (!arena)
-		return NULL;
+		return (PyArena*)PyErr_NoMemory();
 
 	arena->a_head = block_new(DEFAULT_BLOCK_SIZE);
 	arena->a_cur = arena->a_head;
         if (!arena->a_head) {
                 free((void *)arena);
-                return NULL;
+                return (PyArena*)PyErr_NoMemory();
         }
         arena->a_objects = PyList_New(0);
         if (!arena->a_objects) {
                 block_free(arena->a_head);
                 free((void *)arena);
-                return NULL;
+                return (PyArena*)PyErr_NoMemory();
         }
 #if defined(Py_DEBUG)
         arena->total_allocs = 0;
@@ -191,7 +191,7 @@
 {
 	void *p = block_alloc(arena->a_cur, size);
 	if (!p)
-		return NULL;
+		return PyErr_NoMemory();
 #if defined(Py_DEBUG)
         arena->total_allocs++;
         arena->total_size += size;

Modified: python/branches/bcannon-sandboxing/Python/pystate.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/pystate.c	(original)
+++ python/branches/bcannon-sandboxing/Python/pystate.c	Wed Aug  2 00:51:44 2006
@@ -63,6 +63,10 @@
 
 	if (interp != NULL) {
 		HEAD_INIT();
+#ifdef WITH_THREAD
+		if (head_mutex == NULL)
+			Py_FatalError("Can't initialize threads for interpreter");
+#endif
 		interp->modules = NULL;
 		interp->sysdict = NULL;
 		interp->builtins = NULL;
@@ -508,6 +512,53 @@
 	return tstate->next;
 }
 
+/* The implementation of sys._current_frames().  This is intended to be
+   called with the GIL held, as it will be when called via
+   sys._current_frames().  It's possible it would work fine even without
+   the GIL held, but haven't thought enough about that.
+*/
+PyObject *
+_PyThread_CurrentFrames(void)
+{
+	PyObject *result;
+	PyInterpreterState *i;
+
+	result = PyDict_New();
+	if (result == NULL)
+		return NULL;
+
+	/* for i in all interpreters:
+	 *     for t in all of i's thread states:
+	 *          if t's frame isn't NULL, map t's id to its frame
+	 * Because these lists can mutute even when the GIL is held, we
+	 * need to grab head_mutex for the duration.
+	 */
+	HEAD_LOCK();
+	for (i = interp_head; i != NULL; i = i->next) {
+		PyThreadState *t;
+		for (t = i->tstate_head; t != NULL; t = t->next) {
+			PyObject *id;
+			int stat;
+			struct _frame *frame = t->frame;
+			if (frame == NULL)
+				continue;
+			id = PyInt_FromLong(t->thread_id);
+			if (id == NULL)
+				goto Fail;
+			stat = PyDict_SetItem(result, id, (PyObject *)frame);
+			Py_DECREF(id);
+			if (stat < 0)
+				goto Fail;
+		}
+	}
+	HEAD_UNLOCK();
+	return result;
+
+ Fail:
+ 	HEAD_UNLOCK();
+ 	Py_DECREF(result);
+ 	return NULL;
+}
 
 /* Python "auto thread state" API. */
 #ifdef WITH_THREAD
@@ -565,15 +616,15 @@
 	/* If autoTLSkey is 0, this must be the very first threadstate created
 	   in Py_Initialize().  Don't do anything for now (we'll be back here
 	   when _PyGILState_Init is called). */
-	if (!autoTLSkey) 
+	if (!autoTLSkey)
 		return;
-	
+
 	/* Stick the thread state for this thread in thread local storage.
 
 	   The only situation where you can legitimately have more than one
 	   thread state for an OS level thread is when there are multiple
 	   interpreters, when:
-	       
+
 	       a) You shouldn't really be using the PyGILState_ APIs anyway,
 	          and:
 

Modified: python/branches/bcannon-sandboxing/Python/pythonrun.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/pythonrun.c	(original)
+++ python/branches/bcannon-sandboxing/Python/pythonrun.c	Wed Aug  2 00:51:44 2006
@@ -756,6 +756,11 @@
 			ps2 = PyString_AsString(w);
 	}
 	arena = PyArena_New();
+	if (arena == NULL) {
+		Py_XDECREF(v);
+		Py_XDECREF(w);
+		return -1;
+	}
 	mod = PyParser_ASTFromFile(fp, filename,
 				   Py_single_input, ps1, ps2,
 				   flags, &errcode, arena);
@@ -1074,6 +1079,17 @@
 			}
 			PyErr_Fetch(&exception2, &v2, &tb2);
 			PyErr_NormalizeException(&exception2, &v2, &tb2);
+			/* It should not be possible for exception2 or v2
+			   to be NULL. However PyErr_Display() can't
+			   tolerate NULLs, so just be safe. */
+			if (exception2 == NULL) {
+				exception2 = Py_None;
+				Py_INCREF(exception2);
+			}
+			if (v2 == NULL) {
+				v2 = Py_None;
+				Py_INCREF(v2);
+			}
 			if (Py_FlushLine())
 				PyErr_Clear();
 			fflush(stdout);
@@ -1081,8 +1097,8 @@
 			PyErr_Display(exception2, v2, tb2);
 			PySys_WriteStderr("\nOriginal exception was:\n");
 			PyErr_Display(exception, v, tb);
-			Py_XDECREF(exception2);
-			Py_XDECREF(v2);
+			Py_DECREF(exception2);
+			Py_DECREF(v2);
 			Py_XDECREF(tb2);
 		}
 		Py_XDECREF(result);
@@ -1202,9 +1218,12 @@
 		  PyObject *locals, PyCompilerFlags *flags)
 {
 	PyObject *ret = NULL;
+	mod_ty mod;
 	PyArena *arena = PyArena_New();
-	mod_ty mod = PyParser_ASTFromString(str, "<string>", start, flags,
-					    arena);
+	if (arena == NULL)
+		return NULL;
+	
+	mod = PyParser_ASTFromString(str, "<string>", start, flags, arena);
 	if (mod != NULL)
 		ret = run_mod(mod, "<string>", globals, locals, flags, arena);
 	PyArena_Free(arena);
@@ -1216,9 +1235,13 @@
 		  PyObject *locals, int closeit, PyCompilerFlags *flags)
 {
 	PyObject *ret;
+	mod_ty mod;
 	PyArena *arena = PyArena_New();
-	mod_ty mod = PyParser_ASTFromFile(fp, filename, start, 0, 0,
-					  flags, NULL, arena);
+	if (arena == NULL)
+		return NULL;
+	
+	mod = PyParser_ASTFromFile(fp, filename, start, 0, 0,
+				   flags, NULL, arena);
 	if (mod == NULL) {
 		PyArena_Free(arena);
 		return NULL;
@@ -1281,8 +1304,12 @@
 		      PyCompilerFlags *flags)
 {
 	PyCodeObject *co;
+	mod_ty mod;
 	PyArena *arena = PyArena_New();
-	mod_ty mod = PyParser_ASTFromString(str, filename, start, flags, arena);
+	if (arena == NULL)
+		return NULL;
+
+	mod = PyParser_ASTFromString(str, filename, start, flags, arena);
 	if (mod == NULL) {
 		PyArena_Free(arena);
 		return NULL;
@@ -1301,8 +1328,12 @@
 Py_SymtableString(const char *str, const char *filename, int start)
 {
 	struct symtable *st;
+	mod_ty mod;
 	PyArena *arena = PyArena_New();
-	mod_ty mod = PyParser_ASTFromString(str, filename, start, NULL, arena);
+	if (arena == NULL)
+		return NULL;
+
+	mod = PyParser_ASTFromString(str, filename, start, NULL, arena);
 	if (mod == NULL) {
 		PyArena_Free(arena);
 		return NULL;

Modified: python/branches/bcannon-sandboxing/Python/symtable.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/symtable.c	(original)
+++ python/branches/bcannon-sandboxing/Python/symtable.c	Wed Aug  2 00:51:44 2006
@@ -221,8 +221,12 @@
 		return st;
 	st->st_filename = filename;
 	st->st_future = future;
-	symtable_enter_block(st, GET_IDENTIFIER(top), ModuleBlock, 
-			     (void *)mod, 0);
+	if (!symtable_enter_block(st, GET_IDENTIFIER(top), ModuleBlock, 
+			     (void *)mod, 0)) {
+		PySymtable_Free(st);
+		return NULL;
+	}
+
 	st->st_top = st->st_cur;
 	st->st_cur->ste_unoptimized = OPT_TOPLEVEL;
 	/* Any other top-level initialization? */
@@ -525,6 +529,8 @@
 		i = PyInt_AS_LONG(w);
 		flags |= (i << SCOPE_OFF);
 		u = PyInt_FromLong(flags);
+		if (!u)
+			return 0;
 		if (PyDict_SetItem(symbols, name, u) < 0) {
 			Py_DECREF(u);
 			return 0;
@@ -723,11 +729,13 @@
 {
 	Py_ssize_t end;
 
-	Py_DECREF(st->st_cur);
+	Py_CLEAR(st->st_cur);
 	end = PyList_GET_SIZE(st->st_stack) - 1;
 	if (end >= 0) {
 		st->st_cur = (PySTEntryObject *)PyList_GET_ITEM(st->st_stack, 
 								end);
+		if (st->st_cur == NULL)
+			return 0;
 		Py_INCREF(st->st_cur);
 		if (PySequence_DelItem(st->st_stack, end) < 0)
 			return 0;
@@ -749,6 +757,8 @@
 		Py_DECREF(st->st_cur);
 	}
 	st->st_cur = PySTEntry_New(st, name, block, ast, lineno);
+	if (st->st_cur == NULL)
+		return 0;
 	if (name == GET_IDENTIFIER(top))
 		st->st_global = st->st_cur->ste_symbols;
 	if (prev) {

Modified: python/branches/bcannon-sandboxing/Python/sysmodule.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/sysmodule.c	(original)
+++ python/branches/bcannon-sandboxing/Python/sysmodule.c	Wed Aug  2 00:51:44 2006
@@ -660,6 +660,21 @@
 	return (PyObject*)f;
 }
 
+PyDoc_STRVAR(current_frames_doc,
+"_current_frames() -> dictionary\n\
+\n\
+Return a dictionary mapping each current thread T's thread id to T's\n\
+current stack frame.\n\
+\n\
+This function should be used for specialized purposes only."
+);
+
+static PyObject *
+sys_current_frames(PyObject *self, PyObject *noargs)
+{
+	return _PyThread_CurrentFrames();
+}
+
 PyDoc_STRVAR(call_tracing_doc,
 "call_tracing(func, args) -> object\n\
 \n\
@@ -722,6 +737,8 @@
 	/* Might as well keep this in alphabetic order */
 	{"callstats", (PyCFunction)PyEval_GetCallStats, METH_NOARGS,
 	 callstats_doc},
+	{"_current_frames", sys_current_frames, METH_NOARGS,
+	 current_frames_doc},
 	{"displayhook",	sys_displayhook, METH_O, displayhook_doc},
 	{"exc_info",	sys_exc_info, METH_NOARGS, exc_info_doc},
 	{"exc_clear",	sys_exc_clear, METH_NOARGS, exc_clear_doc},
@@ -1123,41 +1140,38 @@
 #elif PY_RELEASE_LEVEL == PY_RELEASE_LEVEL_FINAL
 	s = "final";
 #endif
-	PyDict_SetItemString(sysdict, "version_info",
-			     v = Py_BuildValue("iiisi", PY_MAJOR_VERSION,
+
+#define SET_SYS_FROM_STRING(key, value)			\
+	v = value;					\
+	if (v != NULL)					\
+		PyDict_SetItemString(sysdict, key, v);	\
+	Py_XDECREF(v)
+
+	SET_SYS_FROM_STRING("version_info",
+			    Py_BuildValue("iiisi", PY_MAJOR_VERSION,
 					       PY_MINOR_VERSION,
 					       PY_MICRO_VERSION, s,
 					       PY_RELEASE_SERIAL));
-	Py_XDECREF(v);
-	PyDict_SetItemString(sysdict, "api_version",
-			     v = PyInt_FromLong(PYTHON_API_VERSION));
-	Py_XDECREF(v);
-	PyDict_SetItemString(sysdict, "copyright",
-			     v = PyString_FromString(Py_GetCopyright()));
-	Py_XDECREF(v);
-	PyDict_SetItemString(sysdict, "platform",
-			     v = PyString_FromString(Py_GetPlatform()));
-	Py_XDECREF(v);
-	PyDict_SetItemString(sysdict, "executable",
-			     v = PyString_FromString(Py_GetProgramFullPath()));
-	Py_XDECREF(v);
-	PyDict_SetItemString(sysdict, "prefix",
-			     v = PyString_FromString(Py_GetPrefix()));
-	Py_XDECREF(v);
-	PyDict_SetItemString(sysdict, "exec_prefix",
-		   v = PyString_FromString(Py_GetExecPrefix()));
-	Py_XDECREF(v);
-	PyDict_SetItemString(sysdict, "maxint",
-			     v = PyInt_FromLong(PyInt_GetMax()));
-	Py_XDECREF(v);
+	SET_SYS_FROM_STRING("api_version",
+			    PyInt_FromLong(PYTHON_API_VERSION));
+	SET_SYS_FROM_STRING("copyright",
+			    PyString_FromString(Py_GetCopyright()));
+	SET_SYS_FROM_STRING("platform",
+			    PyString_FromString(Py_GetPlatform()));
+	SET_SYS_FROM_STRING("executable",
+			    PyString_FromString(Py_GetProgramFullPath()));
+	SET_SYS_FROM_STRING("prefix",
+			    PyString_FromString(Py_GetPrefix()));
+	SET_SYS_FROM_STRING("exec_prefix",
+		   	    PyString_FromString(Py_GetExecPrefix()));
+	SET_SYS_FROM_STRING("maxint",
+			    PyInt_FromLong(PyInt_GetMax()));
 #ifdef Py_USING_UNICODE
-	PyDict_SetItemString(sysdict, "maxunicode",
-			     v = PyInt_FromLong(PyUnicode_GetMax()));
-	Py_XDECREF(v);
+	SET_SYS_FROM_STRING("maxunicode",
+			    PyInt_FromLong(PyUnicode_GetMax()));
 #endif
-	PyDict_SetItemString(sysdict, "builtin_module_names",
-		   v = list_builtin_module_names());
-	Py_XDECREF(v);
+	SET_SYS_FROM_STRING("builtin_module_names",
+			    list_builtin_module_names());
 	{
 		/* Assumes that longs are at least 2 bytes long.
 		   Should be safe! */
@@ -1169,18 +1183,16 @@
 			value = "big";
 		else
 			value = "little";
-		PyDict_SetItemString(sysdict, "byteorder",
-				     v = PyString_FromString(value));
-		Py_XDECREF(v);
+		SET_SYS_FROM_STRING("byteorder",
+				    PyString_FromString(value));
 	}
 #ifdef MS_COREDLL
-	PyDict_SetItemString(sysdict, "dllhandle",
-			     v = PyLong_FromVoidPtr(PyWin_DLLhModule));
-	Py_XDECREF(v);
-	PyDict_SetItemString(sysdict, "winver",
-			     v = PyString_FromString(PyWin_DLLVersionString));
-	Py_XDECREF(v);
+	SET_SYS_FROM_STRING("dllhandle",
+			    PyLong_FromVoidPtr(PyWin_DLLhModule));
+	SET_SYS_FROM_STRING("winver",
+			    PyString_FromString(PyWin_DLLVersionString));
 #endif
+#undef SET_SYS_FROM_STRING
 	if (warnoptions == NULL) {
 		warnoptions = PyList_New(0);
 	}

Modified: python/branches/bcannon-sandboxing/Python/thread.c
==============================================================================
--- python/branches/bcannon-sandboxing/Python/thread.c	(original)
+++ python/branches/bcannon-sandboxing/Python/thread.c	Wed Aug  2 00:51:44 2006
@@ -267,6 +267,8 @@
 	struct key *p;
 	long id = PyThread_get_thread_ident();
 
+	if (!keymutex)
+		return NULL;
 	PyThread_acquire_lock(keymutex, 1);
 	for (p = keyhead; p != NULL; p = p->next) {
 		if (p->id == id && p->key == key)

Modified: python/branches/bcannon-sandboxing/Python/thread_os2.h
==============================================================================
--- python/branches/bcannon-sandboxing/Python/thread_os2.h	(original)
+++ python/branches/bcannon-sandboxing/Python/thread_os2.h	Wed Aug  2 00:51:44 2006
@@ -35,21 +35,18 @@
 long
 PyThread_start_new_thread(void (*func)(void *), void *arg)
 {
-	int aThread;
-	int success = 0;
+	int thread_id;
 
-	aThread = _beginthread(func,
+	thread_id = _beginthread(func,
 				NULL,
 				OS2_STACKSIZE(_pythread_stacksize),
 				arg);
 
-	if (aThread == -1) {
-		success = -1;
-		fprintf(stderr, "aThread failed == %d", aThread);
+	if (thread_id == -1) {
 		dprintf(("_beginthread failed. return %ld\n", errno));
 	}
 
-	return success;
+	return thread_id;
 }
 
 long

Modified: python/branches/bcannon-sandboxing/README
==============================================================================
--- python/branches/bcannon-sandboxing/README	(original)
+++ python/branches/bcannon-sandboxing/README	Wed Aug  2 00:51:44 2006
@@ -1,4 +1,4 @@
-This is Python version 2.5 alpha 1
+This is Python version 2.5 beta 2
 ==================================
 
 Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Python Software Foundation.
@@ -226,13 +226,13 @@
 Unsupported systems
 -------------------
 
-XXX This section is out of date!
-
-A number of features are not supported in Python 2.3 anymore. Some
-support code is still present, but will be removed in Python 2.4. 
+A number of features are not supported in Python 2.5 anymore. Some
+support code is still present, but will be removed in Python 2.6. 
 If you still need to use current Python versions on these systems,
 please send a message to python-dev at python.org indicating that you
-volunteer to support this system.
+volunteer to support this system. For a more detailed discussion 
+regarding no-longer-supported and resupporting platforms, as well
+as a list of platforms that became or will be unsupported, see PEP 11.
 
 More specifically, the following systems are not supported any
 longer:
@@ -240,6 +240,7 @@
 - DYNIX
 - dgux
 - Minix
+- NeXT
 - Irix 4 and --with-sgi-dl
 - Linux 1
 - Systems defining __d6_pthread_create (configure.in)
@@ -247,6 +248,25 @@
   or PY_PTHREAD_D7 in thread_pthread.h
 - Systems using --with-dl-dld
 - Systems using --without-universal-newlines
+- MacOS 9
+
+The following systems are still supported in Python 2.5, but
+support will be dropped in 2.6:
+- Systems using --with-wctype-functions
+- Win9x, WinME
+
+Warning on install in Windows 98 and Windows Me
+-----------------------------------------------
+
+Following Microsoft's closing of Extended Support for
+Windows 98/ME (July 11, 2006), Python 2.6 will stop
+supporting these platforms. Python development and
+maintainability becomes easier (and more reliable) when
+platform specific code targeting OSes with few users
+and no dedicated expert developers is taken out. The
+vendor also warns that the OS versions listed above
+"can expose customers to security risks" and recommends
+upgrade.
 
 Platform specific notes
 -----------------------
@@ -426,14 +446,6 @@
         thread may interrupt system calls in others). Therefore, test_math and
         tests involving threads will fail until those problems are fixed.
 
-SunOS 4.x: When using the SunPro C compiler, you may want to use the
-        '-Xa' option instead of '-Xc', to enable some needed non-ANSI
-        Sunisms.
-        THIS SYSTEM IS NO LONGER SUPPORTED.
-
-NeXT:   Not supported anymore. Start with the MacOSX/Darwin code if you
-        want to revive it.
-
 QNX:    Chris Herborth (chrish at qnx.com) writes:
         configure works best if you use GNU bash; a port is available on
         ftp.qnx.com in /usr/free.  I used the following process to build,

Modified: python/branches/bcannon-sandboxing/Tools/buildbot/kill_python.c
==============================================================================
--- python/branches/bcannon-sandboxing/Tools/buildbot/kill_python.c	(original)
+++ python/branches/bcannon-sandboxing/Tools/buildbot/kill_python.c	Wed Aug  2 00:51:44 2006
@@ -42,8 +42,19 @@
 
 		_strlwr(path);
 		/* printf("%s\n", path); */
+
+		/* Check if we are running a buildbot version of Python.
+
+		   On Windows, this will always be a debug build from the
+		   PCbuild directory.  build\\PCbuild\\python_d.exe
+		   
+		   On Cygwin, the pathname is similar to other Unixes.
+		   Use \\build\\python.exe to ensure we don't match
+		   PCbuild\\python.exe which could be a normal instance
+		   of Python running on vanilla Windows.
+		*/
 		if ((strstr(path, "build\\pcbuild\\python_d.exe") != NULL) ||
-		    (strstr(path, "build\\python.exe") != NULL)) {
+		    (strstr(path, "\\build\\python.exe") != NULL)) {
 			printf("Terminating %s (pid %d)\n", path, pids[i]);
 			if (!TerminateProcess(hProcess, 1)) {
 				printf("Termination failed: %d\n", GetLastError());

Modified: python/branches/bcannon-sandboxing/Tools/faqwiz/faqw.py
==============================================================================
--- python/branches/bcannon-sandboxing/Tools/faqwiz/faqw.py	(original)
+++ python/branches/bcannon-sandboxing/Tools/faqwiz/faqw.py	Wed Aug  2 00:51:44 2006
@@ -27,7 +27,7 @@
 except SystemExit, n:
     sys.exit(n)
 except:
-    t, v, tb = sys.exc_type, sys.exc_value, sys.exc_traceback
+    t, v, tb = sys.exc_info()
     print
     import cgi
     cgi.print_exception(t, v, tb)

Modified: python/branches/bcannon-sandboxing/Tools/msi/msi.py
==============================================================================
--- python/branches/bcannon-sandboxing/Tools/msi/msi.py	(original)
+++ python/branches/bcannon-sandboxing/Tools/msi/msi.py	Wed Aug  2 00:51:44 2006
@@ -367,7 +367,7 @@
               ("VerdanaRed9", "Verdana", 9, 255, 0),
              ])
 
-    compileargs = r"-Wi [TARGETDIR]Lib\compileall.py -f -x bad_coding|badsyntax|site-packages [TARGETDIR]Lib"
+    compileargs = r'-Wi "[TARGETDIR]Lib\compileall.py" -f -x bad_coding|badsyntax|site-packages "[TARGETDIR]Lib"'
     # See "CustomAction Table"
     add_data(db, "CustomAction", [
         # msidbCustomActionTypeFirstSequence + msidbCustomActionTypeTextData + msidbCustomActionTypeProperty
@@ -962,6 +962,14 @@
             continue
         dlls.append(f)
         lib.add_file(f)
+    # Add sqlite
+    if msilib.msi_type=="Intel64;1033":
+        sqlite_arch = "/ia64"
+    elif msilib.msi_type=="x64;1033":
+        sqlite_arch = "/amd64"
+    else:
+        sqlite_arch = ""
+    lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
     if have_tcl:
         if not os.path.exists(srcdir+"/PCBuild/_tkinter.pyd"):
             print "WARNING: Missing _tkinter.pyd"
@@ -972,14 +980,6 @@
             tcldir = os.path.normpath(srcdir+"/../tcltk/bin")
             for f in glob.glob1(tcldir, "*.dll"):
                 lib.add_file(f, src=os.path.join(tcldir, f))
-    # Add sqlite
-    if msilib.msi_type=="Intel64;1033":
-        sqlite_arch = "/ia64"
-    elif msilib.msi_type=="x64;1033":
-        sqlite_arch = "/amd64"
-    else:
-        sqlite_arch = ""
-    lib.add_file(srcdir+"/"+sqlite_dir+sqlite_arch+"/sqlite3.dll")
     # check whether there are any unknown extensions
     for f in glob.glob1(srcdir+"/PCBuild", "*.pyd"):
         if f.endswith("_d.pyd"): continue # debug version

Modified: python/branches/bcannon-sandboxing/Tools/msi/uuids.py
==============================================================================
--- python/branches/bcannon-sandboxing/Tools/msi/uuids.py	(original)
+++ python/branches/bcannon-sandboxing/Tools/msi/uuids.py	Wed Aug  2 00:51:44 2006
@@ -27,6 +27,7 @@
     '2.5.103': '{73dcd966-ffec-415f-bb39-8342c1f47017}', # 2.5a3
     '2.5.111': '{c797ecf8-a8e6-4fec-bb99-526b65f28626}', # 2.5b1
     '2.5.112': '{32beb774-f625-439d-b587-7187487baf15}', # 2.5b2
+    '2.5.113': '{89f23918-11cf-4f08-be13-b9b2e6463fd9}', # 2.5b3
     '2.5.121': '{8e9321bc-6b24-48a3-8fd4-c95f8e531e5f}', # 2.5c1
     '2.5.122': '{a6cd508d-9599-45da-a441-cbffa9f7e070}', # 2.5c2
     '2.5.150': '{0a2c5854-557e-48c8-835a-3b9f074bdcaa}', # 2.5.0

Modified: python/branches/bcannon-sandboxing/Tools/scripts/README
==============================================================================
--- python/branches/bcannon-sandboxing/Tools/scripts/README	(original)
+++ python/branches/bcannon-sandboxing/Tools/scripts/README	Wed Aug  2 00:51:44 2006
@@ -27,7 +27,6 @@
 fixnotice.py		Fix the copyright notice in source files
 fixps.py		Fix Python scripts' first line (if #!)
 ftpmirror.py		FTP mirror script
-gencodec.py		Create Python codecs from Unicode mapping files
 google.py		Open a webbrowser with Google.
 gprof2html.py		Transform gprof(1) output into useful HTML.
 h2py.py			Translate #define's into Python assignments
@@ -53,14 +52,14 @@
 ptags.py		Create vi tags file for Python modules
 pydoc			Python documentation browser.
 pysource.py		Find Python source files
-redemo.py		Basic regular expression demostration facility
+redemo.py		Basic regular expression demonstration facility
 reindent.py		Change .py files to use 4-space indents.
 rgrep.py		Reverse grep through a file (useful for big logfiles)
 setup.py		Install all scripts listed here.
 suff.py			Sort a list of files by suffix
+svneol.py		Sets svn:eol-style on all files in directory.
 texcheck.py             Validate Python LaTeX formatting (Raymond Hettinger)
 texi2html.py		Convert GNU texinfo files into HTML
-trace.py		Trace Python program or function execution
 treesync.py		Synchronize source trees (very ideosyncratic)
 untabify.py		Replace tabs with spaces in argument files
 which.py		Find a program in $PATH

Modified: python/branches/bcannon-sandboxing/Tools/webchecker/webchecker.py
==============================================================================
--- python/branches/bcannon-sandboxing/Tools/webchecker/webchecker.py	(original)
+++ python/branches/bcannon-sandboxing/Tools/webchecker/webchecker.py	Wed Aug  2 00:51:44 2006
@@ -760,7 +760,8 @@
             try:
                 names = os.listdir(path)
             except os.error, msg:
-                raise IOError, msg, sys.exc_traceback
+                exc_type, exc_value, exc_tb = sys.exc_info()
+                raise IOError, msg, exc_tb
             names.sort()
             s = MyStringIO("file:"+url, {'content-type': 'text/html'})
             s.write('<BASE HREF="file:%s">\n' %

Modified: python/branches/bcannon-sandboxing/configure
==============================================================================
--- python/branches/bcannon-sandboxing/configure	(original)
+++ python/branches/bcannon-sandboxing/configure	Wed Aug  2 00:51:44 2006
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: 50892 .
+# From configure.in Revision: 51009 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for python 2.5.
 #
@@ -14915,6 +14915,15 @@
 fi
 
 
+case $ac_sys_system/$ac_sys_release in
+Darwin/*)
+	_CUR_CFLAGS="${CFLAGS}"
+	_CUR_LDFLAGS="${LDFLAGS}"
+	CFLAGS="${CFLAGS} -Wl,-search_paths_first"
+	LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
+	;;
+esac
+
 echo "$as_me:$LINENO: checking for inflateCopy in -lz" >&5
 echo $ECHO_N "checking for inflateCopy in -lz... $ECHO_C" >&6
 if test "${ac_cv_lib_z_inflateCopy+set}" = set; then
@@ -14987,6 +14996,13 @@
 fi
 
 
+case $ac_sys_system/$ac_sys_release in
+Darwin/*)
+	CFLAGS="${_CUR_CFLAGS}"
+	LDFLAGS="${_CUR_LDFLAGS}"
+	;;
+esac
+
 echo "$as_me:$LINENO: checking for hstrerror" >&5
 echo $ECHO_N "checking for hstrerror... $ECHO_C" >&6
 cat >conftest.$ac_ext <<_ACEOF
@@ -21870,38 +21886,55 @@
 
 echo "$as_me:$LINENO: checking for /dev/ptmx" >&5
 echo $ECHO_N "checking for /dev/ptmx... $ECHO_C" >&6
-
-if test -e /dev/ptmx
-then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+if test "${ac_cv_file__dev_ptmx+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  test "$cross_compiling" = yes &&
+  { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
+echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
+   { (exit 1); exit 1; }; }
+if test -r "/dev/ptmx"; then
+  ac_cv_file__dev_ptmx=yes
+else
+  ac_cv_file__dev_ptmx=no
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_file__dev_ptmx" >&5
+echo "${ECHO_T}$ac_cv_file__dev_ptmx" >&6
+if test $ac_cv_file__dev_ptmx = yes; then
 
 cat >>confdefs.h <<\_ACEOF
 #define HAVE_DEV_PTMX 1
 _ACEOF
 
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
 fi
 
 echo "$as_me:$LINENO: checking for /dev/ptc" >&5
 echo $ECHO_N "checking for /dev/ptc... $ECHO_C" >&6
-
-if test -e /dev/ptc
-then
-  echo "$as_me:$LINENO: result: yes" >&5
-echo "${ECHO_T}yes" >&6
+if test "${ac_cv_file__dev_ptc+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  test "$cross_compiling" = yes &&
+  { { echo "$as_me:$LINENO: error: cannot check for file existence when cross compiling" >&5
+echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
+   { (exit 1); exit 1; }; }
+if test -r "/dev/ptc"; then
+  ac_cv_file__dev_ptc=yes
+else
+  ac_cv_file__dev_ptc=no
+fi
+fi
+echo "$as_me:$LINENO: result: $ac_cv_file__dev_ptc" >&5
+echo "${ECHO_T}$ac_cv_file__dev_ptc" >&6
+if test $ac_cv_file__dev_ptc = yes; then
 
 cat >>confdefs.h <<\_ACEOF
 #define HAVE_DEV_PTC 1
 _ACEOF
 
-else
-  echo "$as_me:$LINENO: result: no" >&5
-echo "${ECHO_T}no" >&6
 fi
 
+
 echo "$as_me:$LINENO: checking for %zd printf() format support" >&5
 echo $ECHO_N "checking for %zd printf() format support... $ECHO_C" >&6
 if test "$cross_compiling" = yes; then

Modified: python/branches/bcannon-sandboxing/configure.in
==============================================================================
--- python/branches/bcannon-sandboxing/configure.in	(original)
+++ python/branches/bcannon-sandboxing/configure.in	Wed Aug  2 00:51:44 2006
@@ -2374,8 +2374,34 @@
 )
 
 dnl Check if system zlib has *Copy() functions
+dnl
+dnl On MacOSX the linker will search for dylibs on the entire linker path
+dnl before searching for static libraries. setup.py adds -Wl,-search_paths_first
+dnl to revert to a more traditional unix behaviour and make it possible to
+dnl override the system libz with a local static library of libz. Temporarily
+dnl add that flag to our CFLAGS as well to ensure that we check the version
+dnl of libz that will be used by setup.py. 
+dnl The -L/usr/local/lib is needed as wel to get the same compilation 
+dnl environment as setup.py (and leaving it out can cause configure to use the
+dnl wrong version of the library)
+case $ac_sys_system/$ac_sys_release in
+Darwin/*) 
+	_CUR_CFLAGS="${CFLAGS}"
+	_CUR_LDFLAGS="${LDFLAGS}"
+	CFLAGS="${CFLAGS} -Wl,-search_paths_first"
+	LDFLAGS="${LDFLAGS} -Wl,-search_paths_first -L/usr/local/lib"
+	;;
+esac
+
 AC_CHECK_LIB(z, inflateCopy, AC_DEFINE(HAVE_ZLIB_COPY, 1, Define if the zlib library has inflateCopy))
 
+case $ac_sys_system/$ac_sys_release in
+Darwin/*) 
+	CFLAGS="${_CUR_CFLAGS}"
+	LDFLAGS="${_CUR_LDFLAGS}"
+	;;
+esac
+
 AC_MSG_CHECKING(for hstrerror)
 AC_TRY_LINK([
 #include "confdefs.h" 
@@ -3338,27 +3364,8 @@
   AC_MSG_RESULT(no)
 )
 
-AC_MSG_CHECKING(for /dev/ptmx)
-
-if test -e /dev/ptmx
-then
-  AC_MSG_RESULT(yes)
-  AC_DEFINE(HAVE_DEV_PTMX, 1,
-  [Define if we have /dev/ptmx.])
-else
-  AC_MSG_RESULT(no)
-fi
-
-AC_MSG_CHECKING(for /dev/ptc)
-
-if test -e /dev/ptc
-then
-  AC_MSG_RESULT(yes)
-  AC_DEFINE(HAVE_DEV_PTC, 1,
-  [Define if we have /dev/ptc.])
-else
-  AC_MSG_RESULT(no)
-fi
+AC_CHECK_FILE(/dev/ptmx, AC_DEFINE(HAVE_DEV_PTMX, 1, [Define if we have /dev/ptmx.]))
+AC_CHECK_FILE(/dev/ptc, AC_DEFINE(HAVE_DEV_PTC, 1, [Define if we have /dev/ptc.]))
 
 AC_MSG_CHECKING(for %zd printf() format support)
 AC_TRY_RUN([#include <stdio.h>


More information about the Python-checkins mailing list