[Stackless-checkins] r50634 - in stackless/trunk: Doc/Makefile.deps Doc/api/concrete.tex Doc/commontex/boilerplate.tex Doc/dist/dist.tex Doc/howto/Makefile Doc/lib/lib.tex Doc/lib/libcookielib.tex Doc/lib/libctypes.tex Doc/lib/libetree.tex Doc/lib/libfuncs.tex Doc/lib/libstdtypes.tex Doc/lib/libsys.tex Doc/lib/libturtle.tex Doc/lib/libuuid.tex Doc/lib/libwarnings.tex Doc/tut/tut.tex Doc/whatsnew/whatsnew20.tex Doc/whatsnew/whatsnew23.tex Doc/whatsnew/whatsnew25.tex Include/patchlevel.h Include/pystate.h Lib/compiler/transformer.py Lib/ctypes/test/test_objects.py Lib/ctypes/test/test_parameters.py Lib/ctypes/test/test_pointers.py Lib/ctypes/test/test_structures.py Lib/ctypes/test/test_win32.py Lib/distutils/command/bdist_rpm.py Lib/distutils/command/upload.py Lib/distutils/msvccompiler.py Lib/distutils/sysconfig.py Lib/distutils/unixccompiler.py Lib/idlelib/Debugger.py Lib/idlelib/NEWS.txt Lib/idlelib/idlever.py Lib/inspect.py Lib/lib-tk/turtle.py Lib/logging/config.py Lib/logging/handle! rs.py Lib/mailbox.py Lib/msilib/__init__.py Lib/popen2.py Lib/sgmllib.py Lib/socket.py Lib/sqlite3/test/types.py Lib/sqlite3/test/userfunctions.py Lib/string.py Lib/subprocess.py Lib/tarfile.py Lib/telnetlib.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/xml_parsers.py Lib/test/fork_wait.py Lib/test/regrtest.py Lib/test/test__locale.py Lib/test/test_ast.py Lib/test/test_builtin.py Lib/test/test_bz2.py Lib/test/test_cmd_line.py Lib/test/test_commands.py Lib/test/test_compile.py Lib/test/test_compiler.py Lib/test/test_descr.py Lib/test/test_exceptions.py Lib/test/test_fcntl.py Lib/test/test_fork1.py Lib/test/test_inspect.py Lib/test/test_logging.py Lib/test/test_mailbox.py Lib/test/test_multibytecodec.py Lib/test/test_os.py Lib/test/test_pep292.py Lib/test/test_popen.py Lib/test/test_popen2.py Lib/test/test_pyexpat.py Lib/test/test_scope.py Lib/test/test_select! .py Lib/test/test_sgmllib.py Lib/test/test_socket.py Lib/test/test_socket_ssl.py Lib/test/test_socketserver.py Lib/test/test_subprocess.py Lib/test/test_support.py Lib/test/test_sys.py Lib/test/test_wait3.py Lib/test/test_wait4.py Lib/test/test_warnings.py Lib/warnings.py Lib/xmlcore/etree/ElementTree.py Mac/BuildScript/buil

richard.tew python-checkins at python.org
Fri Jul 14 14:40:10 CEST 2006


Author: richard.tew
Date: Fri Jul 14 14:39:40 2006
New Revision: 50634

Added:
   stackless/trunk/Doc/lib/libetree.tex
      - copied unchanged from r50568, python/trunk/Doc/lib/libetree.tex
   stackless/trunk/Doc/lib/libuuid.tex
      - copied unchanged from r50568, python/trunk/Doc/lib/libuuid.tex
   stackless/trunk/Lib/test/crashers/bogus_code_obj.py
      - copied unchanged from r50568, python/trunk/Lib/test/crashers/bogus_code_obj.py
   stackless/trunk/Lib/test/crashers/borrowed_ref_1.py
      - copied unchanged from r50568, python/trunk/Lib/test/crashers/borrowed_ref_1.py
   stackless/trunk/Lib/test/crashers/borrowed_ref_2.py
      - copied unchanged from r50568, python/trunk/Lib/test/crashers/borrowed_ref_2.py
   stackless/trunk/Lib/test/crashers/gc_inspection.py
      - copied unchanged from r50568, python/trunk/Lib/test/crashers/gc_inspection.py
Removed:
   stackless/trunk/Lib/test/crashers/xml_parsers.py
   stackless/trunk/Mac/Demo/calldll/
Modified:
   stackless/trunk/Doc/Makefile.deps
   stackless/trunk/Doc/api/concrete.tex
   stackless/trunk/Doc/commontex/boilerplate.tex
   stackless/trunk/Doc/dist/dist.tex
   stackless/trunk/Doc/howto/Makefile
   stackless/trunk/Doc/lib/lib.tex
   stackless/trunk/Doc/lib/libcookielib.tex
   stackless/trunk/Doc/lib/libctypes.tex
   stackless/trunk/Doc/lib/libfuncs.tex
   stackless/trunk/Doc/lib/libstdtypes.tex
   stackless/trunk/Doc/lib/libsys.tex
   stackless/trunk/Doc/lib/libturtle.tex
   stackless/trunk/Doc/lib/libwarnings.tex
   stackless/trunk/Doc/tut/tut.tex
   stackless/trunk/Doc/whatsnew/whatsnew20.tex
   stackless/trunk/Doc/whatsnew/whatsnew23.tex
   stackless/trunk/Doc/whatsnew/whatsnew25.tex
   stackless/trunk/Include/patchlevel.h
   stackless/trunk/Include/pystate.h
   stackless/trunk/Lib/compiler/transformer.py
   stackless/trunk/Lib/ctypes/test/test_objects.py
   stackless/trunk/Lib/ctypes/test/test_parameters.py
   stackless/trunk/Lib/ctypes/test/test_pointers.py
   stackless/trunk/Lib/ctypes/test/test_structures.py
   stackless/trunk/Lib/ctypes/test/test_win32.py
   stackless/trunk/Lib/distutils/command/bdist_rpm.py
   stackless/trunk/Lib/distutils/command/upload.py
   stackless/trunk/Lib/distutils/msvccompiler.py
   stackless/trunk/Lib/distutils/sysconfig.py
   stackless/trunk/Lib/distutils/unixccompiler.py
   stackless/trunk/Lib/idlelib/Debugger.py
   stackless/trunk/Lib/idlelib/NEWS.txt
   stackless/trunk/Lib/idlelib/idlever.py
   stackless/trunk/Lib/inspect.py
   stackless/trunk/Lib/lib-tk/turtle.py
   stackless/trunk/Lib/logging/config.py
   stackless/trunk/Lib/logging/handlers.py
   stackless/trunk/Lib/mailbox.py
   stackless/trunk/Lib/msilib/__init__.py
   stackless/trunk/Lib/popen2.py
   stackless/trunk/Lib/sgmllib.py
   stackless/trunk/Lib/socket.py
   stackless/trunk/Lib/sqlite3/test/types.py
   stackless/trunk/Lib/sqlite3/test/userfunctions.py
   stackless/trunk/Lib/string.py
   stackless/trunk/Lib/subprocess.py
   stackless/trunk/Lib/tarfile.py
   stackless/trunk/Lib/telnetlib.py
   stackless/trunk/Lib/test/fork_wait.py
   stackless/trunk/Lib/test/regrtest.py
   stackless/trunk/Lib/test/test__locale.py
   stackless/trunk/Lib/test/test_ast.py
   stackless/trunk/Lib/test/test_builtin.py
   stackless/trunk/Lib/test/test_bz2.py
   stackless/trunk/Lib/test/test_cmd_line.py
   stackless/trunk/Lib/test/test_commands.py
   stackless/trunk/Lib/test/test_compile.py
   stackless/trunk/Lib/test/test_compiler.py
   stackless/trunk/Lib/test/test_descr.py
   stackless/trunk/Lib/test/test_exceptions.py
   stackless/trunk/Lib/test/test_fcntl.py
   stackless/trunk/Lib/test/test_fork1.py
   stackless/trunk/Lib/test/test_inspect.py
   stackless/trunk/Lib/test/test_logging.py
   stackless/trunk/Lib/test/test_mailbox.py
   stackless/trunk/Lib/test/test_multibytecodec.py
   stackless/trunk/Lib/test/test_os.py
   stackless/trunk/Lib/test/test_pep292.py
   stackless/trunk/Lib/test/test_popen.py
   stackless/trunk/Lib/test/test_popen2.py
   stackless/trunk/Lib/test/test_pyexpat.py
   stackless/trunk/Lib/test/test_scope.py
   stackless/trunk/Lib/test/test_select.py
   stackless/trunk/Lib/test/test_sgmllib.py
   stackless/trunk/Lib/test/test_socket.py
   stackless/trunk/Lib/test/test_socket_ssl.py
   stackless/trunk/Lib/test/test_socketserver.py
   stackless/trunk/Lib/test/test_subprocess.py
   stackless/trunk/Lib/test/test_support.py
   stackless/trunk/Lib/test/test_sys.py
   stackless/trunk/Lib/test/test_wait3.py
   stackless/trunk/Lib/test/test_wait4.py
   stackless/trunk/Lib/test/test_warnings.py
   stackless/trunk/Lib/warnings.py
   stackless/trunk/Lib/xmlcore/etree/ElementTree.py
   stackless/trunk/Mac/BuildScript/build-installer.py
   stackless/trunk/Mac/BuildScript/resources/Welcome.rtf
   stackless/trunk/Mac/BuildScript/scripts/postflight.framework
   stackless/trunk/Mac/Demo/applescript.html
   stackless/trunk/Mac/Demo/index.html
   stackless/trunk/Makefile.pre.in
   stackless/trunk/Misc/NEWS
   stackless/trunk/Misc/RPM/python-2.5.spec
   stackless/trunk/Misc/Vim/python.vim
   stackless/trunk/Misc/build.sh
   stackless/trunk/Misc/cheatsheet
   stackless/trunk/Misc/valgrind-python.supp
   stackless/trunk/Modules/_ctypes/_ctypes.c
   stackless/trunk/Modules/_ctypes/callbacks.c
   stackless/trunk/Modules/_ctypes/callproc.c
   stackless/trunk/Modules/_ctypes/cfield.c
   stackless/trunk/Modules/_ctypes/libffi/src/x86/darwin.S
   stackless/trunk/Modules/_ctypes/libffi/src/x86/ffi_darwin.c
   stackless/trunk/Modules/_ctypes/libffi_msvc/ffi.c
   stackless/trunk/Modules/_ctypes/libffi_msvc/fficonfig.h
   stackless/trunk/Modules/_ctypes/libffi_msvc/ffitarget.h
   stackless/trunk/Modules/_sqlite/cursor.c
   stackless/trunk/Modules/_sqlite/module.h
   stackless/trunk/Modules/_ssl.c
   stackless/trunk/Modules/bz2module.c
   stackless/trunk/Modules/cPickle.c
   stackless/trunk/Modules/cryptmodule.c
   stackless/trunk/Modules/dlmodule.c
   stackless/trunk/Modules/fpectlmodule.c
   stackless/trunk/Modules/getpath.c
   stackless/trunk/Modules/posixmodule.c
   stackless/trunk/Modules/pyexpat.c
   stackless/trunk/Modules/selectmodule.c
   stackless/trunk/Modules/socketmodule.c
   stackless/trunk/Modules/timemodule.c
   stackless/trunk/Objects/abstract.c
   stackless/trunk/Objects/cellobject.c
   stackless/trunk/Objects/descrobject.c
   stackless/trunk/Objects/exceptions.c
   stackless/trunk/Objects/fileobject.c
   stackless/trunk/Objects/typeobject.c
   stackless/trunk/PCbuild/readme.txt
   stackless/trunk/Python/ast.c
   stackless/trunk/Python/ceval.c
   stackless/trunk/Python/codecs.c
   stackless/trunk/Python/compile.c
   stackless/trunk/Python/import.c
   stackless/trunk/Python/mystrtoul.c
   stackless/trunk/Python/pystate.c
   stackless/trunk/Python/pystrtod.c
   stackless/trunk/Python/sysmodule.c
   stackless/trunk/README
   stackless/trunk/Stackless/core/stacklesseval.c
   stackless/trunk/Stackless/module/scheduling.c
   stackless/trunk/Tools/msi/   (props changed)
   stackless/trunk/Tools/msi/msi.py
   stackless/trunk/configure
   stackless/trunk/configure.in
   stackless/trunk/setup.py
Log:
Merged in the changelists included up to the 2.5b2 tag. This fixes the problems with inconsistent recursion depth in scheduling.c:schedule_tasklet_destruct, and the Stackless unit test warnings.

Modified: stackless/trunk/Doc/Makefile.deps
==============================================================================
--- stackless/trunk/Doc/Makefile.deps	(original)
+++ stackless/trunk/Doc/Makefile.deps	Fri Jul 14 14:39:40 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: stackless/trunk/Doc/api/concrete.tex
==============================================================================
--- stackless/trunk/Doc/api/concrete.tex	(original)
+++ stackless/trunk/Doc/api/concrete.tex	Fri Jul 14 14:39:40 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: stackless/trunk/Doc/commontex/boilerplate.tex
==============================================================================
--- stackless/trunk/Doc/commontex/boilerplate.tex	(original)
+++ stackless/trunk/Doc/commontex/boilerplate.tex	Fri Jul 14 14:39:40 2006
@@ -5,5 +5,5 @@
 	Email: \email{docs at python.org}
 }
 
-\date{20 June, 2006}			% XXX update before final release!
+\date{11th July, 2006}			% XXX update before final release!
 \input{patchlevel}		% include Python version information

Modified: stackless/trunk/Doc/dist/dist.tex
==============================================================================
--- stackless/trunk/Doc/dist/dist.tex	(original)
+++ stackless/trunk/Doc/dist/dist.tex	Fri Jul 14 14:39:40 2006
@@ -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}

Modified: stackless/trunk/Doc/howto/Makefile
==============================================================================
--- stackless/trunk/Doc/howto/Makefile	(original)
+++ stackless/trunk/Doc/howto/Makefile	Fri Jul 14 14:39:40 2006
@@ -1,88 +1,84 @@
+# Makefile for the HOWTO directory
+# LaTeX HOWTOs can be turned into HTML, PDF, PS, DVI or plain text output.
+# reST HOWTOs can only be turned into HTML.
 
-MKHOWTO=../tools/mkhowto
-WEBDIR=.
+# Variables to change
+
+# Paper size for non-HTML formats (letter or a4)
+PAPER=letter
+
+# Arguments to rst2html.py, and location of the script
 RSTARGS = --input-encoding=utf-8
-VPATH=.:dvi:pdf:ps:txt
+RST2HTML = rst2html.py
 
-# List of HOWTOs that aren't to be processed
+# List of HOWTOs that aren't to be processed.  This should contain the
+# base name of the HOWTO without any extension (e.g. 'advocacy',
+# 'unicode').
+REMOVE_HOWTOS =
 
-REMOVE_HOWTO =
+MKHOWTO=../tools/mkhowto
+WEBDIR=.
+PAPERDIR=../paper-$(PAPER)
+HTMLDIR=../html
 
 # Determine list of files to be built
-
-HOWTO=$(filter-out $(REMOVE_HOWTO),$(wildcard *.tex))
-RST_SOURCES =	$(shell echo *.rst)
-DVI  =$(patsubst %.tex,%.dvi,$(HOWTO))
-PDF  =$(patsubst %.tex,%.pdf,$(HOWTO))
-PS   =$(patsubst %.tex,%.ps,$(HOWTO))
-TXT  =$(patsubst %.tex,%.txt,$(HOWTO))
-HTML =$(patsubst %.tex,%,$(HOWTO))
+TEX_SOURCES = $(wildcard *.tex)
+RST_SOURCES = $(wildcard *.rst)
+TEX_NAMES = $(filter-out $(REMOVE_HOWTOS),$(patsubst %.tex,%,$(TEX_SOURCES)))
+
+PAPER_PATHS=$(addprefix $(PAPERDIR)/,$(TEX_NAMES))
+DVI  =$(addsuffix .dvi,$(PAPER_PATHS))
+PDF  =$(addsuffix .pdf,$(PAPER_PATHS))
+PS   =$(addsuffix .ps,$(PAPER_PATHS))
+
+ALL_HOWTO_NAMES = $(TEX_NAMES) $(patsubst %.rst,%,$(RST_SOURCES))
+HOWTO_NAMES = $(filter-out $(REMOVE_HOWTOS),$(ALL_HOWTO_NAMES))
+HTML = $(addprefix $(HTMLDIR)/,$(HOWTO_NAMES))
 
 # Rules for building various formats
-%.dvi : %.tex
+
+# reST to HTML
+$(HTMLDIR)/%: %.rst
+	if [ ! -d $@ ] ; then mkdir $@ ; fi
+	$(RST2HTML) $(RSTARGS) $< >$@/index.html
+
+# LaTeX to various output formats
+$(PAPERDIR)/%.dvi : %.tex
 	$(MKHOWTO) --dvi $<
-	mv $@ dvi
+	mv $*.dvi $@
 
-%.pdf : %.tex
+$(PAPERDIR)/%.pdf : %.tex
 	$(MKHOWTO) --pdf $<
-	mv $@ pdf
+	mv $*.pdf $@
 
-%.ps : %.tex
+$(PAPERDIR)/%.ps : %.tex
 	$(MKHOWTO) --ps $<
-	mv $@ ps
+	mv $*.ps $@
 
-%.txt : %.tex
+$(HTMLDIR)/% : %.tex
+	$(MKHOWTO) --html --iconserver="." --dir $@ $<
+
+# Rule that isn't actually used -- we no longer support the 'txt' target.
+$(PAPERDIR)/%.txt : %.tex
 	$(MKHOWTO) --text $<
 	mv $@ txt
 
-% : %.tex
-	$(MKHOWTO) --html --iconserver="." $<
-	tar -zcvf html/$*.tgz $*
-	#zip -r html/$*.zip $*
-
 default:
 	@echo "'all'    -- build all files"
-	@echo "'dvi', 'pdf', 'ps', 'txt', 'html' -- build one format"
-
-all: $(HTML)
-
-.PHONY : dvi pdf ps txt html rst
-dvi: $(DVI)
+	@echo "'dvi', 'pdf', 'ps', 'html' -- build one format"
 
-pdf: $(PDF)
-ps:  $(PS)
-txt: $(TXT)
-html:$(HTML)
-
-# Rule to build collected tar files
-dist: #all
-	for i in dvi pdf ps txt ; do \
-	    cd $$i ; \
-	    tar -zcf All.tgz *.$$i ;\
-	    cd .. ;\
-	done
-
-# Rule to copy files to the Web tree on AMK's machine
-web: dist
-	cp dvi/* $(WEBDIR)/dvi
-	cp ps/* $(WEBDIR)/ps
-	cp pdf/* $(WEBDIR)/pdf
-	cp txt/* $(WEBDIR)/txt
-	for dir in $(HTML) ; do cp -rp $$dir $(WEBDIR) ; done
-	for ltx in $(HOWTO) ; do cp -p $$ltx $(WEBDIR)/latex ; done
+all: dvi pdf ps html
 
-rst: unicode.html
-
-%.html: %.rst
-	rst2html $(RSTARGS) $< >$@
+.PHONY : dvi pdf ps html
+dvi:  $(DVI)
+pdf:  $(PDF)
+ps:   $(PS)
+html: $(HTML)
 
 clean:
-	rm -f *~ *.log *.ind *.l2h *.aux *.toc *.how
-	rm -f *.dvi *.ps *.pdf *.bkm
-	rm -f unicode.html
+	rm -f *~ *.log *.ind *.l2h *.aux *.toc *.how *.bkm
+	rm -f *.dvi *.pdf *.ps
 
 clobber:
-	rm dvi/* ps/* pdf/* txt/* html/*
-
-
-
+	rm -rf $(HTML)
+	rm -rf $(DVI) $(PDF) $(PS)

Modified: stackless/trunk/Doc/lib/lib.tex
==============================================================================
--- stackless/trunk/Doc/lib/lib.tex	(original)
+++ stackless/trunk/Doc/lib/lib.tex	Fri Jul 14 14:39:40 2006
@@ -171,6 +171,7 @@
 \input{xmlsaxhandler}
 \input{xmlsaxutils}
 \input{xmlsaxreader}
+\input{libetree}
 % \input{libxmllib}
 
 \input{fileformats}		% Miscellaneous file formats
@@ -303,6 +304,7 @@
 \input{libsmtplib}
 \input{libsmtpd}
 \input{libtelnetlib}
+\input{libuuid}
 \input{liburlparse}
 \input{libsocksvr}
 \input{libbasehttp}

Modified: stackless/trunk/Doc/lib/libcookielib.tex
==============================================================================
--- stackless/trunk/Doc/lib/libcookielib.tex	(original)
+++ stackless/trunk/Doc/lib/libcookielib.tex	Fri Jul 14 14:39:40 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: stackless/trunk/Doc/lib/libctypes.tex
==============================================================================
--- stackless/trunk/Doc/lib/libctypes.tex	(original)
+++ stackless/trunk/Doc/lib/libctypes.tex	Fri Jul 14 14:39:40 2006
@@ -1543,13 +1543,13 @@
 The following public attributes are available, their name starts with
 an underscore to not clash with exported function names:
 
-\begin{datadescni}{_handle: memberdesc}
+\begin{memberdesc}{_handle}
 The system handle used to access the library.
-\end{datadescni}
+\end{memberdesc}
 
-\begin{datadescni}{_name: memberdesc}
+\begin{memberdesc}{_name}
 The name of the library passed in the contructor.
-\end{datadescni}
+\end{memberdesc}
 
 Shared libraries can also be loaded by using one of the prefabricated
 objects, which are instances of the \class{LibraryLoader} class, either by
@@ -1648,6 +1648,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}
@@ -1748,7 +1754,7 @@
 Each item in this tuple contains further information about a
 parameter, it must be a tuple containing 1, 2, or 3 items.
 
-The first item is an integer containing flags for the parameter.
+The first item is an integer containing flags for the parameter:
 
 \begin{datadescni}{1}
 Specifies an input parameter to the function.
@@ -2374,7 +2380,7 @@
 \code{u} field is defined as anonymous field, it is now possible to
 access the members directly off the TYPEDESC instance.
 \code{td.lptdesc} and \code{td.u.lptdesc} are equivalent, but the former
-is faster since it does not need to create a temporary \code{{\_}U}
+is faster since it does not need to create a temporary union
 instance:
 \begin{verbatim}
 td = TYPEDESC()
@@ -2386,9 +2392,16 @@
 
 It is possible to defined sub-subclasses of structures, they inherit
 the fields of the base class.  If the subclass definition has a
-separate``{\_}fields{\_}`` variable, the fields specified in this are
+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: stackless/trunk/Doc/lib/libfuncs.tex
==============================================================================
--- stackless/trunk/Doc/lib/libfuncs.tex	(original)
+++ stackless/trunk/Doc/lib/libfuncs.tex	Fri Jul 14 14:39:40 2006
@@ -468,10 +468,10 @@
   Construct a list from those elements of \var{list} for which
   \var{function} returns true.  \var{list} may be either a sequence, a
   container which supports iteration, or an iterator,  If \var{list}
-  is a string or a tuple, the result also has that type; otherwise it
-  is always a list.  If \var{function} is \code{None}, the identity
-  function is assumed, that is, all elements of \var{list} that are false
-  (zero or empty) are removed.
+  is a string or a tuple, the result
+  also has that type; otherwise it is always a list.  If \var{function} is
+  \code{None}, the identity function is assumed, that is, all elements of
+  \var{list} that are false are removed.
 
   Note that \code{filter(function, \var{list})} is equivalent to
   \code{[item for item in \var{list} if function(item)]} if function is
@@ -781,15 +781,30 @@
 \begin{verbatim}
 class C(object):
     def __init__(self): self.__x = None
-    def getx(self): return self.__x
-    def setx(self, value): self.__x = value
-    def delx(self): del self.__x
+    def getx(self): return self._x
+    def setx(self, value): self._x = value
+    def delx(self): del self._x
     x = property(getx, setx, delx, "I'm the 'x' property.")
 \end{verbatim}
 
   If given, \var{doc} will be the docstring of the property attribute.
   Otherwise, the property will copy \var{fget}'s docstring (if it
-  exists).
+  exists).  This makes it possible to create read-only properties
+  easily using \function{property()} as a decorator:
+
+\begin{verbatim}
+class Parrot(object):
+    def __init__(self):
+        self._voltage = 100000
+
+    @property
+    def voltage(self):
+        """Get the current voltage."""
+        return self._voltage
+\end{verbatim}
+
+  turns the \method{voltage()} method into a ``getter'' for a read-only
+  attribute with the same name.
 
   \versionadded{2.2}
   \versionchanged[Use \var{fget}'s docstring if no \var{doc} given]{2.5}
@@ -993,8 +1008,30 @@
 \begin{funcdesc}{sorted}{iterable\optional{, cmp\optional{,
                          key\optional{, reverse}}}}
   Return a new sorted list from the items in \var{iterable}.
-  The optional arguments \var{cmp}, \var{key}, and \var{reverse}
-  have the same meaning as those for the \method{list.sort()} method.
+
+  The optional arguments \var{cmp}, \var{key}, and \var{reverse} have
+  the same meaning as those for the \method{list.sort()} method
+  (described in section~\ref{typesseq-mutable}).
+
+  \var{cmp} specifies a custom comparison function of two arguments
+  (iterable elements) which should return a negative, zero or positive
+  number depending on whether the first argument is considered smaller
+  than, equal to, or larger than the second argument:
+  \samp{\var{cmp}=\keyword{lambda} \var{x},\var{y}:
+  \function{cmp}(x.lower(), y.lower())}
+     
+  \var{key} specifies a function of one argument that is used to
+     extract a comparison key from each list element:
+     \samp{\var{key}=\function{str.lower}}
+
+  \var{reverse} is a boolean value.  If set to \code{True}, then the
+     list elements are sorted as if each comparison were reversed.
+
+  In general, the \var{key} and \var{reverse} conversion processes are
+  much faster than specifying an equivalent \var{cmp} function.  This is
+  because \var{cmp} is called multiple times for each list element while
+  \var{key} and \var{reverse} touch each element only once.
+
   \versionadded{2.4}
 \end{funcdesc}
 

Modified: stackless/trunk/Doc/lib/libstdtypes.tex
==============================================================================
--- stackless/trunk/Doc/lib/libstdtypes.tex	(original)
+++ stackless/trunk/Doc/lib/libstdtypes.tex	Fri Jul 14 14:39:40 2006
@@ -567,6 +567,7 @@
 
 
 \subsubsection{String Methods \label{string-methods}}
+\indexii{string}{methods}
 
 These are the string methods which both 8-bit strings and Unicode
 objects support:
@@ -1100,7 +1101,8 @@
   \lineiii{\var{s}[\var{i}] = \var{x}}
 	{item \var{i} of \var{s} is replaced by \var{x}}{}
   \lineiii{\var{s}[\var{i}:\var{j}] = \var{t}}
-  	{slice of \var{s} from \var{i} to \var{j} is replaced by \var{t}}{}
+  	{slice of \var{s} from \var{i} to \var{j} 
+         is replaced by the contents of the iterable \var{t}}{}
   \lineiii{del \var{s}[\var{i}:\var{j}]}
 	{same as \code{\var{s}[\var{i}:\var{j}] = []}}{}
   \lineiii{\var{s}[\var{i}:\var{j}:\var{k}] = \var{t}}

Modified: stackless/trunk/Doc/lib/libsys.tex
==============================================================================
--- stackless/trunk/Doc/lib/libsys.tex	(original)
+++ stackless/trunk/Doc/lib/libsys.tex	Fri Jul 14 14:39:40 2006
@@ -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,7 +258,7 @@
 \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 
+\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 Windows NT+, file names are Unicode natively, so no conversion
@@ -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: stackless/trunk/Doc/lib/libturtle.tex
==============================================================================
--- stackless/trunk/Doc/lib/libturtle.tex	(original)
+++ stackless/trunk/Doc/lib/libturtle.tex	Fri Jul 14 14:39:40 2006
@@ -42,6 +42,19 @@
 line.
 \end{funcdesc}
 
+\begin{funcdesc}{speed}{speed}
+Set the speed of the turtle. Valid values for the parameter
+\var{speed} are \code{'fastest'} (no delay), \code{'fast'},
+(delay 5ms), \code{'normal'} (delay 10ms), \code{'slow'}
+(delay 15ms), and \code{'slowest'} (delay 20ms).
+\versionadded{2.5}
+\end{funcdesc}
+
+\begin{funcdesc}{delay}{delay}
+Set the speed of the turtle to \var{delay}, which is given
+in ms. \versionadded{2.5}
+\end{funcdesc}
+
 \begin{funcdesc}{forward}{distance}
 Go forward \var{distance} steps.
 \end{funcdesc}
@@ -94,6 +107,18 @@
 and call \code{fill(0)} when you finish to draw the path.
 \end{funcdesc}
 
+\begin{funcdesc}{begin\_fill}{}
+Switch turtle into filling mode; 
+Must eventually be followed by a corresponding end_fill() call.
+Otherwise it will be ignored.
+\versionadded{2.5}
+\end{funcdesc}
+
+\begin{funcdesc}{end\_fill}{}
+End filling mode, and fill the shape; equivalent to \code{fill(0)}.
+\versionadded{2.5}
+\end{funcdesc}
+
 \begin{funcdesc}{circle}{radius\optional{, extent}}
 Draw a circle with radius \var{radius} whose center-point is
 \var{radius} units left of the turtle.
@@ -113,6 +138,49 @@
 specified either as two separate arguments or as a 2-tuple.
 \end{funcdesc}
 
+\begin{funcdesc}{towards}{x, y}
+Return the angle of the line from the turtle's position
+to the point \var{x}, \var{y}. The co-ordinates may be
+specified either as two separate arguments, as a 2-tuple,
+or as another pen object.
+\versionadded{2.5}
+\end{funcdesc}
+
+\begin{funcdesc}{heading}{}
+Return the current orientation of the turtle.
+\versionadded{2.3}
+\end{funcdesc}
+
+\begin{funcdesc}{setheading}{angle}
+Set the orientation of the turtle to \var{angle}.
+\versionadded{2.3}
+\end{funcdesc}
+
+\begin{funcdesc}{position}{}
+Return the current location of the turtle as an \code{(x,y)} pair.
+\versionadded{2.3}
+\end{funcdesc}
+
+\begin{funcdesc}{setx}{x}
+Set the x coordinate of the turtle to \var{x}.
+\versionadded{2.3}
+\end{funcdesc}
+
+\begin{funcdesc}{sety}{y}
+Set the y coordinate of the turtle to \var{y}.
+\versionadded{2.3}
+\end{funcdesc}
+
+\begin{funcdesc}{window\_width}{}
+Return the width of the canvas window.
+\versionadded{2.3}
+\end{funcdesc}
+
+\begin{funcdesc}{window\_height}{}
+Return the height of the canvas window.
+\versionadded{2.3}
+\end{funcdesc}
+
 This module also does \code{from math import *}, so see the
 documentation for the \refmodule{math} module for additional constants
 and functions useful for turtle graphics.
@@ -134,16 +202,21 @@
 pen. The constructor automatically creates a canvas do be drawn on.
 \end{classdesc}
 
+\begin{classdesc}{Turtle}{}
+Define a pen. This is essentially a synonym for \code{Pen()};
+\class{Turtle} is an empty subclass of \class{Pen}.
+\end{classdesc}
+
 \begin{classdesc}{RawPen}{canvas}
 Define a pen which draws on a canvas \var{canvas}. This is useful if 
 you want to use the module to create graphics in a ``real'' program.
 \end{classdesc}
 
-\subsection{Pen and RawPen Objects \label{pen-rawpen-objects}}
+\subsection{Turtle, Pen and RawPen Objects \label{pen-rawpen-objects}}
 
-\class{Pen} and \class{RawPen} objects have all the global functions
-described above, except for \function{demo()} as methods, which
-manipulate the given pen.
+\class{Turtle}, \class{Pen} and \class{RawPen} objects have all the
+global functions described above, except for \function{demo()} as
+methods, which manipulate the given pen.
 
 The only method which is more powerful as a method is
 \function{degrees()}.

Modified: stackless/trunk/Doc/lib/libwarnings.tex
==============================================================================
--- stackless/trunk/Doc/lib/libwarnings.tex	(original)
+++ stackless/trunk/Doc/lib/libwarnings.tex	Fri Jul 14 14:39:40 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: stackless/trunk/Doc/tut/tut.tex
==============================================================================
--- stackless/trunk/Doc/tut/tut.tex	(original)
+++ stackless/trunk/Doc/tut/tut.tex	Fri Jul 14 14:39:40 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: stackless/trunk/Doc/whatsnew/whatsnew20.tex
==============================================================================
--- stackless/trunk/Doc/whatsnew/whatsnew20.tex	(original)
+++ stackless/trunk/Doc/whatsnew/whatsnew20.tex	Fri Jul 14 14:39:40 2006
@@ -777,7 +777,7 @@
 
 Some work has been done to make integers and long integers a bit more
 interchangeable.  In 1.5.2, large-file support was added for Solaris,
-to allow reading files larger than 2Gb; this made the \method{tell()}
+to allow reading files larger than 2~GiB; this made the \method{tell()}
 method of file objects return a long integer instead of a regular
 integer.  Some code would subtract two file offsets and attempt to use
 the result to multiply a sequence or slice a string, but this raised a

Modified: stackless/trunk/Doc/whatsnew/whatsnew23.tex
==============================================================================
--- stackless/trunk/Doc/whatsnew/whatsnew23.tex	(original)
+++ stackless/trunk/Doc/whatsnew/whatsnew23.tex	Fri Jul 14 14:39:40 2006
@@ -1479,7 +1479,7 @@
 ('amk', 500)
 \end{verbatim}
 
-\item The \module{gzip} module can now handle files exceeding 2~Gb.  
+\item The \module{gzip} module can now handle files exceeding 2~GiB.  
 
 \item The new \module{heapq} module contains an implementation of a
 heap queue algorithm.  A heap is an array-like data structure that

Modified: stackless/trunk/Doc/whatsnew/whatsnew25.tex
==============================================================================
--- stackless/trunk/Doc/whatsnew/whatsnew25.tex	(original)
+++ stackless/trunk/Doc/whatsnew/whatsnew25.tex	Fri Jul 14 14:39:40 2006
@@ -2,12 +2,11 @@
 \usepackage{distutils}
 % $Id$
 
-% wsgiref section
 % Fix XXX comments
 % Count up the patches and bugs
 
 \title{What's New in Python 2.5}
-\release{0.2}
+\release{0.3}
 \author{A.M. Kuchling}
 \authoraddress{\email{amk at amk.ca}}
 
@@ -15,31 +14,51 @@
 \maketitle
 \tableofcontents
 
-This article explains the new features in Python 2.5.  No release date
-for Python 2.5 has been set; it will probably be released in the
-autumn of 2006.  \pep{356} describes the planned release schedule.
-
-Comments, suggestions, and error reports are welcome; please e-mail them 
-to the author or open a bug in the Python bug tracker.
-
-% XXX Compare with previous release in 2 - 3 sentences here.
-
-This article doesn't attempt to provide a complete specification of
-the new features, but instead provides a convenient overview.  For
-full details, you should refer to the documentation for Python 2.5.
+This article explains the new features in Python 2.5.  The final
+release of Python 2.5 is scheduled for August 2006;
+\pep{356} describes the planned release schedule.
+
+The changes in Python 2.5 are an interesting mix of language and
+library improvements. The library enhancements will be more important
+to Python's user community, I think, because several widely-useful
+packages were added.  New modules include ElementTree for XML
+processing (section~\ref{module-etree}), the SQLite database module
+(section~\ref{module-sqlite}), and the \module{ctypes} module for
+calling C functions (section~\ref{module-ctypes}).
+
+The language changes are of middling significance.  Some pleasant new
+features were added, but most of them aren't features that you'll use
+every day.  Conditional expressions were finally added to the language
+using a novel syntax; see section~\ref{pep-308}.  The new
+'\keyword{with}' statement will make writing cleanup code easier
+(section~\ref{pep-343}).  Values can now be passed into generators
+(section~\ref{pep-342}).  Imports are now visible as either absolute
+or relative (section~\ref{pep-328}).  Some corner cases of exception
+handling are handled better (section~\ref{pep-341}).  All these
+improvements are worthwhile, but they're improvements to one specific
+language feature or another; none of them are broad modifications to
+Python's semantics.
+
+This article doesn't try to be a complete specification of the new
+features; instead changes are briefly introduced using helpful
+examples.  For full details, you should always refer to the
+documentation for Python 2.5.
 % XXX add hyperlink when the documentation becomes available online.
 If you want to understand the complete implementation and design
 rationale, refer to the PEP for a particular new feature.
 
+Comments, suggestions, and error reports for this document are
+welcome; please e-mail them to the author or open a bug in the Python
+bug tracker.
 
 %======================================================================
 \section{PEP 308: Conditional Expressions\label{pep-308}}
 
 For a long time, people have been requesting a way to write
-conditional expressions, expressions that return value A or value B
-depending on whether a Boolean value is true or false.  A conditional
-expression lets you write a single assignment statement that has the
-same effect as the following:
+conditional expressions, which are expressions that return value A or
+value B depending on whether a Boolean value is true or false.  A
+conditional expression lets you write a single assignment statement
+that has the same effect as the following:
 
 \begin{verbatim}
 if condition:
@@ -798,7 +817,7 @@
 decorator that are useful for writing objects for use with the
 '\keyword{with}' statement.
 
-The decorator is called \function{contextfactory}, and lets you write
+The decorator is called \function{contextmanager}, and lets you write
 a single generator function instead of defining a new class.  The generator
 should yield exactly one value.  The code up to the \keyword{yield}
 will be executed as the \method{__enter__()} method, and the value
@@ -812,9 +831,9 @@
 using this decorator as:
 
 \begin{verbatim}
-from contextlib import contextfactory
+from contextlib import contextmanager
 
- at contextfactory
+ at contextmanager
 def db_transaction (connection):
     cursor = connection.cursor()
     try:
@@ -960,7 +979,7 @@
 already more bytes than a 32-bit address space can contain.
 
 It's possible to address that much memory on a 64-bit platform,
-however.  The pointers for a list that size would only require 16GiB
+however.  The pointers for a list that size would only require 16~GiB
 of space, so it's not unreasonable that Python programmers might
 construct lists that large.  Therefore, the Python interpreter had to
 be changed to use some type other than \ctype{int}, and this will be a
@@ -1151,9 +1170,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.)
+\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:
@@ -1384,6 +1406,16 @@
 code snippets that are usage examples intended for the reader and
 aren't actually test cases.
 
+An \var{encoding} parameter was added to the \function{testfile()}
+function and the \class{DocFileSuite} class to specify the file's
+encoding.  This makes it easier to use non-ASCII characters in 
+tests contained within a docstring.  (Contributed by Bjorn Tillenius.)
+% Patch 1080727
+
+\item The \module{email} package has been updated to version 4.0.
+% XXX need to provide some more detail here
+(Contributed by Barry Warsaw.)
+
 \item The \module{fileinput} module was made more flexible.
 Unicode filenames are now supported, and a \var{mode} parameter that
 defaults to \code{"r"} was added to the
@@ -1402,6 +1434,7 @@
 collection sweep will be made.  The existing \function{gc.collect()}
 function now takes an optional \var{generation} argument of 0, 1, or 2
 to specify which generation to collect.
+(Contributed by Barry Warsaw.)
 
 \item The \function{nsmallest()} and 
 \function{nlargest()} functions in the \module{heapq} module 
@@ -1540,6 +1573,9 @@
 performing many different operations and reducing the result to a
 single number as \file{pystone.py} does.
 
+\item The \module{pyexpat} module now uses version 2.0 of the Expat parser.
+(Contributed by Trent Mick.)
+
 \item The old \module{regex} and \module{regsub} modules, which have been 
 deprecated ever since Python 2.0, have finally been deleted.  
 Other deleted modules: \module{statcache}, \module{tzparse},
@@ -1682,6 +1718,14 @@
 
 (Contributed by Ka-Ping Yee.)
 
+\item The \module{weakref} module's \class{WeakKeyDictionary} and
+\class{WeakValueDictionary} types gained new methods for iterating
+over the weak references contained in the dictionary. 
+\method{iterkeyrefs()} and \method{keyrefs()} methods were
+added to \class{WeakKeyDictionary}, and
+\method{itervaluerefs()} and \method{valuerefs()} were added to
+\class{WeakValueDictionary}.  (Contributed by Fred L.~Drake, Jr.)
+
 \item The \module{webbrowser} module received a number of
 enhancements.
 It's now usable as a script with \code{python -m webbrowser}, taking a
@@ -1693,10 +1737,16 @@
 additional feature, an \var{autoraise} parameter that signals whether
 to raise the open window when possible. A number of additional
 browsers were added to the supported list such as Firefox, Opera,
-Konqueror, and elinks.  (Contributed by Oleg Broytmann and George
+Konqueror, and elinks.  (Contributed by Oleg Broytmann and Georg
 Brandl.)
 % Patch #754022
 
+\item The 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 
@@ -1705,6 +1755,12 @@
       (Contributed by Skip Montanaro.)
 % Patch 1120353
 
+\item The \module{zipfile} module now supports the ZIP64 version of the 
+format, meaning that a .zip archive can now be larger than 4~GiB and
+can contain individual files larger than 4~GiB.  (Contributed by
+Ronald Oussoren.)
+% Patch 1446489
+
 \item The \module{zlib} module's \class{Compress} and \class{Decompress}
 objects now support a \method{copy()} method that makes a copy of the 
 object's internal state and returns a new 
@@ -1795,6 +1851,9 @@
 \seeurl{http://starship.python.net/crew/theller/ctypes/}
 {The ctypes web page, with a tutorial, reference, and FAQ.}
 
+\seeurl{../lib/module-ctypes.html}{The documentation 
+for the \module{ctypes} module.}
+
 \end{seealso}
 
 
@@ -1906,7 +1965,6 @@
 \seeurl{http://effbot.org/zone/element-index.htm}
 {Official documentation for ElementTree.}
 
-
 \end{seealso}
 
 
@@ -1957,6 +2015,13 @@
 return the digest value as a binary string or a string of hex digits,
 and \method{copy()} returns a new hashing object with the same digest state.
 
+\begin{seealso}
+
+\seeurl{../lib/module-hashlib.html}{The documentation 
+for the \module{hashlib} module.}
+
+\end{seealso}
+
 
 %======================================================================
 \subsection{The sqlite3 package\label{module-sqlite}}
@@ -2067,6 +2132,9 @@
 {The SQLite web page; the documentation describes the syntax and the
 available data types for the supported SQL dialect.}
 
+\seeurl{../lib/module-sqlite3.html}{The documentation 
+for the \module{sqlite3} module.}
+
 \seepep{249}{Database API Specification 2.0}{PEP written by
 Marc-Andr\'e Lemburg.}
 
@@ -2074,10 +2142,9 @@
 
 
 %======================================================================
-%\subsection{The wsgiref package\label{module-wsgiref}}
+\subsection{The wsgiref package\label{module-wsgiref}}
 
 % XXX should this be in a PEP 333 section instead?
-\begin{comment}
 
 The Web Server Gateway Interface (WSGI) v1.0 defines a standard
 interface between web servers and Python web applications and is
@@ -2086,10 +2153,7 @@
 
 The package includes a basic HTTP server that will run a WSGI
 application; this server is useful for debugging but isn't intended for 
-production use.
-
-% XXX structure of WSGI applications?  
-% XXX provide an example using Django or some other framework?
+production use.  Setting up a server takes only a few lines of code:
 
 \begin{verbatim}
 from wsgiref import simple_server
@@ -2098,21 +2162,23 @@
 
 host = ''
 port = 8000
-httpd = make_server(host, port, wsgi_app)
+httpd = simple_server.make_server(host, port, wsgi_app)
 httpd.serve_forever()
 \end{verbatim}
 
+% XXX discuss structure of WSGI applications?  
+% XXX provide an example using Django or some other framework?
 
 \begin{seealso}
 
+\seeurl{http://www.wsgi.org}{A central web site for WSGI-related resources.}
+
 \seepep{333}{Python Web Server Gateway Interface v1.0}{PEP written by
 Phillip J. Eby.}
 
 \end{seealso}
 
 
-\end{comment}
-
 % ======================================================================
 \section{Build and C API Changes\label{build-api}}
 
@@ -2146,12 +2212,13 @@
 for_loop = ast.body[1]
 \end{verbatim}
 
-No documentation has been written for the AST code yet.  To start
-learning about it, read the definition of the various AST nodes in
-\file{Parser/Python.asdl}.  A Python script reads this file and
-generates a set of C structure definitions in
-\file{Include/Python-ast.h}.  The \cfunction{PyParser_ASTFromString()}
-and \cfunction{PyParser_ASTFromFile()}, defined in
+No official documentation has been written for the AST code yet, but
+\pep{339} discusses the design.  To start learning about the code, read the
+definition of the various AST nodes in \file{Parser/Python.asdl}.  A
+Python script reads this file and generates a set of C structure
+definitions in \file{Include/Python-ast.h}.  The
+\cfunction{PyParser_ASTFromString()} and
+\cfunction{PyParser_ASTFromFile()}, defined in
 \file{Include/pythonrun.h}, take Python source as input and return the
 root of an AST representing the contents.  This AST can then be turned
 into a code object by \cfunction{PyAST_Compile()}.  For more
@@ -2202,7 +2269,12 @@
 
 \item The \cfunction{PyRange_New()} function was removed.  It was
 never documented, never used in the core code, and had dangerously lax
-error checking.
+error checking.  In the unlikely case that your extensions were using
+it, you can replace it by something like the following:
+\begin{verbatim}
+range = PyObject_CallFunction((PyObject*) &PyRange_Type, "lll", 
+                              start, stop, step);
+\end{verbatim}
 
 \end{itemize}
 
@@ -2308,6 +2380,10 @@
 \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
@@ -2330,7 +2406,8 @@
 
 The author would like to thank the following people for offering
 suggestions, corrections and assistance with various drafts of this
-article: Phillip J. Eby, Kent Johnson, Martin von~L\"owis, Fredrik Lundh, 
-Gustavo Niemeyer, James Pryor, Mike Rovner, Scott Weikart, Thomas Wouters.
+article: 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.
 
 \end{document}

Modified: stackless/trunk/Include/patchlevel.h
==============================================================================
--- stackless/trunk/Include/patchlevel.h	(original)
+++ stackless/trunk/Include/patchlevel.h	Fri Jul 14 14:39:40 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: stackless/trunk/Include/pystate.h
==============================================================================
--- stackless/trunk/Include/pystate.h	(original)
+++ stackless/trunk/Include/pystate.h	Fri Jul 14 14:39:40 2006
@@ -178,6 +178,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: stackless/trunk/Lib/compiler/transformer.py
==============================================================================
--- stackless/trunk/Lib/compiler/transformer.py	(original)
+++ stackless/trunk/Lib/compiler/transformer.py	Fri Jul 14 14:39:40 2006
@@ -536,12 +536,7 @@
                    lineno=nodelist[0][2])
 
     def try_stmt(self, nodelist):
-        # 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite]
-        # | 'try' ':' suite 'finally' ':' suite
-        if nodelist[3][0] != symbol.except_clause:
-            return self.com_try_finally(nodelist)
-
-        return self.com_try_except(nodelist)
+        return self.com_try_except_finally(nodelist)
 
     def with_stmt(self, nodelist):
         return self.com_with(nodelist)
@@ -732,17 +727,17 @@
 
     def atom_lpar(self, nodelist):
         if nodelist[1][0] == token.RPAR:
-            return Tuple(())
+            return Tuple((), lineno=nodelist[0][2])
         return self.com_node(nodelist[1])
 
     def atom_lsqb(self, nodelist):
         if nodelist[1][0] == token.RSQB:
-            return List(())
+            return List((), lineno=nodelist[0][2])
         return self.com_list_constructor(nodelist[1])
 
     def atom_lbrace(self, nodelist):
         if nodelist[1][0] == token.RBRACE:
-            return Dict(())
+            return Dict((), lineno=nodelist[0][2])
         return self.com_dictmaker(nodelist[1])
 
     def atom_backquote(self, nodelist):
@@ -917,18 +912,21 @@
             bases.append(self.com_node(node[i]))
         return bases
 
-    def com_try_finally(self, nodelist):
-        # try_fin_stmt: "try" ":" suite "finally" ":" suite
-        return TryFinally(self.com_node(nodelist[2]),
-                       self.com_node(nodelist[5]),
-                       lineno=nodelist[0][2])
+    def com_try_except_finally(self, nodelist):
+        # ('try' ':' suite
+        #  ((except_clause ':' suite)+ ['else' ':' suite] ['finally' ':' suite]
+        #   | 'finally' ':' suite))
+
+        if nodelist[3][0] == token.NAME:
+            # first clause is a finally clause: only try-finally
+            return TryFinally(self.com_node(nodelist[2]),
+                              self.com_node(nodelist[5]),
+                              lineno=nodelist[0][2])
 
-    def com_try_except(self, nodelist):
-        # try_except: 'try' ':' suite (except_clause ':' suite)* ['else' suite]
         #tryexcept:  [TryNode, [except_clauses], elseNode)]
-        stmt = self.com_node(nodelist[2])
         clauses = []
         elseNode = None
+        finallyNode = None
         for i in range(3, len(nodelist), 3):
             node = nodelist[i]
             if node[0] == symbol.except_clause:
@@ -944,9 +942,16 @@
                 clauses.append((expr1, expr2, self.com_node(nodelist[i+2])))
 
             if node[0] == token.NAME:
-                elseNode = self.com_node(nodelist[i+2])
-        return TryExcept(self.com_node(nodelist[2]), clauses, elseNode,
-                         lineno=nodelist[0][2])
+                if node[1] == 'else':
+                    elseNode = self.com_node(nodelist[i+2])
+                elif node[1] == 'finally':
+                    finallyNode = self.com_node(nodelist[i+2])
+        try_except = TryExcept(self.com_node(nodelist[2]), clauses, elseNode,
+                               lineno=nodelist[0][2])
+        if finallyNode:
+            return TryFinally(try_except, finallyNode, lineno=nodelist[0][2])
+        else:
+            return try_except
 
     def com_with(self, nodelist):
         # with_stmt: 'with' expr [with_var] ':' suite
@@ -1136,7 +1141,7 @@
             values = []
             for i in range(1, len(nodelist), 2):
                 values.append(self.com_node(nodelist[i]))
-            return List(values)
+            return List(values, lineno=values[0].lineno)
 
     if hasattr(symbol, 'gen_for'):
         def com_generator_expression(self, expr, node):
@@ -1183,7 +1188,7 @@
         for i in range(1, len(nodelist), 4):
             items.append((self.com_node(nodelist[i]),
                           self.com_node(nodelist[i+2])))
-        return Dict(items)
+        return Dict(items, lineno=items[0][0].lineno)
 
     def com_apply_trailer(self, primaryNode, nodelist):
         t = nodelist[1][0]

Modified: stackless/trunk/Lib/ctypes/test/test_objects.py
==============================================================================
--- stackless/trunk/Lib/ctypes/test/test_objects.py	(original)
+++ stackless/trunk/Lib/ctypes/test/test_objects.py	Fri Jul 14 14:39:40 2006
@@ -54,13 +54,17 @@
 
 '''
 
-import unittest, doctest
+import unittest, doctest, sys
 
 import ctypes.test.test_objects
 
 class TestCase(unittest.TestCase):
-    def test(self):
-        doctest.testmod(ctypes.test.test_objects)
+    if sys.hexversion > 0x02040000:
+        # Python 2.3 has no ELLIPSIS flag, so we don't test with this
+        # version:
+        def test(self):
+            doctest.testmod(ctypes.test.test_objects)
 
 if __name__ == '__main__':
-    doctest.testmod(ctypes.test.test_objects)
+    if sys.hexversion > 0x02040000:
+        doctest.testmod(ctypes.test.test_objects)

Modified: stackless/trunk/Lib/ctypes/test/test_parameters.py
==============================================================================
--- stackless/trunk/Lib/ctypes/test/test_parameters.py	(original)
+++ stackless/trunk/Lib/ctypes/test/test_parameters.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/ctypes/test/test_pointers.py
==============================================================================
--- stackless/trunk/Lib/ctypes/test/test_pointers.py	(original)
+++ stackless/trunk/Lib/ctypes/test/test_pointers.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/ctypes/test/test_structures.py
==============================================================================
--- stackless/trunk/Lib/ctypes/test/test_structures.py	(original)
+++ stackless/trunk/Lib/ctypes/test/test_structures.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/ctypes/test/test_win32.py
==============================================================================
--- stackless/trunk/Lib/ctypes/test/test_win32.py	(original)
+++ stackless/trunk/Lib/ctypes/test/test_win32.py	Fri Jul 14 14:39:40 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,15 +31,10 @@
             # or wrong calling convention
             self.assertRaises(ValueError, IsWindow, None)
 
-        def test_SEH(self):
-            # Call functions with invalid arguments, and make sure that access violations
-            # are trapped and raise an exception.
-            #
-            # Normally, in a debug build of the _ctypes extension
-            # module, exceptions are not trapped, so we can only run
-            # this test in a release build.
-            import sys
-            if not hasattr(sys, "getobjects"):
+        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.
                 self.assertRaises(WindowsError, windll.kernel32.GetModuleHandleA, 32)
 
 class Structures(unittest.TestCase):

Modified: stackless/trunk/Lib/distutils/command/bdist_rpm.py
==============================================================================
--- stackless/trunk/Lib/distutils/command/bdist_rpm.py	(original)
+++ stackless/trunk/Lib/distutils/command/bdist_rpm.py	Fri Jul 14 14:39:40 2006
@@ -467,7 +467,8 @@
 
         # rpm scripts
         # figure out default build script
-        def_build = "%s setup.py build" % self.python
+        def_setup_call = "%s %s" % (self.python,os.path.basename(sys.argv[0]))
+        def_build = "%s build" % def_setup_call
         if self.use_rpm_opt_flags:
             def_build = 'env CFLAGS="$RPM_OPT_FLAGS" ' + def_build
 
@@ -481,9 +482,9 @@
             ('prep', 'prep_script', "%setup"),
             ('build', 'build_script', def_build),
             ('install', 'install_script',
-             ("%s setup.py install "
+             ("%s install "
               "--root=$RPM_BUILD_ROOT "
-              "--record=INSTALLED_FILES") % self.python),
+              "--record=INSTALLED_FILES") % def_setup_call),
             ('clean', 'clean_script', "rm -rf $RPM_BUILD_ROOT"),
             ('verifyscript', 'verify_script', None),
             ('pre', 'pre_install', None),

Modified: stackless/trunk/Lib/distutils/command/upload.py
==============================================================================
--- stackless/trunk/Lib/distutils/command/upload.py	(original)
+++ stackless/trunk/Lib/distutils/command/upload.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/distutils/msvccompiler.py
==============================================================================
--- stackless/trunk/Lib/distutils/msvccompiler.py	(original)
+++ stackless/trunk/Lib/distutils/msvccompiler.py	Fri Jul 14 14:39:40 2006
@@ -131,7 +131,7 @@
                 self.set_macro("FrameworkSDKDir", net, "sdkinstallroot")
         except KeyError, exc: #
             raise DistutilsPlatformError, \
-                  ("The .NET Framework SDK needs to be installed before "
+                  ("Visual Studio 2003 needs to be installed before "
                    "building extensions for Python.")
 
         p = r"Software\Microsoft\NET Framework Setup\Product"
@@ -237,7 +237,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: stackless/trunk/Lib/distutils/sysconfig.py
==============================================================================
--- stackless/trunk/Lib/distutils/sysconfig.py	(original)
+++ stackless/trunk/Lib/distutils/sysconfig.py	Fri Jul 14 14:39:40 2006
@@ -512,7 +512,7 @@
                 for key in ('LDFLAGS', 'BASECFLAGS'):
                     flags = _config_vars[key]
                     flags = re.sub('-arch\s+\w+\s', ' ', flags)
-                    flags = re.sub('-isysroot [^ \t]* ', ' ', flags)
+                    flags = re.sub('-isysroot [^ \t]*', ' ', flags)
                     _config_vars[key] = flags
 
     if args:

Modified: stackless/trunk/Lib/distutils/unixccompiler.py
==============================================================================
--- stackless/trunk/Lib/distutils/unixccompiler.py	(original)
+++ stackless/trunk/Lib/distutils/unixccompiler.py	Fri Jul 14 14:39:40 2006
@@ -78,7 +78,7 @@
         try:
             index = compiler_so.index('-isysroot')
             # Strip this argument and the next one:
-            del compiler_so[index:index+1]
+            del compiler_so[index:index+2]
         except ValueError:
             pass
 

Modified: stackless/trunk/Lib/idlelib/Debugger.py
==============================================================================
--- stackless/trunk/Lib/idlelib/Debugger.py	(original)
+++ stackless/trunk/Lib/idlelib/Debugger.py	Fri Jul 14 14:39:40 2006
@@ -4,6 +4,7 @@
 from Tkinter import *
 from WindowList import ListedToplevel
 from ScrolledList import ScrolledList
+import macosxSupport
 
 
 class Idb(bdb.Bdb):
@@ -322,7 +323,13 @@
 class StackViewer(ScrolledList):
 
     def __init__(self, master, flist, gui):
-        ScrolledList.__init__(self, master, width=80)
+        if macosxSupport.runningAsOSXApp():
+            # At least on with the stock AquaTk version on OSX 10.4 you'll
+            # get an shaking GUI that eventually kills IDLE if the width
+            # argument is specified.
+            ScrolledList.__init__(self, master)
+        else:
+            ScrolledList.__init__(self, master, width=80)
         self.flist = flist
         self.gui = gui
         self.stack = []

Modified: stackless/trunk/Lib/idlelib/NEWS.txt
==============================================================================
--- stackless/trunk/Lib/idlelib/NEWS.txt	(original)
+++ stackless/trunk/Lib/idlelib/NEWS.txt	Fri Jul 14 14:39:40 2006
@@ -1,3 +1,8 @@
+What's New in IDLE 1.2b2?
+=========================
+
+*Release date: 11-JUL-2006*
+
 What's New in IDLE 1.2b1?
 =========================
 

Modified: stackless/trunk/Lib/idlelib/idlever.py
==============================================================================
--- stackless/trunk/Lib/idlelib/idlever.py	(original)
+++ stackless/trunk/Lib/idlelib/idlever.py	Fri Jul 14 14:39:40 2006
@@ -1 +1 @@
-IDLE_VERSION = "1.2b1"
+IDLE_VERSION = "1.2b2"

Modified: stackless/trunk/Lib/inspect.py
==============================================================================
--- stackless/trunk/Lib/inspect.py	(original)
+++ stackless/trunk/Lib/inspect.py	Fri Jul 14 14:39:40 2006
@@ -355,40 +355,37 @@
             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)))
+        os.path.abspath(_filename or getsourcefile(object) or getfile(object)))
 
 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: stackless/trunk/Lib/lib-tk/turtle.py
==============================================================================
--- stackless/trunk/Lib/lib-tk/turtle.py	(original)
+++ stackless/trunk/Lib/lib-tk/turtle.py	Fri Jul 14 14:39:40 2006
@@ -30,6 +30,7 @@
         self._tracing = 1
         self._arrow = 0
         self._delay = 10     # default delay for drawing
+        self._angle = 0.0
         self.degrees()
         self.reset()
 
@@ -39,6 +40,10 @@
         Example:
         >>> turtle.degrees()
         """
+        # Don't try to change _angle if it is 0, because
+        # _fullcircle might not be set, yet
+        if self._angle:
+            self._angle = (self._angle / self._fullcircle) * fullcircle
         self._fullcircle = fullcircle
         self._invradian = pi / (fullcircle * 0.5)
 
@@ -81,7 +86,6 @@
         self._color = "black"
         self._filling = 0
         self._path = []
-        self._tofill = []
         self.clear()
         canvas._root().tkraise()
 
@@ -301,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()
@@ -326,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.
@@ -344,7 +345,7 @@
         """
         self.fill(0)
 
-    def circle(self, radius, extent=None):
+    def circle(self, radius, extent = None):
         """ Draw a circle with given radius.
         The center is radius units left of the turtle; extent
         determines which part of the circle is drawn. If not given,
@@ -361,52 +362,18 @@
         """
         if extent is None:
             extent = self._fullcircle
-        x0, y0 = self._position
-        xc = x0 - radius * sin(self._angle * self._invradian)
-        yc = y0 - radius * cos(self._angle * self._invradian)
-        if radius >= 0.0:
-            start = self._angle - (self._fullcircle / 4.0)
-        else:
-            start = self._angle + (self._fullcircle / 4.0)
-            extent = -extent
-        if self._filling:
-            if abs(extent) >= self._fullcircle:
-                item = self._canvas.create_oval(xc-radius, yc-radius,
-                                                xc+radius, yc+radius,
-                                                width=self._width,
-                                                outline="")
-                self._tofill.append(item)
-            item = self._canvas.create_arc(xc-radius, yc-radius,
-                                           xc+radius, yc+radius,
-                                           style="chord",
-                                           start=start,
-                                           extent=extent,
-                                           width=self._width,
-                                           outline="")
-            self._tofill.append(item)
-        if self._drawing:
-            if abs(extent) >= self._fullcircle:
-                item = self._canvas.create_oval(xc-radius, yc-radius,
-                                                xc+radius, yc+radius,
-                                                width=self._width,
-                                                outline=self._color)
-                self._items.append(item)
-            item = self._canvas.create_arc(xc-radius, yc-radius,
-                                           xc+radius, yc+radius,
-                                           style="arc",
-                                           start=start,
-                                           extent=extent,
-                                           width=self._width,
-                                           outline=self._color)
-            self._items.append(item)
-        angle = start + extent
-        x1 = xc + abs(radius) * cos(angle * self._invradian)
-        y1 = yc - abs(radius) * sin(angle * self._invradian)
-        self._angle = (self._angle + extent) % self._fullcircle
-        self._position = x1, y1
-        if self._filling:
-            self._path.append(self._position)
-        self._draw_turtle()
+        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
+        l = 2.0 * radius * sin(w2*self._invradian)
+        if radius < 0:
+            l, w, w2 = -l, -w, -w2
+        self.left(w2)
+        for i in range(steps):
+            self.forward(l)
+            self.left(w)
+        self.right(w2)
 
     def heading(self):
         """ Return the turtle's current heading.
@@ -679,7 +646,7 @@
             _canvas = Tkinter.Canvas(_root, background="white")
             _canvas.pack(expand=1, fill="both")
 
-        setup(width=_width, height= _height, startx=_startx, starty=_starty)
+            setup(width=_width, height= _height, startx=_startx, starty=_starty)
 
         RawPen.__init__(self, _canvas)
 
@@ -721,7 +688,7 @@
 def write(arg, move=0): _getpen().write(arg, move)
 def fill(flag): _getpen().fill(flag)
 def begin_fill(): _getpen().begin_fill()
-def end_fill(): _getpen.end_fill()
+def end_fill(): _getpen().end_fill()
 def circle(radius, extent=None): _getpen().circle(radius, extent)
 def goto(*args): _getpen().goto(*args)
 def heading(): return _getpen().heading()
@@ -930,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: stackless/trunk/Lib/logging/config.py
==============================================================================
--- stackless/trunk/Lib/logging/config.py	(original)
+++ stackless/trunk/Lib/logging/config.py	Fri Jul 14 14:39:40 2006
@@ -79,6 +79,7 @@
     logging._acquireLock()
     try:
         logging._handlers.clear()
+        logging._handlerList = []
         # Handlers add themselves to logging._handlers
         handlers = _install_handlers(cp, formatters)
         _install_loggers(cp, handlers)

Modified: stackless/trunk/Lib/logging/handlers.py
==============================================================================
--- stackless/trunk/Lib/logging/handlers.py	(original)
+++ stackless/trunk/Lib/logging/handlers.py	Fri Jul 14 14:39:40 2006
@@ -128,12 +128,7 @@
             dfn = self.baseFilename + ".1"
             if os.path.exists(dfn):
                 os.remove(dfn)
-            try:
-                os.rename(self.baseFilename, dfn)
-            except (KeyboardInterrupt, SystemExit):
-                raise
-            except:
-                self.handleError(record)
+            os.rename(self.baseFilename, dfn)
             #print "%s -> %s" % (self.baseFilename, dfn)
         if self.encoding:
             self.stream = codecs.open(self.baseFilename, 'w', self.encoding)
@@ -273,12 +268,7 @@
         dfn = self.baseFilename + "." + time.strftime(self.suffix, timeTuple)
         if os.path.exists(dfn):
             os.remove(dfn)
-        try:
-            os.rename(self.baseFilename, dfn)
-        except (KeyboardInterrupt, SystemExit):
-            raise
-        except:
-            self.handleError(record)
+        os.rename(self.baseFilename, dfn)
         if self.backupCount > 0:
             # find the oldest log file and delete it
             s = glob.glob(self.baseFilename + ".20*")

Modified: stackless/trunk/Lib/mailbox.py
==============================================================================
--- stackless/trunk/Lib/mailbox.py	(original)
+++ stackless/trunk/Lib/mailbox.py	Fri Jul 14 14:39:40 2006
@@ -15,7 +15,7 @@
 import rfc822
 import StringIO
 try:
-    import fnctl
+    import fcntl
 except ImportError:
     fcntl = None
 
@@ -1798,26 +1798,18 @@
 
 
 def _lock_file(f, dotlock=True):
-    """Lock file f using lockf, flock, and dot locking."""
+    """Lock file f using lockf and dot locking."""
     dotlock_done = False
     try:
         if fcntl:
             try:
                 fcntl.lockf(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
             except IOError, e:
-                if e.errno == errno.EAGAIN:
+                if e.errno in (errno.EAGAIN, errno.EACCES):
                     raise ExternalClashError('lockf: lock unavailable: %s' %
                                              f.name)
                 else:
                     raise
-            try:
-                fcntl.flock(f, fcntl.LOCK_EX | fcntl.LOCK_NB)
-            except IOError, e:
-                if e.errno == errno.EWOULDBLOCK:
-                    raise ExternalClashError('flock: lock unavailable: %s' %
-                                             f.name)
-                else:
-                    raise
         if dotlock:
             try:
                 pre_lock = _create_temporary(f.name + '.lock')
@@ -1845,16 +1837,14 @@
     except:
         if fcntl:
             fcntl.lockf(f, fcntl.LOCK_UN)
-            fcntl.flock(f, fcntl.LOCK_UN)
         if dotlock_done:
             os.remove(f.name + '.lock')
         raise
 
 def _unlock_file(f):
-    """Unlock file f using lockf, flock, and dot locking."""
+    """Unlock file f using lockf and dot locking."""
     if fcntl:
         fcntl.lockf(f, fcntl.LOCK_UN)
-        fcntl.flock(f, fcntl.LOCK_UN)
     if os.path.exists(f.name + '.lock'):
         os.remove(f.name + '.lock')
 

Modified: stackless/trunk/Lib/msilib/__init__.py
==============================================================================
--- stackless/trunk/Lib/msilib/__init__.py	(original)
+++ stackless/trunk/Lib/msilib/__init__.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/popen2.py
==============================================================================
--- stackless/trunk/Lib/popen2.py	(original)
+++ stackless/trunk/Lib/popen2.py	Fri Jul 14 14:39:40 2006
@@ -79,7 +79,7 @@
     def _run_child(self, cmd):
         if isinstance(cmd, basestring):
             cmd = ['/bin/sh', '-c', cmd]
-        for i in range(3, MAXFD):
+        for i in xrange(3, MAXFD):
             try:
                 os.close(i)
             except OSError:

Modified: stackless/trunk/Lib/sgmllib.py
==============================================================================
--- stackless/trunk/Lib/sgmllib.py	(original)
+++ stackless/trunk/Lib/sgmllib.py	Fri Jul 14 14:39:40 2006
@@ -29,11 +29,16 @@
 shorttagopen = re.compile('<[a-zA-Z][-.a-zA-Z0-9]*/')
 shorttag = re.compile('<([a-zA-Z][-.a-zA-Z0-9]*)/([^/]*)/')
 piclose = re.compile('>')
-endbracket = re.compile('[<>]')
+starttag = re.compile(r'<[a-zA-Z][-_.:a-zA-Z0-9]*\s*('
+        r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*'
+        r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~@]'
+        r'[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*(?=[\s>/<])))?'
+    r')*\s*/?\s*(?=[<>])')
+endtag = re.compile(r'</?[a-zA-Z][-_.:a-zA-Z0-9]*\s*/?\s*(?=[<>])')
 tagfind = re.compile('[a-zA-Z][-_.a-zA-Z0-9]*')
 attrfind = re.compile(
     r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*'
-    r'(\'[^\']*\'|"[^"]*"|[-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*))?')
+    r'(\'[^\']*\'|"[^"]*"|[][\-a-zA-Z0-9./,:;+*%?!&$\(\)_#=~\'"@]*))?')
 
 
 class SGMLParseError(RuntimeError):
@@ -249,14 +254,10 @@
             self.finish_shorttag(tag, data)
             self.__starttag_text = rawdata[start_pos:match.end(1) + 1]
             return k
-        # XXX The following should skip matching quotes (' or ")
-        # As a shortcut way to exit, this isn't so bad, but shouldn't
-        # be used to locate the actual end of the start tag since the
-        # < or > characters may be embedded in an attribute value.
-        match = endbracket.search(rawdata, i+1)
+        match = starttag.match(rawdata, i)
         if not match:
             return -1
-        j = match.start(0)
+        j = match.end(0)
         # Now parse the data between i+1 and j into a tag and attrs
         attrs = []
         if rawdata[i:i+2] == '<>':
@@ -305,10 +306,10 @@
     # Internal -- parse endtag
     def parse_endtag(self, i):
         rawdata = self.rawdata
-        match = endbracket.search(rawdata, i+1)
+        match = endtag.match(rawdata, i)
         if not match:
             return -1
-        j = match.start(0)
+        j = match.end(0)
         tag = rawdata[i+2:j].strip().lower()
         if rawdata[j] == '>':
             j = j+1
@@ -400,11 +401,11 @@
 
     def handle_charref(self, name):
         """Handle character reference, no need to override."""
-        replacement = convert_charref(name)
+        replacement = self.convert_charref(name)
         if replacement is None:
             self.unknown_charref(name)
         else:
-            self.handle_data(convert_charref(name))
+            self.handle_data(replacement)
 
     # Definition of entities -- derived classes may override
     entitydefs = \

Modified: stackless/trunk/Lib/socket.py
==============================================================================
--- stackless/trunk/Lib/socket.py	(original)
+++ stackless/trunk/Lib/socket.py	Fri Jul 14 14:39:40 2006
@@ -130,35 +130,37 @@
 if sys.platform == "riscos":
     _socketmethods = _socketmethods + ('sleeptaskw',)
 
+# All the method names that must be delegated to either the real socket
+# object or the _closedsocket object.
+_delegate_methods = ("recv", "recvfrom", "recv_into", "recvfrom_into",
+                     "send", "sendto")
+
 class _closedsocket(object):
     __slots__ = []
     def _dummy(*args):
         raise error(EBADF, 'Bad file descriptor')
-    send = recv = sendto = recvfrom = __getattr__ = _dummy
+    # All _delegate_methods must also be initialized here.
+    send = recv = recv_into = sendto = recvfrom = recvfrom_into = _dummy
+    __getattr__ = _dummy
 
 class _socketobject(object):
 
     __doc__ = _realsocket.__doc__
 
-    __slots__ = ["_sock",
-                 "recv", "recv_into", "recvfrom_into",
-                 "send", "sendto", "recvfrom",
-                 "__weakref__"]
+    __slots__ = ["_sock", "__weakref__"] + list(_delegate_methods)
 
     def __init__(self, family=AF_INET, type=SOCK_STREAM, proto=0, _sock=None):
         if _sock is None:
             _sock = _realsocket(family, type, proto)
         self._sock = _sock
-        self.send = self._sock.send
-        self.recv = self._sock.recv
-        self.recv_into = self._sock.recv_into
-        self.sendto = self._sock.sendto
-        self.recvfrom = self._sock.recvfrom
-        self.recvfrom_into = self._sock.recvfrom_into
+        for method in _delegate_methods:
+            setattr(self, method, getattr(_sock, method))
 
     def close(self):
         self._sock = _closedsocket()
-        self.send = self.recv = self.sendto = self.recvfrom = self._sock._dummy
+        dummy = self._sock._dummy
+        for method in _delegate_methods:
+            setattr(self, method, dummy)
     close.__doc__ = _realsocket.close.__doc__
 
     def accept(self):

Modified: stackless/trunk/Lib/sqlite3/test/types.py
==============================================================================
--- stackless/trunk/Lib/sqlite3/test/types.py	(original)
+++ stackless/trunk/Lib/sqlite3/test/types.py	Fri Jul 14 14:39:40 2006
@@ -21,7 +21,7 @@
 #    misrepresented as being the original software.
 # 3. This notice may not be removed or altered from any source distribution.
 
-import datetime
+import bz2, datetime
 import unittest
 import sqlite3 as sqlite
 
@@ -273,6 +273,23 @@
         val = self.cur.fetchone()[0]
         self.failUnlessEqual(type(val), float)
 
+class BinaryConverterTests(unittest.TestCase):
+    def convert(s):
+        return bz2.decompress(s)
+    convert = staticmethod(convert)
+
+    def setUp(self):
+        self.con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_COLNAMES)
+        sqlite.register_converter("bin", BinaryConverterTests.convert)
+
+    def tearDown(self):
+        self.con.close()
+
+    def CheckBinaryInputForConverter(self):
+        testdata = "abcdefg" * 10
+        result = self.con.execute('select ? as "x [bin]"', (buffer(bz2.compress(testdata)),)).fetchone()[0]
+        self.failUnlessEqual(testdata, result)
+
 class DateTimeTests(unittest.TestCase):
     def setUp(self):
         self.con = sqlite.connect(":memory:", detect_types=sqlite.PARSE_DECLTYPES)
@@ -322,8 +339,9 @@
     decltypes_type_suite = unittest.makeSuite(DeclTypesTests, "Check")
     colnames_type_suite = unittest.makeSuite(ColNamesTests, "Check")
     adaptation_suite = unittest.makeSuite(ObjectAdaptationTests, "Check")
+    bin_suite = unittest.makeSuite(BinaryConverterTests, "Check")
     date_suite = unittest.makeSuite(DateTimeTests, "Check")
-    return unittest.TestSuite((sqlite_type_suite, decltypes_type_suite, colnames_type_suite, adaptation_suite, date_suite))
+    return unittest.TestSuite((sqlite_type_suite, decltypes_type_suite, colnames_type_suite, adaptation_suite, bin_suite, date_suite))
 
 def test():
     runner = unittest.TextTestRunner()

Modified: stackless/trunk/Lib/sqlite3/test/userfunctions.py
==============================================================================
--- stackless/trunk/Lib/sqlite3/test/userfunctions.py	(original)
+++ stackless/trunk/Lib/sqlite3/test/userfunctions.py	Fri Jul 14 14:39:40 2006
@@ -365,7 +365,6 @@
 
 class AuthorizerTests(unittest.TestCase):
     def setUp(self):
-        sqlite.enable_callback_tracebacks(1)
         self.con = sqlite.connect(":memory:")
         self.con.executescript("""
             create table t1 (c1, c2);

Modified: stackless/trunk/Lib/string.py
==============================================================================
--- stackless/trunk/Lib/string.py	(original)
+++ stackless/trunk/Lib/string.py	Fri Jul 14 14:39:40 2006
@@ -161,7 +161,7 @@
                 val = mapping[named]
                 # We use this idiom instead of str() because the latter will
                 # fail if val is a Unicode containing non-ASCII characters.
-                return '%s' % val
+                return '%s' % (val,)
             if mo.group('escaped') is not None:
                 return self.delimiter
             if mo.group('invalid') is not None:
@@ -186,13 +186,13 @@
                 try:
                     # We use this idiom instead of str() because the latter
                     # will fail if val is a Unicode containing non-ASCII
-                    return '%s' % mapping[named]
+                    return '%s' % (mapping[named],)
                 except KeyError:
                     return self.delimiter + named
             braced = mo.group('braced')
             if braced is not None:
                 try:
-                    return '%s' % mapping[braced]
+                    return '%s' % (mapping[braced],)
                 except KeyError:
                     return self.delimiter + '{' + braced + '}'
             if mo.group('escaped') is not None:

Modified: stackless/trunk/Lib/subprocess.py
==============================================================================
--- stackless/trunk/Lib/subprocess.py	(original)
+++ stackless/trunk/Lib/subprocess.py	Fri Jul 14 14:39:40 2006
@@ -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:
 
@@ -941,7 +941,7 @@
 
 
         def _close_fds(self, but):
-            for i in range(3, MAXFD):
+            for i in xrange(3, MAXFD):
                 if i == but:
                     continue
                 try:

Modified: stackless/trunk/Lib/tarfile.py
==============================================================================
--- stackless/trunk/Lib/tarfile.py	(original)
+++ stackless/trunk/Lib/tarfile.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/telnetlib.py
==============================================================================
--- stackless/trunk/Lib/telnetlib.py	(original)
+++ stackless/trunk/Lib/telnetlib.py	Fri Jul 14 14:39:40 2006
@@ -311,6 +311,8 @@
         s_args = s_reply
         if timeout is not None:
             s_args = s_args + (timeout,)
+            from time import time
+            time_start = time()
         while not self.eof and select.select(*s_args) == s_reply:
             i = max(0, len(self.cookedq)-n)
             self.fill_rawq()
@@ -321,6 +323,11 @@
                 buf = self.cookedq[:i]
                 self.cookedq = self.cookedq[i:]
                 return buf
+            if timeout is not None:
+                elapsed = time() - time_start
+                if elapsed >= timeout:
+                    break
+                s_args = s_reply + (timeout-elapsed,)
         return self.read_very_lazy()
 
     def read_all(self):
@@ -601,6 +608,9 @@
             if not hasattr(list[i], "search"):
                 if not re: import re
                 list[i] = re.compile(list[i])
+        if timeout is not None:
+            from time import time
+            time_start = time()
         while 1:
             self.process_rawq()
             for i in indices:
@@ -613,7 +623,11 @@
             if self.eof:
                 break
             if timeout is not None:
-                r, w, x = select.select([self.fileno()], [], [], timeout)
+                elapsed = time() - time_start
+                if elapsed >= timeout:
+                    break
+                s_args = ([self.fileno()], [], [], timeout-elapsed)
+                r, w, x = select.select(*s_args)
                 if not r:
                     break
             self.fill_rawq()

Deleted: /stackless/trunk/Lib/test/crashers/xml_parsers.py
==============================================================================
--- /stackless/trunk/Lib/test/crashers/xml_parsers.py	Fri Jul 14 14:39:40 2006
+++ (empty file)
@@ -1,56 +0,0 @@
-from xml.parsers import expat
-
-# http://python.org/sf/1296433
-
-def test_parse_only_xml_data():
-    #
-    xml = "<?xml version='1.0' encoding='iso8859'?><s>%s</s>" % ('a' * 1025)
-    # this one doesn't crash
-    #xml = "<?xml version='1.0'?><s>%s</s>" % ('a' * 10000)
-
-    def handler(text):
-        raise Exception
-
-    parser = expat.ParserCreate()
-    parser.CharacterDataHandler = handler
-
-    try:
-        parser.Parse(xml)
-    except:
-        pass
-
-if __name__ == '__main__':
-    test_parse_only_xml_data()
-
-# Invalid read of size 4
-#    at 0x43F936: PyObject_Free (obmalloc.c:735)
-#    by 0x45A7C7: unicode_dealloc (unicodeobject.c:246)
-#    by 0x1299021D: PyUnknownEncodingHandler (pyexpat.c:1314)
-#    by 0x12993A66: processXmlDecl (xmlparse.c:3330)
-#    by 0x12999211: doProlog (xmlparse.c:3678)
-#    by 0x1299C3F0: prologInitProcessor (xmlparse.c:3550)
-#    by 0x12991EA3: XML_ParseBuffer (xmlparse.c:1562)
-#    by 0x1298F8EC: xmlparse_Parse (pyexpat.c:895)
-#    by 0x47B3A1: PyEval_EvalFrameEx (ceval.c:3565)
-#    by 0x47CCAC: PyEval_EvalCodeEx (ceval.c:2739)
-#    by 0x47CDE1: PyEval_EvalCode (ceval.c:490)
-#    by 0x499820: PyRun_SimpleFileExFlags (pythonrun.c:1198)
-#    by 0x4117F1: Py_Main (main.c:492)
-#    by 0x12476D1F: __libc_start_main (in /lib/libc-2.3.5.so)
-#    by 0x410DC9: (within /home/neal/build/python/svn/clean/python)
-#  Address 0x12704020 is 264 bytes inside a block of size 592 free'd
-#    at 0x11B1BA8A: free (vg_replace_malloc.c:235)
-#    by 0x124B5F18: (within /lib/libc-2.3.5.so)
-#    by 0x48DE43: find_module (import.c:1320)
-#    by 0x48E997: import_submodule (import.c:2249)
-#    by 0x48EC15: load_next (import.c:2083)
-#    by 0x48F091: import_module_ex (import.c:1914)
-#    by 0x48F385: PyImport_ImportModuleEx (import.c:1955)
-#    by 0x46D070: builtin___import__ (bltinmodule.c:44)
-#    by 0x4186CF: PyObject_Call (abstract.c:1777)
-#    by 0x474E9B: PyEval_CallObjectWithKeywords (ceval.c:3432)
-#    by 0x47928E: PyEval_EvalFrameEx (ceval.c:2038)
-#    by 0x47CCAC: PyEval_EvalCodeEx (ceval.c:2739)
-#    by 0x47CDE1: PyEval_EvalCode (ceval.c:490)
-#    by 0x48D0F7: PyImport_ExecCodeModuleEx (import.c:635)
-#    by 0x48D4F4: load_source_module (import.c:913)

Modified: stackless/trunk/Lib/test/fork_wait.py
==============================================================================
--- stackless/trunk/Lib/test/fork_wait.py	(original)
+++ stackless/trunk/Lib/test/fork_wait.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/test/regrtest.py
==============================================================================
--- stackless/trunk/Lib/test/regrtest.py	(original)
+++ stackless/trunk/Lib/test/regrtest.py	Fri Jul 14 14:39:40 2006
@@ -1274,6 +1274,37 @@
         test_winreg
         test_winsound
         """,
+    'netbsd3':
+        """
+        test_aepack
+        test_al
+        test_applesingle
+        test_bsddb
+        test_bsddb185
+        test_bsddb3
+        test_cd
+        test_cl
+        test_ctypes
+        test_curses
+        test_dl
+        test_gdbm
+        test_gl
+        test_imgfile
+        test_linuxaudiodev
+        test_locale
+        test_macfs
+        test_macostools
+        test_nis
+        test_ossaudiodev
+        test_pep277
+        test_sqlite
+        test_startfile
+        test_sunaudiodev
+        test_tcl
+        test_unicode_file
+        test_winreg
+        test_winsound
+        """,
 }
 _expectations['freebsd5'] = _expectations['freebsd4']
 _expectations['freebsd6'] = _expectations['freebsd4']

Modified: stackless/trunk/Lib/test/test__locale.py
==============================================================================
--- stackless/trunk/Lib/test/test__locale.py	(original)
+++ stackless/trunk/Lib/test/test__locale.py	Fri Jul 14 14:39:40 2006
@@ -113,6 +113,9 @@
                                 "using eval('3.14') failed for %s" % loc)
             self.assertEquals(int(float('3.14') * 100), 314,
                                 "using float('3.14') failed for %s" % loc)
+            if localeconv()['decimal_point'] != '.':
+                self.assertRaises(ValueError, float,
+                                  localeconv()['decimal_point'].join(['1', '23']))
 
 def test_main():
     run_unittest(_LocaleTests)

Modified: stackless/trunk/Lib/test/test_ast.py
==============================================================================
--- stackless/trunk/Lib/test/test_ast.py	(original)
+++ stackless/trunk/Lib/test/test_ast.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/test/test_builtin.py
==============================================================================
--- stackless/trunk/Lib/test/test_builtin.py	(original)
+++ stackless/trunk/Lib/test/test_builtin.py	Fri Jul 14 14:39:40 2006
@@ -558,13 +558,24 @@
     @run_with_locale('LC_NUMERIC', 'fr_FR', 'de_DE')
     def test_float_with_comma(self):
         # set locale to something that doesn't use '.' for the decimal point
+        # float must not accept the locale specific decimal point but
+        # it still has to accept the normal python syntac
         import locale
         if not locale.localeconv()['decimal_point'] == ',':
             return
 
-        self.assertEqual(float("  3,14  "), 3.14)
-        self.assertEqual(float("  +3,14  "), 3.14)
-        self.assertEqual(float("  -3,14  "), -3.14)
+        self.assertEqual(float("  3.14  "), 3.14)
+        self.assertEqual(float("+3.14  "), 3.14)
+        self.assertEqual(float("-3.14  "), -3.14)
+        self.assertEqual(float(".14  "), .14)
+        self.assertEqual(float("3.  "), 3.0)
+        self.assertEqual(float("3.e3  "), 3000.0)
+        self.assertEqual(float("3.2e3  "), 3200.0)
+        self.assertEqual(float("2.5e-1  "), 0.25)
+        self.assertEqual(float("5e-1"), 0.5)
+        self.assertRaises(ValueError, float, "  3,14  ")
+        self.assertRaises(ValueError, float, "  +3,14  ")
+        self.assertRaises(ValueError, float, "  -3,14  ")
         self.assertRaises(ValueError, float, "  0x3.1  ")
         self.assertRaises(ValueError, float, "  -0x3.p-1  ")
         self.assertEqual(float("  25.e-1  "), 2.5)

Modified: stackless/trunk/Lib/test/test_bz2.py
==============================================================================
--- stackless/trunk/Lib/test/test_bz2.py	(original)
+++ stackless/trunk/Lib/test/test_bz2.py	Fri Jul 14 14:39:40 2006
@@ -352,6 +352,7 @@
         BZ2DecompressorTest,
         FuncTest
     )
+    test_support.reap_children()
 
 if __name__ == '__main__':
     test_main()

Modified: stackless/trunk/Lib/test/test_cmd_line.py
==============================================================================
--- stackless/trunk/Lib/test/test_cmd_line.py	(original)
+++ stackless/trunk/Lib/test/test_cmd_line.py	Fri Jul 14 14:39:40 2006
@@ -87,6 +87,7 @@
 
 def test_main():
     test.test_support.run_unittest(CmdLineTest)
+    test.test_support.reap_children()
 
 if __name__ == "__main__":
     test_main()

Modified: stackless/trunk/Lib/test/test_commands.py
==============================================================================
--- stackless/trunk/Lib/test/test_commands.py	(original)
+++ stackless/trunk/Lib/test/test_commands.py	Fri Jul 14 14:39:40 2006
@@ -5,7 +5,7 @@
 import unittest
 import os, tempfile, re
 
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
 from commands import *
 
 # The module says:
@@ -58,6 +58,7 @@
 
 def test_main():
     run_unittest(CommandTests)
+    reap_children()
 
 
 if __name__ == "__main__":

Modified: stackless/trunk/Lib/test/test_compile.py
==============================================================================
--- stackless/trunk/Lib/test/test_compile.py	(original)
+++ stackless/trunk/Lib/test/test_compile.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/test/test_compiler.py
==============================================================================
--- stackless/trunk/Lib/test/test_compiler.py	(original)
+++ stackless/trunk/Lib/test/test_compiler.py	Fri Jul 14 14:39:40 2006
@@ -56,6 +56,15 @@
     def testYieldExpr(self):
         compiler.compile("def g(): yield\n\n", "<string>", "exec")
 
+    def testTryExceptFinally(self):
+        # Test that except and finally clauses in one try stmt are recognized
+        c = compiler.compile("try:\n 1/0\nexcept:\n e = 1\nfinally:\n f = 1",
+                             "<string>", "exec")
+        dct = {}
+        exec c in dct
+        self.assertEquals(dct.get('e'), 1)
+        self.assertEquals(dct.get('f'), 1)
+
     def testDefaultArgs(self):
         self.assertRaises(SyntaxError, compiler.parse, "def foo(a=1, b): pass")
 
@@ -103,6 +112,12 @@
 l = [(x, y) for x, y in zip(range(5), range(5,10))]
 l[0]
 l[3:4]
+d = {'a': 2}
+d = {}
+t = ()
+t = (1, 2)
+l = []
+l = [1, 2]
 if l:
     pass
 else:

Modified: stackless/trunk/Lib/test/test_descr.py
==============================================================================
--- stackless/trunk/Lib/test/test_descr.py	(original)
+++ stackless/trunk/Lib/test/test_descr.py	Fri Jul 14 14:39:40 2006
@@ -3966,6 +3966,13 @@
     o.whatever = Provoker(o)
     del o
 
+def wrapper_segfault():
+    # SF 927248: deeply nested wrappers could cause stack overflow
+    f = lambda:None
+    for i in xrange(1000000):
+        f = f.__call__
+    f = None
+
 # Fix SF #762455, segfault when sys.stdout is changed in getattr
 def filefault():
     if verbose:
@@ -4121,6 +4128,7 @@
 
 def test_main():
     weakref_segfault() # Must be first, somehow
+    wrapper_segfault()
     do_this_first()
     class_docstrings()
     lists()

Modified: stackless/trunk/Lib/test/test_exceptions.py
==============================================================================
--- stackless/trunk/Lib/test/test_exceptions.py	(original)
+++ stackless/trunk/Lib/test/test_exceptions.py	Fri Jul 14 14:39:40 2006
@@ -305,6 +305,18 @@
         x = DerivedException(fancy_arg=42)
         self.assertEquals(x.fancy_arg, 42)
 
+    def testInfiniteRecursion(self):
+        def f():
+            return f()
+        self.assertRaises(RuntimeError, f)
+
+        def g():
+            try:
+                return g()
+            except ValueError:
+                return -1
+        self.assertRaises(RuntimeError, g)
+
 def test_main():
     run_unittest(ExceptionTests)
 

Modified: stackless/trunk/Lib/test/test_fcntl.py
==============================================================================
--- stackless/trunk/Lib/test/test_fcntl.py	(original)
+++ stackless/trunk/Lib/test/test_fcntl.py	Fri Jul 14 14:39:40 2006
@@ -20,9 +20,10 @@
 if sys.platform.startswith('atheos'):
     start_len = "qq"
 
-if sys.platform in ('netbsd1', 'netbsd2', 'Darwin1.2', 'darwin',
-                    'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5', 'freebsd6',
-                    'freebsd7',
+if sys.platform in ('netbsd1', 'netbsd2', 'netbsd3',
+                    'Darwin1.2', 'darwin',
+                    'freebsd2', 'freebsd3', 'freebsd4', 'freebsd5',
+                    'freebsd6', 'freebsd7',
                     'bsdos2', 'bsdos3', 'bsdos4',
                     'openbsd', 'openbsd2', 'openbsd3'):
     if struct.calcsize('l') == 8:

Modified: stackless/trunk/Lib/test/test_fork1.py
==============================================================================
--- stackless/trunk/Lib/test/test_fork1.py	(original)
+++ stackless/trunk/Lib/test/test_fork1.py	Fri Jul 14 14:39:40 2006
@@ -2,8 +2,9 @@
 """
 
 import os
+import time
 from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
 
 try:
     os.fork
@@ -12,12 +13,20 @@
 
 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))
 
 def test_main():
     run_unittest(ForkTest)
+    reap_children()
 
 if __name__ == "__main__":
     test_main()

Modified: stackless/trunk/Lib/test/test_inspect.py
==============================================================================
--- stackless/trunk/Lib/test/test_inspect.py	(original)
+++ stackless/trunk/Lib/test/test_inspect.py	Fri Jul 14 14:39:40 2006
@@ -178,6 +178,16 @@
     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]
+
 class TestDecorators(GetSourceBase):
     fodderFile = mod2
 

Modified: stackless/trunk/Lib/test/test_logging.py
==============================================================================
--- stackless/trunk/Lib/test/test_logging.py	(original)
+++ stackless/trunk/Lib/test/test_logging.py	Fri Jul 14 14:39:40 2006
@@ -480,6 +480,8 @@
             f.close()
             try:
                 logging.config.fileConfig(fn)
+                #call again to make sure cleanup is correct
+                logging.config.fileConfig(fn)
             except:
                 t = sys.exc_info()[0]
                 message(str(t))

Modified: stackless/trunk/Lib/test/test_mailbox.py
==============================================================================
--- stackless/trunk/Lib/test/test_mailbox.py	(original)
+++ stackless/trunk/Lib/test/test_mailbox.py	Fri Jul 14 14:39:40 2006
@@ -720,6 +720,30 @@
         self.assert_(contents == open(self._path, 'rb').read())
         self._box = self._factory(self._path)
 
+    def test_lock_conflict(self):
+        # Fork off a subprocess that will lock the file for 2 seconds,
+        # unlock it, and then exit.
+        if not hasattr(os, 'fork'):
+            return
+        pid = os.fork()
+        if pid == 0:
+            # In the child, lock the mailbox.
+            self._box.lock()
+            time.sleep(2)
+            self._box.unlock()
+            os._exit(0)
+
+        # In the parent, sleep a bit to give the child time to acquire
+        # the lock.
+        time.sleep(0.5)
+        self.assertRaises(mailbox.ExternalClashError,
+                          self._box.lock)
+
+        # Wait for child to exit.  Locking should now succeed.
+        exited_pid, status = os.waitpid(pid, 0)
+        self._box.lock()
+        self._box.unlock()
+
 
 class TestMbox(_TestMboxMMDF):
 
@@ -1761,6 +1785,7 @@
              TestMessageConversion, TestProxyFile, TestPartialFile,
              MaildirTestCase)
     test_support.run_unittest(*tests)
+    test_support.reap_children()
 
 
 if __name__ == '__main__':

Modified: stackless/trunk/Lib/test/test_multibytecodec.py
==============================================================================
--- stackless/trunk/Lib/test/test_multibytecodec.py	(original)
+++ stackless/trunk/Lib/test/test_multibytecodec.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/test/test_os.py
==============================================================================
--- stackless/trunk/Lib/test/test_os.py	(original)
+++ stackless/trunk/Lib/test/test_os.py	Fri Jul 14 14:39:40 2006
@@ -11,6 +11,19 @@
 warnings.filterwarnings("ignore", "tempnam", RuntimeWarning, __name__)
 warnings.filterwarnings("ignore", "tmpnam", RuntimeWarning, __name__)
 
+# Tests creating TESTFN
+class FileTests(unittest.TestCase):
+    def setUp(self):
+        if os.path.exists(test_support.TESTFN):
+            os.unlink(test_support.TESTFN)
+    tearDown = setUp
+
+    def test_access(self):
+        f = os.open(test_support.TESTFN, os.O_CREAT|os.O_RDWR)
+        os.close(f)
+        self.assert_(os.access(test_support.TESTFN, os.W_OK))
+
+
 class TemporaryFileTests(unittest.TestCase):
     def setUp(self):
         self.files = []
@@ -393,6 +406,7 @@
 
 def test_main():
     test_support.run_unittest(
+        FileTests,
         TemporaryFileTests,
         StatAttributeTests,
         EnvironTests,

Modified: stackless/trunk/Lib/test/test_pep292.py
==============================================================================
--- stackless/trunk/Lib/test/test_pep292.py	(original)
+++ stackless/trunk/Lib/test/test_pep292.py	Fri Jul 14 14:39:40 2006
@@ -58,6 +58,13 @@
         s = Template('tim has eaten ${count} bags of ham today')
         eq(s.substitute(d), 'tim has eaten 7 bags of ham today')
 
+    def test_tupleargs(self):
+        eq = self.assertEqual
+        s = Template('$who ate ${meal}')
+        d = dict(who=('tim', 'fred'), meal=('ham', 'kung pao'))
+        eq(s.substitute(d), "('tim', 'fred') ate ('ham', 'kung pao')")
+        eq(s.safe_substitute(d), "('tim', 'fred') ate ('ham', 'kung pao')")
+
     def test_SafeTemplate(self):
         eq = self.assertEqual
         s = Template('$who likes ${what} for ${meal}')

Modified: stackless/trunk/Lib/test/test_popen.py
==============================================================================
--- stackless/trunk/Lib/test/test_popen.py	(original)
+++ stackless/trunk/Lib/test/test_popen.py	Fri Jul 14 14:39:40 2006
@@ -6,7 +6,7 @@
 
 import os
 import sys
-from test.test_support import TestSkipped
+from test.test_support import TestSkipped, reap_children
 from os import popen
 
 # Test that command-lines get down as we expect.
@@ -35,5 +35,6 @@
 def main():
     print "Test popen:"
     _test_commandline()
+    reap_children()
 
 main()

Modified: stackless/trunk/Lib/test/test_popen2.py
==============================================================================
--- stackless/trunk/Lib/test/test_popen2.py	(original)
+++ stackless/trunk/Lib/test/test_popen2.py	Fri Jul 14 14:39:40 2006
@@ -5,7 +5,7 @@
 
 import os
 import sys
-from test.test_support import TestSkipped
+from test.test_support import TestSkipped, reap_children
 
 # popen2 contains its own testing routine
 # which is especially useful to see if open files
@@ -75,3 +75,4 @@
 
 main()
 _test()
+reap_children()

Modified: stackless/trunk/Lib/test/test_pyexpat.py
==============================================================================
--- stackless/trunk/Lib/test/test_pyexpat.py	(original)
+++ stackless/trunk/Lib/test/test_pyexpat.py	Fri Jul 14 14:39:40 2006
@@ -365,3 +365,24 @@
   <c/>
  </b>
 </a>''', 1)
+
+
+def test_parse_only_xml_data():
+    # http://python.org/sf/1296433
+    #
+    xml = "<?xml version='1.0' encoding='iso8859'?><s>%s</s>" % ('a' * 1025)
+    # this one doesn't crash
+    #xml = "<?xml version='1.0'?><s>%s</s>" % ('a' * 10000)
+
+    def handler(text):
+        raise Exception
+
+    parser = expat.ParserCreate()
+    parser.CharacterDataHandler = handler
+
+    try:
+        parser.Parse(xml)
+    except:
+        pass
+
+test_parse_only_xml_data()

Modified: stackless/trunk/Lib/test/test_scope.py
==============================================================================
--- stackless/trunk/Lib/test/test_scope.py	(original)
+++ stackless/trunk/Lib/test/test_scope.py	Fri Jul 14 14:39:40 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: stackless/trunk/Lib/test/test_select.py
==============================================================================
--- stackless/trunk/Lib/test/test_select.py	(original)
+++ stackless/trunk/Lib/test/test_select.py	Fri Jul 14 14:39:40 2006
@@ -1,5 +1,5 @@
 # Testing select module
-from test.test_support import verbose
+from test.test_support import verbose, reap_children
 import select
 import os
 
@@ -65,5 +65,6 @@
             continue
         print 'Unexpected return values from select():', rfd, wfd, xfd
     p.close()
+    reap_children()
 
 test()

Modified: stackless/trunk/Lib/test/test_sgmllib.py
==============================================================================
--- stackless/trunk/Lib/test/test_sgmllib.py	(original)
+++ stackless/trunk/Lib/test/test_sgmllib.py	Fri Jul 14 14:39:40 2006
@@ -1,4 +1,6 @@
+import htmlentitydefs
 import pprint
+import re
 import sgmllib
 import unittest
 from test import test_support
@@ -65,20 +67,34 @@
 
 
 class HTMLEntityCollector(EventCollector):
-    import re, htmlentitydefs
+
     entity_or_charref = re.compile('(?:&([a-zA-Z][-.a-zA-Z0-9]*)'
         '|&#(x[0-9a-zA-Z]+|[0-9]+))(;?)')
 
     def convert_charref(self, name):
         self.append(("charref", "convert", name))
-        if name.startswith('x'):
-            return unichr(int(name[1:],16))
-        else:
-            return unichr(int(name))
+        if name[0] != "x":
+            return EventCollector.convert_charref(self, name)
+
+    def convert_codepoint(self, codepoint):
+        self.append(("codepoint", "convert", codepoint))
+        EventCollector.convert_codepoint(self, codepoint)
 
     def convert_entityref(self, name):
         self.append(("entityref", "convert", name))
-        return unichr(self.htmlentitydefs.name2codepoint[name])
+        return EventCollector.convert_entityref(self, name)
+
+    # These to record that they were called, then pass the call along
+    # to the default implementation so that it's actions can be
+    # recorded.
+
+    def handle_charref(self, data):
+        self.append(("charref", data))
+        sgmllib.SGMLParser.handle_charref(self, data)
+
+    def handle_entityref(self, data):
+        self.append(("entityref", data))
+        sgmllib.SGMLParser.handle_entityref(self, data)
 
 
 class SGMLParserTestCase(unittest.TestCase):
@@ -251,20 +267,53 @@
                                 ])])
 
     def test_convert_overrides(self):
+        # This checks that the character and entity reference
+        # conversion helpers are called at the documented times.  No
+        # attempt is made to really change what the parser accepts.
+        #
         self.collector = HTMLEntityCollector
-        self.check_events('<a title="&ldquo;test&#x201d;">foo</a>', [
+        self.check_events(('<a title="&ldquo;test&#x201d;">foo</a>'
+                           '&foobar;&#42;'), [
             ('entityref', 'convert', 'ldquo'),
             ('charref', 'convert', 'x201d'),
-            ('starttag', 'a', [('title', u'\u201ctest\u201d')]),
+            ('starttag', 'a', [('title', '&ldquo;test&#x201d;')]),
             ('data', 'foo'),
             ('endtag', 'a'),
-            ])
+            ('entityref', 'foobar'),
+            ('entityref', 'convert', 'foobar'),
+            ('charref', '42'),
+            ('charref', 'convert', '42'),
+            ('codepoint', 'convert', 42),
+            ])
+
+    def test_attr_values_quoted_markup(self):
+        """Multi-line and markup in attribute values"""
+        self.check_events("""<a title='foo\n<br>bar'>text</a>""",
+            [("starttag", "a", [("title", "foo\n<br>bar")]),
+             ("data", "text"),
+             ("endtag", "a")])
+        self.check_events("""<a title='less < than'>text</a>""",
+            [("starttag", "a", [("title", "less < than")]),
+             ("data", "text"),
+             ("endtag", "a")])
+        self.check_events("""<a title='greater > than'>text</a>""",
+            [("starttag", "a", [("title", "greater > than")]),
+             ("data", "text"),
+             ("endtag", "a")])
 
     def test_attr_funky_names(self):
         self.check_events("""<a a.b='v' c:d=v e-f=v>""", [
             ("starttag", "a", [("a.b", "v"), ("c:d", "v"), ("e-f", "v")]),
             ])
 
+    def test_attr_value_ip6_url(self):
+        # http://www.python.org/sf/853506
+        self.check_events(("<a href='http://[1080::8:800:200C:417A]/'>"
+                           "<a href=http://[1080::8:800:200C:417A]/>"), [
+            ("starttag", "a", [("href", "http://[1080::8:800:200C:417A]/")]),
+            ("starttag", "a", [("href", "http://[1080::8:800:200C:417A]/")]),
+            ])
+
     def test_illegal_declarations(self):
         s = 'abc<!spacer type="block" height="25">def'
         self.check_events(s, [

Modified: stackless/trunk/Lib/test/test_socket.py
==============================================================================
--- stackless/trunk/Lib/test/test_socket.py	(original)
+++ stackless/trunk/Lib/test/test_socket.py	Fri Jul 14 14:39:40 2006
@@ -582,6 +582,21 @@
     def _testRecvFrom(self):
         self.cli.sendto(MSG, 0, (HOST, PORT))
 
+class TCPCloserTest(ThreadedTCPSocketTest):
+
+    def testClose(self):
+        conn, addr = self.serv.accept()
+        conn.close()
+
+        sd = self.cli
+        read, write, err = select.select([sd], [], [], 1.0)
+        self.assertEqual(read, [sd])
+        self.assertEqual(sd.recv(1), '')
+
+    def _testClose(self):
+        self.cli.connect((HOST, PORT))
+        time.sleep(1.0)
+
 class BasicSocketPairTest(SocketPairTest):
 
     def __init__(self, methodName='runTest'):
@@ -890,8 +905,8 @@
         self.serv_conn.send(buf)
 
 def test_main():
-    tests = [GeneralModuleTests, BasicTCPTest, TCPTimeoutTest, TestExceptions,
-             BufferIOTest]
+    tests = [GeneralModuleTests, BasicTCPTest, TCPCloserTest, TCPTimeoutTest,
+             TestExceptions, BufferIOTest]
     if sys.platform != 'mac':
         tests.extend([ BasicUDPTest, UDPTimeoutTest ])
 

Modified: stackless/trunk/Lib/test/test_socket_ssl.py
==============================================================================
--- stackless/trunk/Lib/test/test_socket_ssl.py	(original)
+++ stackless/trunk/Lib/test/test_socket_ssl.py	Fri Jul 14 14:39:40 2006
@@ -3,6 +3,7 @@
 import sys
 from test import test_support
 import socket
+import errno
 
 # Optionally test SSL support.  This requires the 'network' resource as given
 # on the regrtest command line.
@@ -33,6 +34,13 @@
 def test_timeout():
     test_support.requires('network')
 
+    def error_msg(extra_msg):
+        print >> sys.stderr, """\
+    WARNING:  an attempt to connect to %r %s, in
+    test_timeout.  That may be legitimate, but is not the outcome we hoped
+    for.  If this message is seen often, test_timeout should be changed to
+    use a more reliable address.""" % (ADDR, extra_msg)
+
     if test_support.verbose:
         print "test_timeout ..."
 
@@ -48,12 +56,14 @@
     try:
         s.connect(ADDR)
     except socket.timeout:
-        print >> sys.stderr, """\
-    WARNING:  an attempt to connect to %r timed out, in
-    test_timeout.  That may be legitimate, but is not the outcome we hoped
-    for.  If this message is seen often, test_timeout should be changed to
-    use a more reliable address.""" % (ADDR,)
+        error_msg('timed out')
         return
+    except socket.error, exc:  # In case connection is refused.
+        if exc.args[0] == errno.ECONNREFUSED:
+            error_msg('was refused')
+            return
+        else:
+            raise
 
     ss = socket.ssl(s)
     # Read part of return welcome banner twice.

Modified: stackless/trunk/Lib/test/test_socketserver.py
==============================================================================
--- stackless/trunk/Lib/test/test_socketserver.py	(original)
+++ stackless/trunk/Lib/test/test_socketserver.py	Fri Jul 14 14:39:40 2006
@@ -1,7 +1,8 @@
 # Test suite for SocketServer.py
 
 from test import test_support
-from test.test_support import verbose, verify, TESTFN, TestSkipped
+from test.test_support import (verbose, verify, TESTFN, TestSkipped,
+                               reap_children)
 test_support.requires('network')
 
 from SocketServer import *
@@ -199,6 +200,7 @@
         testall()
     finally:
         cleanup()
+    reap_children()
 
 if __name__ == "__main__":
     test_main()

Modified: stackless/trunk/Lib/test/test_subprocess.py
==============================================================================
--- stackless/trunk/Lib/test/test_subprocess.py	(original)
+++ stackless/trunk/Lib/test/test_subprocess.py	Fri Jul 14 14:39:40 2006
@@ -27,6 +27,18 @@
     return re.sub(r"\[\d+ refs\]\r?\n?$", "", stderr)
 
 class ProcessTestCase(unittest.TestCase):
+    def setUp(self):
+        # Try to minimize the number of children we have so this test
+        # doesn't crash on some buildbots (Alphas in particular).
+        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).
+        if hasattr(test_support, "reap_children"):
+            test_support.reap_children()
+
     def mkstemp(self):
         """wrapper for mkstemp, calling mktemp if mkstemp is not available"""
         if hasattr(tempfile, "mkstemp"):
@@ -384,7 +396,8 @@
 
     def test_no_leaking(self):
         # Make sure we leak no resources
-        if test_support.is_resource_enabled("subprocess") and not mswindows:
+        if not hasattr(test_support, "is_resource_enabled") \
+               or test_support.is_resource_enabled("subprocess") and not mswindows:
             max_handles = 1026 # too much for most UNIX systems
         else:
             max_handles = 65
@@ -599,6 +612,8 @@
 
 def test_main():
     test_support.run_unittest(ProcessTestCase)
+    if hasattr(test_support, "reap_children"):
+        test_support.reap_children()
 
 if __name__ == "__main__":
     test_main()

Modified: stackless/trunk/Lib/test/test_support.py
==============================================================================
--- stackless/trunk/Lib/test/test_support.py	(original)
+++ stackless/trunk/Lib/test/test_support.py	Fri Jul 14 14:39:40 2006
@@ -475,3 +475,24 @@
     while len(threading._limbo) != num_limbo and count < _MAX_COUNT:
         count += 1
         time.sleep(0.1)
+
+def reap_children():
+    """Use this function at the end of test_main() whenever sub-processes
+    are started.  This will help ensure that no extra children (zombies)
+    stick around to hog resources and create problems when looking
+    for refleaks.
+    """
+
+    # Reap all our dead child processes so we don't leave zombies around.
+    # These hog resources and might be causing some of the buildbots to die.
+    import os
+    if hasattr(os, 'waitpid'):
+        any_process = -1
+        while True:
+            try:
+                # This will raise an exception on Windows.  That's ok.
+                pid, status = os.waitpid(any_process, os.WNOHANG)
+                if pid == 0:
+                    break
+            except:
+                break

Modified: stackless/trunk/Lib/test/test_sys.py
==============================================================================
--- stackless/trunk/Lib/test/test_sys.py	(original)
+++ stackless/trunk/Lib/test/test_sys.py	Fri Jul 14 14:39:40 2006
@@ -237,6 +237,67 @@
             is sys._getframe().f_code
         )
 
+    # sys._current_frames() is a CPython-only gimmick.
+    def test_current_frames(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(), and is blocked
+        # in 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.assertEqual(sourceline, "leave_g.wait()")
+
+        # Reap the spawned thread.
+        leave_g.set()
+        t.join()
+
     def test_attributes(self):
         self.assert_(isinstance(sys.api_version, int))
         self.assert_(isinstance(sys.argv, list))

Modified: stackless/trunk/Lib/test/test_wait3.py
==============================================================================
--- stackless/trunk/Lib/test/test_wait3.py	(original)
+++ stackless/trunk/Lib/test/test_wait3.py	Fri Jul 14 14:39:40 2006
@@ -2,8 +2,9 @@
 """
 
 import os
+import time
 from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
 
 try:
     os.fork
@@ -17,16 +18,21 @@
 
 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)
 
 def test_main():
     run_unittest(Wait3Test)
+    reap_children()
 
 if __name__ == "__main__":
     test_main()

Modified: stackless/trunk/Lib/test/test_wait4.py
==============================================================================
--- stackless/trunk/Lib/test/test_wait4.py	(original)
+++ stackless/trunk/Lib/test/test_wait4.py	Fri Jul 14 14:39:40 2006
@@ -2,8 +2,9 @@
 """
 
 import os
+import time
 from test.fork_wait import ForkWait
-from test.test_support import TestSkipped, run_unittest
+from test.test_support import TestSkipped, run_unittest, reap_children
 
 try:
     os.fork
@@ -17,13 +18,20 @@
 
 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)
 
 def test_main():
     run_unittest(Wait4Test)
+    reap_children()
 
 if __name__ == "__main__":
     test_main()

Modified: stackless/trunk/Lib/test/test_warnings.py
==============================================================================
--- stackless/trunk/Lib/test/test_warnings.py	(original)
+++ stackless/trunk/Lib/test/test_warnings.py	Fri Jul 14 14:39:40 2006
@@ -81,6 +81,19 @@
         self.assertEqual(msg.message, text)
         self.assertEqual(msg.category, 'UserWarning')
 
+    def test_options(self):
+        # Uses the private _setoption() function to test the parsing
+        # of command-line warning arguments
+        self.assertRaises(warnings._OptionError,
+                          warnings._setoption, '1:2:3:4:5:6')
+        self.assertRaises(warnings._OptionError,
+                          warnings._setoption, 'bogus::Warning')
+        self.assertRaises(warnings._OptionError,
+                          warnings._setoption, 'ignore:2::4:-5')
+        warnings._setoption('error::Warning::0')
+        self.assertRaises(UserWarning, warnings.warn, 'convert to error')
+
+
 def test_main(verbose=None):
     # Obscure hack so that this test passes after reloads or repeated calls
     # to test_main (regrtest -R).

Modified: stackless/trunk/Lib/warnings.py
==============================================================================
--- stackless/trunk/Lib/warnings.py	(original)
+++ stackless/trunk/Lib/warnings.py	Fri Jul 14 14:39:40 2006
@@ -254,11 +254,11 @@
             cat = getattr(m, klass)
         except AttributeError:
             raise _OptionError("unknown warning category: %r" % (category,))
-    if (not isinstance(cat, types.ClassType) or
-        not issubclass(cat, Warning)):
+    if not issubclass(cat, Warning):
         raise _OptionError("invalid warning category: %r" % (category,))
     return cat
 
 # Module initialization
 _processoptions(sys.warnoptions)
 simplefilter("ignore", category=PendingDeprecationWarning, append=1)
+simplefilter("ignore", category=ImportWarning, append=1)

Modified: stackless/trunk/Lib/xmlcore/etree/ElementTree.py
==============================================================================
--- stackless/trunk/Lib/xmlcore/etree/ElementTree.py	(original)
+++ stackless/trunk/Lib/xmlcore/etree/ElementTree.py	Fri Jul 14 14:39:40 2006
@@ -84,7 +84,7 @@
     "tostring",
     "TreeBuilder",
     "VERSION", "XML",
-    "XMLTreeBuilder",
+    "XMLParser", "XMLTreeBuilder",
     ]
 
 ##
@@ -1255,3 +1255,6 @@
         tree = self._target.close()
         del self._target, self._parser # get rid of circular references
         return tree
+
+# compatibility
+XMLParser = XMLTreeBuilder

Modified: stackless/trunk/Mac/BuildScript/build-installer.py
==============================================================================
--- stackless/trunk/Mac/BuildScript/build-installer.py	(original)
+++ stackless/trunk/Mac/BuildScript/build-installer.py	Fri Jul 14 14:39:40 2006
@@ -67,6 +67,8 @@
 SDKPATH="/Developer/SDKs/MacOSX10.4u.sdk"
 #SDKPATH="/"
 
+ARCHLIST=('i386', 'ppc',)
+
 # Source directory (asume we're in Mac/BuildScript)
 SRCDIR=os.path.dirname(
         os.path.dirname(
@@ -91,6 +93,26 @@
 # batteries included python.
 LIBRARY_RECIPES=[
     dict(
+        name="Bzip2 1.0.3",
+        url="http://www.bzip.org/1.0.3/bzip2-1.0.3.tar.gz",
+        configure=None,
+        install='make install PREFIX=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
+            shellQuote(os.path.join(WORKDIR, 'libraries')),
+            ' -arch '.join(ARCHLIST),
+            SDKPATH,
+        ),
+    ),
+    dict(
+        name="ZLib 1.2.3",
+        url="http://www.gzip.org/zlib/zlib-1.2.3.tar.gz",
+        configure=None,
+        install='make install prefix=%s/usr/local/ CFLAGS="-arch %s -isysroot %s"'%(
+            shellQuote(os.path.join(WORKDIR, 'libraries')),
+            ' -arch '.join(ARCHLIST),
+            SDKPATH,
+        ),
+    ),
+    dict(
         # Note that GNU readline is GPL'd software
         name="GNU Readline 5.1.4",
         url="http://ftp.gnu.org/pub/gnu/readline/readline-5.1.tar.gz" ,
@@ -486,48 +508,49 @@
         runCommand('patch -p%s < %s'%(recipe.get('patchlevel', 1),
             shellQuote(fn),))
 
-    configure_args = [
-        "--prefix=/usr/local",
-        "--enable-static",
-        "--disable-shared",
-        #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),),
-    ]
-
-    if 'configure_pre' in recipe:
-        args = list(recipe['configure_pre'])
-        if '--disable-static' in args:
-            configure_args.remove('--enable-static')
-        if '--enable-shared' in args:
-            configure_args.remove('--disable-shared')
-        configure_args.extend(args)
-
-    if recipe.get('useLDFlags', 1):
-        configure_args.extend([
-            "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
-                    ' -arch '.join(archList),
-                    shellQuote(SDKPATH)[1:-1],
-                    shellQuote(basedir)[1:-1],),
-            "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%(
-                shellQuote(SDKPATH)[1:-1],
-                shellQuote(basedir)[1:-1],
-                ' -arch '.join(archList)),
-        ])
-    else:
-        configure_args.extend([
-            "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
-                    ' -arch '.join(archList),
+    if configure is not None:
+        configure_args = [
+            "--prefix=/usr/local",
+            "--enable-static",
+            "--disable-shared",
+            #"CPP=gcc -arch %s -E"%(' -arch '.join(archList,),),
+        ]
+
+        if 'configure_pre' in recipe:
+            args = list(recipe['configure_pre'])
+            if '--disable-static' in args:
+                configure_args.remove('--enable-static')
+            if '--enable-shared' in args:
+                configure_args.remove('--disable-shared')
+            configure_args.extend(args)
+
+        if recipe.get('useLDFlags', 1):
+            configure_args.extend([
+                "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
+                        ' -arch '.join(archList),
+                        shellQuote(SDKPATH)[1:-1],
+                        shellQuote(basedir)[1:-1],),
+                "LDFLAGS=-syslibroot,%s -L%s/usr/local/lib -arch %s"%(
                     shellQuote(SDKPATH)[1:-1],
-                    shellQuote(basedir)[1:-1],),
-        ])
+                    shellQuote(basedir)[1:-1],
+                    ' -arch '.join(archList)),
+            ])
+        else:
+            configure_args.extend([
+                "CFLAGS=-arch %s -isysroot %s -I%s/usr/local/include"%(
+                        ' -arch '.join(archList),
+                        shellQuote(SDKPATH)[1:-1],
+                        shellQuote(basedir)[1:-1],),
+            ])
 
-    if 'configure_post' in recipe:
-        configure_args = configure_args = list(recipe['configure_post'])
+        if 'configure_post' in recipe:
+            configure_args = configure_args = list(recipe['configure_post'])
 
-    configure_args.insert(0, configure)
-    configure_args = [ shellQuote(a) for a in configure_args ]
+        configure_args.insert(0, configure)
+        configure_args = [ shellQuote(a) for a in configure_args ]
 
-    print "Running configure for %s"%(name,)
-    runCommand(' '.join(configure_args) + ' 2>&1')
+        print "Running configure for %s"%(name,)
+        runCommand(' '.join(configure_args) + ' 2>&1')
 
     print "Running install for %s"%(name,)
     runCommand('{ ' + install + ' ;} 2>&1')
@@ -550,7 +573,7 @@
     os.makedirs(os.path.join(universal, 'usr', 'local', 'include'))
 
     for recipe in LIBRARY_RECIPES:
-        buildRecipe(recipe, universal, ('i386', 'ppc',))
+        buildRecipe(recipe, universal, ARCHLIST)
 
 
 
@@ -997,7 +1020,7 @@
     buildPythonDocs()
     fn = os.path.join(WORKDIR, "_root", "Applications",
                 "MacPython %s"%(getVersion(),), "Update Shell Profile.command")
-    shutil.copy("scripts/postflight.patch-profile",  fn)
+    patchFile("scripts/postflight.patch-profile",  fn)
     os.chmod(fn, 0755)
 
     folder = os.path.join(WORKDIR, "_root", "Applications", "MacPython %s"%(

Modified: stackless/trunk/Mac/BuildScript/resources/Welcome.rtf
==============================================================================
--- stackless/trunk/Mac/BuildScript/resources/Welcome.rtf	(original)
+++ stackless/trunk/Mac/BuildScript/resources/Welcome.rtf	Fri Jul 14 14:39:40 2006
@@ -1,4 +1,4 @@
-{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf330
+{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf410
 {\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;}
 {\colortbl;\red255\green255\blue255;}
 \paperw11900\paperh16840\margl1440\margr1440\vieww9920\viewh10660\viewkind0
@@ -12,4 +12,7 @@
 \
 MacPython consists of the Python programming language interpreter, plus a set of programs to allow easy access to it for Mac users (an integrated development environment, an applet builder), plus a set of pre-built extension modules that open up specific Macintosh technologies to Python programs (Carbon, AppleScript, Quicktime, more).\
 \
-See the ReadMe file for more information.}
\ No newline at end of file
+See the ReadMe file for more information.\
+\
+\
+This package will by default update your shell profile to ensure that this version of Python is on the search path of your shell. Please deselect the "Shell profile updater" package on the package customization screen  if you want to avoid this modification. }
\ No newline at end of file

Modified: stackless/trunk/Mac/BuildScript/scripts/postflight.framework
==============================================================================
--- stackless/trunk/Mac/BuildScript/scripts/postflight.framework	(original)
+++ stackless/trunk/Mac/BuildScript/scripts/postflight.framework	Fri Jul 14 14:39:40 2006
@@ -4,7 +4,7 @@
 #
 
 PYVER="@PYVER@"
-FWK="/Library/Frameworks/Python.framework/Versions/@PYVER@/"
+FWK="/Library/Frameworks/Python.framework/Versions/@PYVER@"
 
 "${FWK}/bin/python" -Wi -tt \
     "${FWK}/lib/python${PYVER}/compileall.py" \

Modified: stackless/trunk/Mac/Demo/applescript.html
==============================================================================
--- stackless/trunk/Mac/Demo/applescript.html	(original)
+++ stackless/trunk/Mac/Demo/applescript.html	Fri Jul 14 14:39:40 2006
@@ -4,6 +4,10 @@
 <h1>Using the Open Scripting Architecture from Python</h1>
 <hr>
 
+<p><b>NOTE:</b> this document describes the OSA support that is shipped with
+the core python distribution. Most users are better of with the more 
+userfriendly <a href="http://freespace.virgin.net/hamish.sanderson/appscript.html">appscript library</a>.
+
 <p>OSA support in Python is still not 100% complete, but
 there is already enough in place to allow you to do some nifty things
 with other programs from your python program. </p> 
@@ -355,4 +359,4 @@
 
 
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: stackless/trunk/Mac/Demo/index.html
==============================================================================
--- stackless/trunk/Mac/Demo/index.html	(original)
+++ stackless/trunk/Mac/Demo/index.html	Fri Jul 14 14:39:40 2006
@@ -3,15 +3,16 @@
 <H1><IMG SRC="html.icons/python.gif">Macintosh Python crash course</H1>
 <HR>
 
-This set of documents provides an introduction to various aspects of
+<p>This set of documents provides an introduction to various aspects of
 Python programming on the Mac. It is assumed that the reader is
 already familiar with Python and, to some extent, with MacOS Toolbox
 programming. Other readers may find something interesting here too,
-your mileage may vary. <p>
+your mileage may vary. </p>
 
-There is a companion document <a href="using.html">Using Python on the Mac</a>
-which you should read before starting here: it explains the basics of using
-python on the Macintosh. <p>
+<p>As the previous paragraph reveals to the careful observer these examples
+are dated, most of them were writting before OSX and haven't been updated
+afterwards. They still show how to use the Carbon wrappers but aren't 
+necessarily the best way to use the Carbon API's in OSX.</p>
 
 Another set of Macintosh-savvy examples, more aimed at beginners, is
 maintained by Joseph Strout, at Python Tidbits in <A
@@ -27,10 +28,9 @@
 href="http://www.python.org/doc/">documentation</a> section on the
 webserver. <p>
 
-The W widget set by Just van Rossum, which is used by the Python IDE, does not
-have complete documentation as of this writing, but Corran Webster has
-documented most of it on his
-<A HREF="http://www.nevada.edu/~cwebster/Python/">Python Page</A>. <p>
+<p>The W widget set by Just van Rossum, does not have complete documentation as 
+of this writing, but Corran Webster has documented most of it on his
+<A HREF="http://www.nevada.edu/~cwebster/Python/">Python Page</A>.</p>
 
 There are also some documentation links, as well as other MacPython-related
 pages, in the

Modified: stackless/trunk/Makefile.pre.in
==============================================================================
--- stackless/trunk/Makefile.pre.in	(original)
+++ stackless/trunk/Makefile.pre.in	Fri Jul 14 14:39:40 2006
@@ -739,14 +739,14 @@
 	plat-mac/lib-scriptpackages/Netscape \
 	plat-mac/lib-scriptpackages/StdSuites \
 	plat-mac/lib-scriptpackages/SystemEvents \
-	plat-mac/lib-scriptpackages/Terminal
+	plat-mac/lib-scriptpackages/Terminal 
 PLATMACPATH=:plat-mac:plat-mac/lib-scriptpackages
-LIBSUBDIRS=	lib-old lib-tk site-packages test test/output test/data \
+LIBSUBDIRS=	lib-tk site-packages test test/output test/data \
 		test/decimaltestdata \
 		encodings compiler hotshot \
 		email email/mime email/test email/test/data \
 		sqlite3 sqlite3/test \
-		logging bsddb bsddb/test csv \
+		logging bsddb bsddb/test csv wsgiref \
 		ctypes ctypes/test ctypes/macholib idlelib idlelib/Icons \
 		distutils distutils/command distutils/tests $(XMLLIBSUBDIRS) \
 		setuptools setuptools/command setuptools/tests setuptools.egg-info \
@@ -771,7 +771,7 @@
 		else	true; \
 		fi; \
 	done
-	@for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc; \
+	@for i in $(srcdir)/Lib/*.py $(srcdir)/Lib/*.doc $(srcdir)/Lib/*.egg-info ; \
 	do \
 		if test -x $$i; then \
 			$(INSTALL_SCRIPT) $$i $(DESTDIR)$(LIBDEST); \
@@ -982,7 +982,10 @@
 	$(INSTALL_SHARED) $(LDLIBRARY) $(DESTDIR)$(PYTHONFRAMEWORKPREFIX)/$(LDLIBRARY)
 
 # This installs Mac/Lib into the framework
+# 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"
 	cd Mac && $(MAKE) installmacsubtree DESTDIR="$(DESTDIR)"
 
 # This installs the IDE, the Launcher and other apps into /Applications

Modified: stackless/trunk/Misc/NEWS
==============================================================================
--- stackless/trunk/Misc/NEWS	(original)
+++ stackless/trunk/Misc/NEWS	Fri Jul 14 14:39:40 2006
@@ -4,8 +4,172 @@
 
 (editors: check NEWS.help for information about editing NEWS using ReST.)
 
+What's New in Python 2.5 beta 2?
+================================
+
+*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.
+
+- Bug #1417699: Reject locale-specific decimal point in float()
+  and atof().
+
+- Bug #1511381: codec_getstreamcodec() in codec.c is corrected to
+  omit a default "error" argument for NULL pointer.  This allows
+  the parser to take a codec from cjkcodecs again.
+
+- 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
+-------
+
+- 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.
+
+- Bug #822974: Honor timeout in telnetlib.{expect,read_until}
+  even if some data are received.
+
+- Bug #1267547: Put proper recursive setup.py call into the
+  spec file generated by bdist_rpm.
+
+- Bug #1514693: Update turtle's heading when switching between
+  degrees and radians.
+
+- Reimplement turtle.circle using a polyline, to allow correct
+  filling of arcs.
+
+- Bug #1514703: Only setup canvas window in turtle when the canvas
+  is created.
+
+- Bug #1513223: .close() of a _socketobj now releases the underlying
+  socket again, which then gets closed as it becomes unreferenced.
+
+- Bug #1504333: Make sgmllib support angle brackets in quoted
+  attribute values.
+
+- Bug #853506: Fix IPv6 address parsing in unquoted attributes in
+  sgmllib ('[' and ']' were not accepted).
+
+- Fix a bug in the turtle module's end_fill function.
+
+- Bug #1510580: The 'warnings' module improperly required that a Warning
+  category be either a types.ClassType and a subclass of Warning.  The proper
+  check is just that it is a subclass with Warning as the documentation states.
+
+- The compiler module now correctly compiles the new try-except-finally
+  statement (bug #1509132).
+
+- The wsgiref package is now installed properly on Unix.
+
+- A bug was fixed in logging.config.fileConfig() which caused a crash on
+  shutdown when fileConfig() was called multiple times.
+
+- The sqlite3 module did cut off data from the SQLite database at the first
+  null character before sending it to a custom converter. This has been fixed
+  now.
+
+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
+-----
+
+- '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.
+
+Tests
+-----
+
+- Call os.waitpid() at the end of tests that spawn child processes in order
+  to minimize resources (zombies).
+
+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?
-=================================
+================================
 
 *Release date: 20-JUN-2006*
 
@@ -22,7 +186,7 @@
 - Fix the socket tests so they can be run concurrently.
 
 - Removed 5 integers from C frame objects (PyFrameObject).
-	f_nlocals, f_ncells, f_nfreevars, f_stack_size, f_restricted.
+  f_nlocals, f_ncells, f_nfreevars, f_stack_size, f_restricted.
 
 - Bug #532646: object.__call__() will continue looking for the __call__
   attribute on objects until one without one is found.  This leads to recursion
@@ -102,6 +266,10 @@
 Extension Modules
 -----------------
 
+- Bug #1295808: expat symbols should be namespaced in pyexpat
+
+- Patch #1462338: Upgrade pyexpat to expat 2.0.0
+
 - Change binascii.hexlify to accept a read-only buffer instead of only a char
   buffer and actually follow its documentation.
 
@@ -157,11 +325,11 @@
   Fixes SF python patch/bug #1408584.
 
 - bsddb: multithreaded DB access using the simple bsddb module interface
-  now works reliably.  It has been updated to use automatic BerkeleyDB 
+  now works reliably.  It has been updated to use automatic BerkeleyDB
   deadlock detection and the bsddb.dbutils.DeadlockWrap wrapper to retry
   database calls that would previously deadlock. [SF python bug #775414]
 
-- Patch #1446489: add support for the ZIP64 extensions to zipfile. 
+- Patch #1446489: add support for the ZIP64 extensions to zipfile.
 
 - Patch #1506645: add Python wrappers for the curses functions
   is_term_resized, resize_term and resizeterm.
@@ -174,7 +342,7 @@
 
 - Patch #812986: Update turtle output even if not tracing.
 
-- Patch #1494750: Destroy master after deleting children in 
+- Patch #1494750: Destroy master after deleting children in
   Tkinter.BaseWidget.
 
 - Patch #1096231: Add ``default`` argument to Tkinter.Wm.wm_iconbitmap.

Modified: stackless/trunk/Misc/RPM/python-2.5.spec
==============================================================================
--- stackless/trunk/Misc/RPM/python-2.5.spec	(original)
+++ stackless/trunk/Misc/RPM/python-2.5.spec	Fri Jul 14 14:39:40 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: stackless/trunk/Misc/Vim/python.vim
==============================================================================
--- stackless/trunk/Misc/Vim/python.vim	(original)
+++ stackless/trunk/Misc/Vim/python.vim	Fri Jul 14 14:39:40 2006
@@ -85,7 +85,7 @@
   syn keyword pythonException    LookupError OSError DeprecationWarning
   syn keyword pythonException    UnicodeError UnicodeEncodeError
   syn keyword pythonException    FloatingPointError ReferenceError NameError
-  syn keyword pythonException    OverflowWarning IOError SyntaxError
+  syn keyword pythonException    IOError SyntaxError
   syn keyword pythonException    FutureWarning ImportWarning SystemExit
   syn keyword pythonException    Exception EOFError StandardError ValueError
   syn keyword pythonException    TabError KeyError ZeroDivisionError SystemError

Modified: stackless/trunk/Misc/build.sh
==============================================================================
--- stackless/trunk/Misc/build.sh	(original)
+++ stackless/trunk/Misc/build.sh	Fri Jul 14 14:39:40 2006
@@ -54,6 +54,12 @@
 INSTALL_DIR="/tmp/python-test/local"
 RSYNC_OPTS="-aC -e ssh"
 
+# Always run the installed version of Python.
+PYTHON=$INSTALL_DIR/bin/python
+
+# Python options and regression test program that should always be run.
+REGRTEST_ARGS="-E -tt $INSTALL_DIR/lib/python2.5/test/regrtest.py"
+
 REFLOG="build/reflog.txt.out"
 # These tests are not stable and falsely report leaks sometimes.
 # The entire leak report will be mailed if any test not in this list leaks.
@@ -158,18 +164,24 @@
             ## make and run basic tests
             F=make-test.out
             start=`current_time`
-            make test >& build/$F
+            $PYTHON $REGRTEST_ARGS >& build/$F
             NUM_FAILURES=`grep -ic " failed:" build/$F`
             update_status "Testing basics ($NUM_FAILURES failures)" "$F" $start
-            ## FIXME: should mail since -uall below should find same problems
             mail_on_failure "basics" build/$F
 
+            F=make-test-opt.out
+            start=`current_time`
+            $PYTHON -O $REGRTEST_ARGS >& build/$F
+            NUM_FAILURES=`grep -ic " failed:" build/$F`
+            update_status "Testing opt ($NUM_FAILURES failures)" "$F" $start
+            mail_on_failure "opt" build/$F
+
             ## run the tests looking for leaks
             F=make-test-refleak.out
             start=`current_time`
             ## ensure that the reflog exists so the grep doesn't fail
             touch $REFLOG
-            ./python ./Lib/test/regrtest.py -R 4:3:$REFLOG -u network $LEAKY_SKIPS >& build/$F
+            $PYTHON $REGRTEST_ARGS -R 4:3:$REFLOG -u network $LEAKY_SKIPS >& build/$F
             NUM_FAILURES=`egrep -vc "$LEAKY_TESTS" $REFLOG`
             update_status "Testing refleaks ($NUM_FAILURES failures)" "$F" $start
             mail_on_failure "refleak" $REFLOG
@@ -179,7 +191,7 @@
             start=`current_time`
             ## skip curses when running from cron since there's no terminal
             ## skip sound since it's not setup on the PSF box (/dev/dsp)
-            ./python -E -tt ./Lib/test/regrtest.py -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F
+            $PYTHON $REGRTEST_ARGS -uall -x test_curses test_linuxaudiodev test_ossaudiodev >& build/$F
             NUM_FAILURES=`grep -ic " failed:" build/$F`
             update_status "Testing all except curses and sound ($NUM_FAILURES failures)" "$F" $start
             mail_on_failure "all" build/$F
@@ -189,7 +201,7 @@
 
 
 ## make doc
-cd Doc
+cd $DIR/Doc
 F="make-doc.out"
 start=`current_time`
 make >& ../build/$F

Modified: stackless/trunk/Misc/cheatsheet
==============================================================================
--- stackless/trunk/Misc/cheatsheet	(original)
+++ stackless/trunk/Misc/cheatsheet	Fri Jul 14 14:39:40 2006
@@ -1135,7 +1135,6 @@
               DeprecationWarning
               PendingDeprecationWarning
               SyntaxWarning
-              OverflowWarning
               RuntimeWarning
               FutureWarning
 

Modified: stackless/trunk/Misc/valgrind-python.supp
==============================================================================
--- stackless/trunk/Misc/valgrind-python.supp	(original)
+++ stackless/trunk/Misc/valgrind-python.supp	Fri Jul 14 14:39:40 2006
@@ -134,6 +134,15 @@
 ###
 
 {
+   Generic gentoo ld problems
+   Memcheck:Cond
+   obj:/lib/ld-2.3.4.so
+   obj:/lib/ld-2.3.4.so
+   obj:/lib/ld-2.3.4.so
+   obj:/lib/ld-2.3.4.so
+}
+
+{
    DBM problems, see test_dbm
    Memcheck:Param
    write(buf)

Modified: stackless/trunk/Modules/_ctypes/_ctypes.c
==============================================================================
--- stackless/trunk/Modules/_ctypes/_ctypes.c	(original)
+++ stackless/trunk/Modules/_ctypes/_ctypes.c	Fri Jul 14 14:39:40 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 {
@@ -4555,7 +4561,9 @@
    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
 	PyEval_InitThreads();
+#endif
 	m = Py_InitModule3("_ctypes", module_methods, module_docs);
 	if (!m)
 		return;

Modified: stackless/trunk/Modules/_ctypes/callbacks.c
==============================================================================
--- stackless/trunk/Modules/_ctypes/callbacks.c	(original)
+++ stackless/trunk/Modules/_ctypes/callbacks.c	Fri Jul 14 14:39:40 2006
@@ -127,7 +127,9 @@
 	PyObject *result;
 	PyObject *arglist = NULL;
 	int nArgs;
+#ifdef WITH_THREADS
 	PyGILState_STATE state = PyGILState_Ensure();
+#endif
 
 	nArgs = PySequence_Length(converters);
 	/* Hm. What to return in case of error?
@@ -235,8 +237,9 @@
 	Py_XDECREF(result);
   Done:
 	Py_XDECREF(arglist);
-	
+#ifdef WITH_THREADS	
 	PyGILState_Release(state);
+#endif
 }
 
 static void closure_fcn(ffi_cif *cif,
@@ -397,12 +400,18 @@
 			 LPVOID *ppv)
 {
 	long result;
+#ifdef WITH_THREADS
 	PyGILState_STATE state;
+#endif
 
 	LoadPython();
+#ifdef WITH_THREADS
 	state = PyGILState_Ensure();
+#endif
 	result = Call_GetClassObject(rclsid, riid, ppv);
+#ifdef WITH_THREADS
 	PyGILState_Release(state);
+#endif
 	return result;
 }
 
@@ -454,9 +463,13 @@
 STDAPI DllCanUnloadNow(void)
 {
 	long result;
+#ifdef WITH_THREADS
 	PyGILState_STATE state = PyGILState_Ensure();
+#endif
 	result = Call_CanUnloadNow();
+#ifdef WITH_THREADS
 	PyGILState_Release(state);
+#endif
 	return result;
 }
 

Modified: stackless/trunk/Modules/_ctypes/callproc.c
==============================================================================
--- stackless/trunk/Modules/_ctypes/callproc.c	(original)
+++ stackless/trunk/Modules/_ctypes/callproc.c	Fri Jul 14 14:39:40 2006
@@ -617,7 +617,9 @@
 				  void *resmem,
 				  int argcount)
 {
+#ifdef WITH_THREADS
 	PyThreadState *_save = NULL; /* For Py_BLOCK_THREADS and Py_UNBLOCK_THREADS */
+#endif
 	ffi_cif cif;
 	int cc;
 #ifdef MS_WIN32
@@ -649,8 +651,10 @@
 		return -1;
 	}
 
+#ifdef WITH_THREADS
 	if ((flags & FUNCFLAG_PYTHONAPI) == 0)
 		Py_UNBLOCK_THREADS
+#endif
 #ifdef MS_WIN32
 #ifndef DONT_USE_SEH
 	__try {
@@ -667,8 +671,10 @@
 	}
 #endif
 #endif
+#ifdef WITH_THREADS
 	if ((flags & FUNCFLAG_PYTHONAPI) == 0)
 		Py_BLOCK_THREADS
+#endif
 #ifdef MS_WIN32
 #ifndef DONT_USE_SEH
 	if (dwExceptionCode) {
@@ -1480,7 +1486,12 @@
 	}
 	if (size < dict->size) {
 		PyErr_Format(PyExc_ValueError,
-			     "minimum size is %d", dict->size);
+#if PY_VERSION_HEX < 0x02050000
+			     "minimum size is %d",
+#else
+			     "minimum size is %zd",
+#endif
+			     dict->size);
 		return NULL;
 	}
 	if (obj->b_needsfree == 0) {

Modified: stackless/trunk/Modules/_ctypes/cfield.c
==============================================================================
--- stackless/trunk/Modules/_ctypes/cfield.c	(original)
+++ stackless/trunk/Modules/_ctypes/cfield.c	Fri Jul 14 14:39:40 2006
@@ -65,10 +65,10 @@
 	}
 	if (bitsize /* this is a bitfield request */
 	    && *pfield_size /* we have a bitfield open */
-#ifdef MS_WIN32
+#if defined(MS_WIN32) && !defined(__MINGW32__)
 	    && dict->size * 8 == *pfield_size /* MSVC */
 #else
-	    && dict->size * 8 <= *pfield_size /* GCC */
+	    && dict->size * 8 <= *pfield_size /* GCC, MINGW */
 #endif
 	    && (*pbitofs + bitsize) <= *pfield_size) {
 		/* continue bit field */
@@ -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: stackless/trunk/Modules/_ctypes/libffi/src/x86/darwin.S
==============================================================================
--- stackless/trunk/Modules/_ctypes/libffi/src/x86/darwin.S	(original)
+++ stackless/trunk/Modules/_ctypes/libffi/src/x86/darwin.S	Fri Jul 14 14:39:40 2006
@@ -35,6 +35,13 @@
 #include <fficonfig.h>
 #include <ffi.h>
 
+#ifdef PyObjC_STRICT_DEBUGGING
+  /* XXX: Debugging of stack alignment, to be removed */
+#define ASSERT_STACK_ALIGNED movdqa -16(%esp), %xmm0
+#else
+#define ASSERT_STACK_ALIGNED 
+#endif
+
 .text
 
 .globl _ffi_prep_args
@@ -47,30 +54,41 @@
         pushl %ebp
 .LCFI0:
         movl  %esp,%ebp
+	subl  $8,%esp
+	ASSERT_STACK_ALIGNED
 .LCFI1:
 	/* Make room for all of the new args.  */
 	movl  16(%ebp),%ecx
 	subl  %ecx,%esp
 
+	ASSERT_STACK_ALIGNED
+
 	movl  %esp,%eax
 
 	/* Place all of the ffi_prep_args in position  */
+	subl  $8,%esp
 	pushl 12(%ebp)
 	pushl %eax
 	call  *8(%ebp)
 
+	ASSERT_STACK_ALIGNED
+
 	/* Return stack to previous state and call the function  */
-	addl  $8,%esp	
+	addl  $16,%esp
 
-	call  *28(%ebp)
+	ASSERT_STACK_ALIGNED
 
-	/* Remove the space we pushed for the args  */
+	call  *28(%ebp)
+	
+	/* XXX: return returns return with 'ret $4', that upsets the stack! */
 	movl  16(%ebp),%ecx
 	addl  %ecx,%esp
 
+
 	/* Load %ecx with the return type code  */
 	movl  20(%ebp),%ecx	
 
+
 	/* If the return value pointer is NULL, assume no return value.  */
 	cmpl  $0,24(%ebp)
 	jne   retint
@@ -117,17 +135,47 @@
 	
 retint64:	
 	cmpl  $FFI_TYPE_SINT64,%ecx
-        jne   retstruct
+        jne   retstruct1b
 	/* Load %ecx with the pointer to storage for the return value  */
 	movl  24(%ebp),%ecx	
 	movl  %eax,0(%ecx)
 	movl  %edx,4(%ecx)
+	jmp   epilogue
+
+retstruct1b:
+   cmpl $FFI_TYPE_SINT8,%ecx
+   jne  retstruct2b
+   movl 24(%ebp),%ecx
+   movb  %al,0(%ecx)
+   jmp  epilogue
+
+retstruct2b:
+   cmpl $FFI_TYPE_SINT16,%ecx
+   jne  retstruct
+   movl 24(%ebp),%ecx
+   movw %ax,0(%ecx)
+   jmp  epilogue
 	
 retstruct:
+   cmpl $FFI_TYPE_STRUCT,%ecx
+   jne  noretval
 	/* Nothing to do!  */
 
+	subl $4,%esp
+
+	ASSERT_STACK_ALIGNED
+
+	addl $8,%esp
+	movl %ebp, %esp
+	popl %ebp
+	ret
+
 noretval:
 epilogue:
+	ASSERT_STACK_ALIGNED
+	addl $8, %esp
+
+
         movl %ebp,%esp
         popl %ebp
         ret

Modified: stackless/trunk/Modules/_ctypes/libffi/src/x86/ffi_darwin.c
==============================================================================
--- stackless/trunk/Modules/_ctypes/libffi/src/x86/ffi_darwin.c	(original)
+++ stackless/trunk/Modules/_ctypes/libffi/src/x86/ffi_darwin.c	Fri Jul 14 14:39:40 2006
@@ -140,7 +140,7 @@
   switch (cif->rtype->type)
     {
     case FFI_TYPE_VOID:
-#if !defined(X86_WIN32) 
+#if !defined(X86_WIN32)  && !defined(X86_DARWIN)
     case FFI_TYPE_STRUCT:
 #endif
     case FFI_TYPE_SINT64:
@@ -154,7 +154,7 @@
       cif->flags = FFI_TYPE_SINT64;
       break;
 
-#if defined X86_WIN32  
+#if defined(X86_WIN32) || defined(X86_DARWIN)
 
     case FFI_TYPE_STRUCT:
       if (cif->rtype->size == 1)
@@ -186,10 +186,11 @@
     }
 
   /* Darwin: The stack needs to be aligned to a multiple of 16 bytes */
-#if 0
+#if 1
   cif->bytes = (cif->bytes + 15) & ~0xF;
 #endif
 
+
   return FFI_OK;
 }
 
@@ -221,7 +222,6 @@
 	      /*@dependent@*/ void **avalue)
 {
   extended_cif ecif;
-  int flags;
 
   ecif.cif = cif;
   ecif.avalue = avalue;
@@ -238,20 +238,6 @@
   else
     ecif.rvalue = rvalue;
 
-  flags = cif->flags;
-  if (flags == FFI_TYPE_STRUCT) {
-    if (cif->rtype->size == 8) {
-	flags = FFI_TYPE_SINT64;
-    } else if (cif->rtype->size == 4) {
-        flags = FFI_TYPE_INT;
-    } else if (cif->rtype->size == 2) {
-        flags = FFI_TYPE_INT;
-    } else if (cif->rtype->size == 1) {
-        flags = FFI_TYPE_INT;
-    }
-  }
-
-  
   switch (cif->abi) 
     {
     case FFI_SYSV:
@@ -260,8 +246,8 @@
        * block is a multiple of 16. Then add 8 to compensate for local variables
        * in ffi_call_SYSV.
        */
-      ffi_call_SYSV(ffi_prep_args, &ecif, ALIGN(cif->bytes, 16) +8, 
-		    flags, ecif.rvalue, fn);
+      ffi_call_SYSV(ffi_prep_args, &ecif, cif->bytes, 
+		    cif->flags, ecif.rvalue, fn);
       /*@=usedef@*/
       break;
 #ifdef X86_WIN32
@@ -281,8 +267,6 @@
 
 /** private members **/
 
-static void ffi_prep_incoming_args_SYSV (char *stack, void **ret,
-					 void** args, ffi_cif* cif);
 static void ffi_closure_SYSV (ffi_closure *)
      __attribute__ ((regparm(1)));
 #if !FFI_NO_RAW_API
@@ -290,6 +274,48 @@
      __attribute__ ((regparm(1)));
 #endif
 
+/*@-exportheader@*/
+static inline void 
+ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
+			    void **avalue, ffi_cif *cif)
+/*@=exportheader@*/
+{
+  register unsigned int i;
+  register void **p_argv;
+  register char *argp;
+  register ffi_type **p_arg;
+
+  argp = stack;
+
+  if (retval_on_stack(cif->rtype)) {
+    *rvalue = *(void **) argp;
+    argp += 4;
+  }
+
+  p_argv = avalue;
+
+  for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
+    {
+      size_t z;
+
+      /* Align if necessary */
+      if ((sizeof(int) - 1) & (unsigned) argp) {
+	argp = (char *) ALIGN(argp, sizeof(int));
+      }
+
+      z = (*p_arg)->size;
+
+      /* because we're little endian, this is what it turns into.   */
+
+      *p_argv = (void*) argp;
+
+      p_argv++;
+      argp += z;
+    }
+  
+  return;
+}
+
 /* This function is jumped to by the trampoline */
 
 static void
@@ -302,10 +328,10 @@
   // our various things...
   ffi_cif       *cif;
   void         **arg_area;
-  unsigned short rtype;
   void          *resp = (void*)&res;
   void *args = __builtin_dwarf_cfa ();
 
+
   cif         = closure->cif;
   arg_area    = (void**) alloca (cif->nargs * sizeof (void*));  
 
@@ -319,94 +345,52 @@
   
   (closure->fun) (cif, resp, arg_area, closure->user_data);
 
-  rtype = cif->flags;
-
-  if (!retval_on_stack(cif->rtype) && cif->flags == FFI_TYPE_STRUCT) {
-      if (cif->rtype->size == 8) {
-         rtype = FFI_TYPE_SINT64;
-      } else {
-         rtype = FFI_TYPE_INT;
-      }
-  }
-
   /* now, do a generic return based on the value of rtype */
-  if (rtype == FFI_TYPE_INT)
+  if (cif->flags == FFI_TYPE_INT)
     {
       asm ("movl (%0),%%eax" : : "r" (resp) : "eax");
     }
-  else if (rtype == FFI_TYPE_FLOAT)
+  else if (cif->flags == FFI_TYPE_FLOAT)
     {
       asm ("flds (%0)" : : "r" (resp) : "st" );
     }
-  else if (rtype == FFI_TYPE_DOUBLE)
+  else if (cif->flags == FFI_TYPE_DOUBLE)
     {
       asm ("fldl (%0)" : : "r" (resp) : "st", "st(1)" );
     }
-  else if (rtype == FFI_TYPE_LONGDOUBLE)
+  else if (cif->flags == FFI_TYPE_LONGDOUBLE)
     {
       asm ("fldt (%0)" : : "r" (resp) : "st", "st(1)" );
     }
-  else if (rtype == FFI_TYPE_SINT64)
+  else if (cif->flags == FFI_TYPE_SINT64)
     {
       asm ("movl 0(%0),%%eax;"
 	   "movl 4(%0),%%edx" 
 	   : : "r"(resp)
 	   : "eax", "edx");
     }
-#ifdef X86_WIN32
-  else if (rtype == FFI_TYPE_SINT8) /* 1-byte struct  */
+#if defined(X86_WIN32) || defined(X86_DARWIN)
+  else if (cif->flags == FFI_TYPE_SINT8) /* 1-byte struct  */
     {
       asm ("movsbl (%0),%%eax" : : "r" (resp) : "eax");
     }
-  else if (rtype == FFI_TYPE_SINT16) /* 2-bytes struct */
+  else if (cif->flags == FFI_TYPE_SINT16) /* 2-bytes struct */
     {
       asm ("movswl (%0),%%eax" : : "r" (resp) : "eax");
     }
 #endif
-}
 
-/*@-exportheader@*/
-static void 
-ffi_prep_incoming_args_SYSV(char *stack, void **rvalue,
-			    void **avalue, ffi_cif *cif)
-/*@=exportheader@*/
-{
-  register unsigned int i;
-  register void **p_argv;
-  register char *argp;
-  register ffi_type **p_arg;
-
-  argp = stack;
-
-  if (retval_on_stack(cif->rtype)) {
-    *rvalue = *(void **) argp;
-    argp += 4;
-  }
-
-  p_argv = avalue;
-
-  for (i = cif->nargs, p_arg = cif->arg_types; (i != 0); i--, p_arg++)
+  else if (cif->flags == FFI_TYPE_STRUCT)
     {
-      size_t z;
-
-      /* Align if necessary */
-      if ((sizeof(int) - 1) & (unsigned) argp) {
-	argp = (char *) ALIGN(argp, sizeof(int));
-      }
-
-      z = (*p_arg)->size;
-
-      /* because we're little endian, this is what it turns into.   */
-
-      *p_argv = (void*) argp;
-
-      p_argv++;
-      argp += z;
+      asm ("lea -8(%ebp),%esp;"
+	   "pop %esi;"
+	   "pop %edi;"
+	   "pop %ebp;"
+	   "ret $4"); 
     }
-  
-  return;
 }
 
+
 /* How to make a trampoline.  Derived from gcc/config/i386/i386.c. */
 
 #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX) \

Modified: stackless/trunk/Modules/_ctypes/libffi_msvc/ffi.c
==============================================================================
--- stackless/trunk/Modules/_ctypes/libffi_msvc/ffi.c	(original)
+++ stackless/trunk/Modules/_ctypes/libffi_msvc/ffi.c	Fri Jul 14 14:39:40 2006
@@ -227,11 +227,7 @@
   void         **arg_area;
   unsigned short rtype;
   void          *resp = (void*)&res;
-//#ifdef _MSC_VER
   void *args = &argp[1];
-//#else
-//  void *args = __builtin_dwarf_cfa ();
-//#endif
 
   cif         = closure->cif;
   arg_area    = (void**) alloca (cif->nargs * sizeof (void*));  
@@ -353,10 +349,6 @@
 
 /* How to make a trampoline.  Derived from gcc/config/i386/i386.c. */
 
-/* MOV EDX, ESP is 0x8b 0xd4 */
-
-//#ifdef _MSC_VER
-
 #define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,BYTES) \
 { unsigned char *__tramp = (unsigned char*)(TRAMP); \
    unsigned int  __fun = (unsigned int)(FUN); \
@@ -365,26 +357,13 @@
    *(unsigned char*)  &__tramp[0] = 0xb9; \
    *(unsigned int*)   &__tramp[1] = __ctx; /* mov ecx, __ctx */ \
    *(unsigned char*)  &__tramp[5] = 0x8b; \
-   *(unsigned char*)  &__tramp[6] = 0xd4; \
+   *(unsigned char*)  &__tramp[6] = 0xd4; /* mov edx, esp */ \
    *(unsigned char*)  &__tramp[7] = 0xe8; \
    *(unsigned int*)   &__tramp[8] = __dis; /* call __fun  */ \
    *(unsigned char*)  &__tramp[12] = 0xC2; /* ret BYTES */ \
    *(unsigned short*) &__tramp[13] = BYTES; \
  }
 
-//#else
-//#define FFI_INIT_TRAMPOLINE(TRAMP,FUN,CTX,BYTES) \
-//({ unsigned char *__tramp = (unsigned char*)(TRAMP); \
-//   unsigned int  __fun = (unsigned int)(FUN); \
-//   unsigned int  __ctx = (unsigned int)(CTX); \
-//   unsigned int  __dis = __fun - ((unsigned int) __tramp + FFI_TRAMPOLINE_SIZE); \
-//   *(unsigned char*) &__tramp[0] = 0xb8; \
-//   *(unsigned int*)  &__tramp[1] = __ctx; /* movl __ctx, %eax */ \
-//   *(unsigned char *)  &__tramp[5] = 0xe9; \
-//   *(unsigned int*)  &__tramp[6] = __dis; /* jmp __fun  */ \
-// })
-//#endif
-
 /* the cif must already be prep'ed */
 
 ffi_status

Modified: stackless/trunk/Modules/_ctypes/libffi_msvc/fficonfig.h
==============================================================================
--- stackless/trunk/Modules/_ctypes/libffi_msvc/fficonfig.h	(original)
+++ stackless/trunk/Modules/_ctypes/libffi_msvc/fficonfig.h	Fri Jul 14 14:39:40 2006
@@ -3,8 +3,10 @@
 /* fficonfig.h.  Generated automatically by configure.  */
 /* fficonfig.h.in.  Generated automatically from configure.in by autoheader.  */
 
-/* Defines for MSVC */
+/* Define this for MSVC, but not for mingw32! */
+#ifdef _MSC_VER
 #define __attribute__(x) /* */
+#endif
 #define alloca _alloca
 
 /*----------------------------------------------------------------*/

Modified: stackless/trunk/Modules/_ctypes/libffi_msvc/ffitarget.h
==============================================================================
--- stackless/trunk/Modules/_ctypes/libffi_msvc/ffitarget.h	(original)
+++ stackless/trunk/Modules/_ctypes/libffi_msvc/ffitarget.h	Fri Jul 14 14:39:40 2006
@@ -71,11 +71,7 @@
 #define FFI_TRAMPOLINE_SIZE 24
 #define FFI_NATIVE_RAW_API 0
 #else
-#ifdef _MSC_VER
-# define FFI_TRAMPOLINE_SIZE 15
-#else
-# define FFI_TRAMPOLINE_SIZE 10
-#endif
+#define FFI_TRAMPOLINE_SIZE 15
 #define FFI_NATIVE_RAW_API 1	/* x86 has native raw api support */
 #endif
 

Modified: stackless/trunk/Modules/_sqlite/cursor.c
==============================================================================
--- stackless/trunk/Modules/_sqlite/cursor.c	(original)
+++ stackless/trunk/Modules/_sqlite/cursor.c	Fri Jul 14 14:39:40 2006
@@ -321,12 +321,13 @@
         }
 
         if (converter != Py_None) {
-            val_str = (const char*)sqlite3_column_text(self->statement->st, i);
+            nbytes = sqlite3_column_bytes(self->statement->st, i);
+            val_str = (const char*)sqlite3_column_blob(self->statement->st, i);
             if (!val_str) {
                 Py_INCREF(Py_None);
                 converted = Py_None;
             } else {
-                item = PyString_FromString(val_str);
+                item = PyString_FromStringAndSize(val_str, nbytes);
                 if (!item) {
                     return NULL;
                 }

Modified: stackless/trunk/Modules/_sqlite/module.h
==============================================================================
--- stackless/trunk/Modules/_sqlite/module.h	(original)
+++ stackless/trunk/Modules/_sqlite/module.h	Fri Jul 14 14:39:40 2006
@@ -25,7 +25,7 @@
 #define PYSQLITE_MODULE_H
 #include "Python.h"
 
-#define PYSQLITE_VERSION "2.3.1"
+#define PYSQLITE_VERSION "2.3.2"
 
 extern PyObject* Error;
 extern PyObject* Warning;

Modified: stackless/trunk/Modules/_ssl.c
==============================================================================
--- stackless/trunk/Modules/_ssl.c	(original)
+++ stackless/trunk/Modules/_ssl.c	Fri Jul 14 14:39:40 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: stackless/trunk/Modules/bz2module.c
==============================================================================
--- stackless/trunk/Modules/bz2module.c	(original)
+++ stackless/trunk/Modules/bz2module.c	Fri Jul 14 14:39:40 2006
@@ -1311,7 +1311,11 @@
 				break;
 
 			case 'U':
+#ifdef __VMS
+				self->f_univ_newline = 0;
+#else
 				self->f_univ_newline = 1;
+#endif
 				break;
 
 			default:

Modified: stackless/trunk/Modules/cPickle.c
==============================================================================
--- stackless/trunk/Modules/cPickle.c	(original)
+++ stackless/trunk/Modules/cPickle.c	Fri Jul 14 14:39:40 2006
@@ -3700,10 +3700,14 @@
 
   err:
 	{
-		PyObject *tp, *v, *tb;
+		PyObject *tp, *v, *tb, *tmp_value;
 
 		PyErr_Fetch(&tp, &v, &tb);
-		if ((r=PyTuple_Pack(3,v,cls,args))) {
+		tmp_value = v;
+		/* NULL occurs when there was a KeyboardInterrupt */
+		if (tmp_value == NULL)
+			tmp_value = Py_None;
+		if ((r = PyTuple_Pack(3, tmp_value, cls, args))) {
 			Py_XDECREF(v);
 			v=r;
 		}

Modified: stackless/trunk/Modules/cryptmodule.c
==============================================================================
--- stackless/trunk/Modules/cryptmodule.c	(original)
+++ stackless/trunk/Modules/cryptmodule.c	Fri Jul 14 14:39:40 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: stackless/trunk/Modules/dlmodule.c
==============================================================================
--- stackless/trunk/Modules/dlmodule.c	(original)
+++ stackless/trunk/Modules/dlmodule.c	Fri Jul 14 14:39:40 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: stackless/trunk/Modules/fpectlmodule.c
==============================================================================
--- stackless/trunk/Modules/fpectlmodule.c	(original)
+++ stackless/trunk/Modules/fpectlmodule.c	Fri Jul 14 14:39:40 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: stackless/trunk/Modules/getpath.c
==============================================================================
--- stackless/trunk/Modules/getpath.c	(original)
+++ stackless/trunk/Modules/getpath.c	Fri Jul 14 14:39:40 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: stackless/trunk/Modules/posixmodule.c
==============================================================================
--- stackless/trunk/Modules/posixmodule.c	(original)
+++ stackless/trunk/Modules/posixmodule.c	Fri Jul 14 14:39:40 2006
@@ -1402,7 +1402,7 @@
 		return PyBool_FromLong(0);
 	/* Access is possible if either write access wasn't requested, or
 	   the file isn't read-only. */
-	return PyBool_FromLong(!(mode & 2) || !(attr && FILE_ATTRIBUTE_READONLY));
+	return PyBool_FromLong(!(mode & 2) || !(attr & FILE_ATTRIBUTE_READONLY));
 #else
 	int res;
 	if (!PyArg_ParseTuple(args, "eti:access", 
@@ -7882,6 +7882,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 +8211,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: stackless/trunk/Modules/pyexpat.c
==============================================================================
--- stackless/trunk/Modules/pyexpat.c	(original)
+++ stackless/trunk/Modules/pyexpat.c	Fri Jul 14 14:39:40 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: stackless/trunk/Modules/selectmodule.c
==============================================================================
--- stackless/trunk/Modules/selectmodule.c	(original)
+++ stackless/trunk/Modules/selectmodule.c	Fri Jul 14 14:39:40 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: stackless/trunk/Modules/socketmodule.c
==============================================================================
--- stackless/trunk/Modules/socketmodule.c	(original)
+++ stackless/trunk/Modules/socketmodule.c	Fri Jul 14 14:39:40 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__)
@@ -386,6 +375,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 +411,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 +624,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 +672,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 +696,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 +704,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 +714,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 +1771,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) {
@@ -2498,9 +2546,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 +2553,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 +2569,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 +2599,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: stackless/trunk/Modules/timemodule.c
==============================================================================
--- stackless/trunk/Modules/timemodule.c	(original)
+++ stackless/trunk/Modules/timemodule.c	Fri Jul 14 14:39:40 2006
@@ -467,7 +467,7 @@
 			return ret;
 		}
 		free(outbuf);
-#if defined _MSC_VER && _MSC_VER >= 1400
+#if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
 		/* VisualStudio .NET 2005 does this properly */
 		if (buflen == 0 && errno == EINVAL) {
 			PyErr_SetString(PyExc_ValueError, "Invalid format string");

Modified: stackless/trunk/Objects/abstract.c
==============================================================================
--- stackless/trunk/Objects/abstract.c	(original)
+++ stackless/trunk/Objects/abstract.c	Fri Jul 14 14:39:40 2006
@@ -1799,17 +1799,8 @@
 
 	if ((call = func->ob_type->tp_call) != NULL) {
 		PyObject *result = NULL;
-		/* slot_tp_call() will be called and ends up calling
-		   PyObject_Call() if the object returned for __call__ has
-		   __call__ itself defined upon it.  This can be an infinite
-		   recursion if you set __call__ in a class to an instance of
-		   it. */
-		if (Py_EnterRecursiveCall(" in __call__")) {
-		    return NULL;
-		}
 		result = (STACKLESS_PROMOTE(func), (*call)(func, arg, kw));
 		STACKLESS_ASSERT();
-		Py_LeaveRecursiveCall();
 		if (result == NULL && !PyErr_Occurred())
 			PyErr_SetString(
 				PyExc_SystemError,

Modified: stackless/trunk/Objects/cellobject.c
==============================================================================
--- stackless/trunk/Objects/cellobject.c	(original)
+++ stackless/trunk/Objects/cellobject.c	Fri Jul 14 14:39:40 2006
@@ -8,6 +8,8 @@
 	PyCellObject *op;
 
 	op = (PyCellObject *)PyObject_GC_New(PyCellObject, &PyCell_Type);
+	if (op == NULL)
+		return NULL;
 	op->ob_ref = obj;
 	Py_XINCREF(obj);
 

Modified: stackless/trunk/Objects/descrobject.c
==============================================================================
--- stackless/trunk/Objects/descrobject.c	(original)
+++ stackless/trunk/Objects/descrobject.c	Fri Jul 14 14:39:40 2006
@@ -919,10 +919,12 @@
 static void
 wrapper_dealloc(wrapperobject *wp)
 {
-	_PyObject_GC_UNTRACK(wp);
+	PyObject_GC_UnTrack(wp);
+	Py_TRASHCAN_SAFE_BEGIN(wp)
 	Py_XDECREF(wp->descr);
 	Py_XDECREF(wp->self);
 	PyObject_GC_Del(wp);
+	Py_TRASHCAN_SAFE_END(wp)
 }
 
 static int

Modified: stackless/trunk/Objects/exceptions.c
==============================================================================
--- stackless/trunk/Objects/exceptions.c	(original)
+++ stackless/trunk/Objects/exceptions.c	Fri Jul 14 14:39:40 2006
@@ -1975,7 +1975,7 @@
     if (PyDict_SetItemString(bdict, # TYPE, PyExc_ ## TYPE)) \
         Py_FatalError("Module dictionary insertion problem.");
 
-#if defined _MSC_VER && _MSC_VER >= 1400
+#if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
 /* crt variable checking in VisualStudio .NET 2005 */
 #include <crtdbg.h>
 
@@ -2132,7 +2132,7 @@
 
     Py_DECREF(bltinmod);
 
-#if defined _MSC_VER && _MSC_VER >= 1400
+#if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
     /* Set CRT argument error handler */
     prevCrtHandler = _set_invalid_parameter_handler(InvalidParameterHandler);
     /* turn off assertions in debug mode */
@@ -2145,7 +2145,7 @@
 {
     Py_XDECREF(PyExc_MemoryErrorInst);
     PyExc_MemoryErrorInst = NULL;
-#if defined _MSC_VER && _MSC_VER >= 1400
+#if defined _MSC_VER && _MSC_VER >= 1400 && defined(__STDC_SECURE_LIB__)
     /* reset CRT error handling */
     _set_invalid_parameter_handler(prevCrtHandler);
     _CrtSetReportMode(_CRT_ASSERT, prevCrtReportMode);

Modified: stackless/trunk/Objects/fileobject.c
==============================================================================
--- stackless/trunk/Objects/fileobject.c	(original)
+++ stackless/trunk/Objects/fileobject.c	Fri Jul 14 14:39:40 2006
@@ -241,7 +241,7 @@
 	}
 
 	if (f->f_fp == NULL) {
-#if defined  _MSC_VER && _MSC_VER < 1400
+#if defined  _MSC_VER && (_MSC_VER < 1400 || !defined(__STDC_SECURE_LIB__))
 		/* MSVC 6 (Microsoft) leaves errno at 0 for bad mode strings,
 		 * across all Windows flavors.  When it sets EINVAL varies
 		 * across Windows flavors, the exact conditions aren't

Modified: stackless/trunk/Objects/typeobject.c
==============================================================================
--- stackless/trunk/Objects/typeobject.c	(original)
+++ stackless/trunk/Objects/typeobject.c	Fri Jul 14 14:39:40 2006
@@ -4665,9 +4665,19 @@
 
 	if (meth == NULL)
 		return NULL;
+
+	/* PyObject_Call() will end up calling slot_tp_call() again if
+	   the object returned for __call__ has __call__ itself defined
+	   upon it.  This can be an infinite recursion if you set
+	   __call__ in a class to an instance of it. */
+	if (Py_EnterRecursiveCall(" in __call__")) {
+		Py_DECREF(meth);
+		return NULL;
+	}
 	STACKLESS_PROMOTE_ALL();
 	res = PyObject_Call(meth, args, kwds);
 	STACKLESS_ASSERT();
+	Py_LeaveRecursiveCall();
 	Py_DECREF(meth);
 	return res;
 }

Modified: stackless/trunk/PCbuild/readme.txt
==============================================================================
--- stackless/trunk/PCbuild/readme.txt	(original)
+++ stackless/trunk/PCbuild/readme.txt	Fri Jul 14 14:39:40 2006
@@ -280,12 +280,21 @@
 Toolkit Compiler. This provides a way of building Python using freely
 available software.
 
+Note that Microsoft have withdrawn the free MS Toolkit Compiler, so this can
+no longer be considered a supported option. The instructions are still
+correct, but you need to already have a copy of the compiler in order to use
+them. Microsoft now supply Visual C++ 2005 Express Edition for free, but this
+is NOT compatible with Visual C++ 7.1 (it uses a different C runtime), and so
+cannot be used to build a version of Python compatible with the standard
+python.org build. If you are interested in using Visual C++ 2005 Express
+Edition, however, you should look at the PCBuild8 directory.
+
 Requirements
 
     To build Python, the following tools are required:
 
     * The Visual C++ Toolkit Compiler
-        from http://msdn.microsoft.com/visualc/vctoolkit2003/
+        no longer available for download - see above
     * A recent Platform SDK
         from http://www.microsoft.com/downloads/details.aspx?FamilyID=484269e2-3b89-47e3-8eb7-1f2be6d7123a
     * The .NET 1.1 SDK

Modified: stackless/trunk/Python/ast.c
==============================================================================
--- stackless/trunk/Python/ast.c	(original)
+++ stackless/trunk/Python/ast.c	Fri Jul 14 14:39:40 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.
     */
@@ -1484,6 +1484,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 +1713,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:
@@ -1901,7 +1934,7 @@
 
         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 "
@@ -1923,6 +1956,7 @@
                           "assignment");
                 return NULL;
         }
+	set_context(expr1, Store, ch);
 
 	ch = CHILD(n, 2);
 	if (TYPE(ch) == testlist)
@@ -2142,7 +2176,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 +2192,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;

Modified: stackless/trunk/Python/ceval.c
==============================================================================
--- stackless/trunk/Python/ceval.c	(original)
+++ stackless/trunk/Python/ceval.c	Fri Jul 14 14:39:40 2006
@@ -2846,7 +2846,7 @@
 	if (tstate->frame->f_back != f)
 		return retval;
 	STACKLESS_UNPACK(retval);
-	retval = tstate->frame->f_execute(tstate->frame, throwflag, retval);
+	retval = tstate->frame->f_execute(tstate->frame, 0, retval);
 	if (tstate->frame != f)
 		return retval;
 	if (STACKLESS_UNWINDING(retval))

Modified: stackless/trunk/Python/codecs.c
==============================================================================
--- stackless/trunk/Python/codecs.c	(original)
+++ stackless/trunk/Python/codecs.c	Fri Jul 14 14:39:40 2006
@@ -249,14 +249,17 @@
 			       const char *errors,
 			       const int index)
 {
-    PyObject *codecs, *streamcodec;
+    PyObject *codecs, *streamcodec, *codeccls;
 
     codecs = _PyCodec_Lookup(encoding);
     if (codecs == NULL)
 	return NULL;
 
-    streamcodec = PyEval_CallFunction(
-	PyTuple_GET_ITEM(codecs, index), "Os", stream, errors);
+    codeccls = PyTuple_GET_ITEM(codecs, index);
+    if (errors != NULL)
+	streamcodec = PyObject_CallFunction(codeccls, "Os", stream, errors);
+    else
+	streamcodec = PyObject_CallFunction(codeccls, "O", stream);
     Py_DECREF(codecs);
     return streamcodec;
 }

Modified: stackless/trunk/Python/compile.c
==============================================================================
--- stackless/trunk/Python/compile.c	(original)
+++ stackless/trunk/Python/compile.c	Fri Jul 14 14:39:40 2006
@@ -1776,7 +1776,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: 
@@ -3688,7 +3689,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);
@@ -4445,6 +4447,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: stackless/trunk/Python/import.c
==============================================================================
--- stackless/trunk/Python/import.c	(original)
+++ stackless/trunk/Python/import.c	Fri Jul 14 14:39:40 2006
@@ -1237,8 +1237,10 @@
 
 			importer = get_path_importer(path_importer_cache,
 						     path_hooks, v);
-			if (importer == NULL)
+			if (importer == NULL) {
+				Py_XDECREF(copy);
 				return NULL;
+			}
 			/* Note: importer is a borrowed reference */
 			if (importer == Py_False) {
 				/* Cached as not being a valid dir. */
@@ -1273,6 +1275,7 @@
 				loader = PyObject_CallMethod(importer,
 							     "find_module",
 							     "s", fullname);
+				Py_XDECREF(copy);
 				if (loader == NULL)
 					return NULL;  /* error */
 				if (loader != Py_None) {
@@ -1281,7 +1284,6 @@
 					return &importhookdescr;
 				}
 				Py_DECREF(loader);
-				Py_XDECREF(copy);
 				continue;
 			}
 		}

Modified: stackless/trunk/Python/mystrtoul.c
==============================================================================
--- stackless/trunk/Python/mystrtoul.c	(original)
+++ stackless/trunk/Python/mystrtoul.c	Fri Jul 14 14:39:40 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

Modified: stackless/trunk/Python/pystate.c
==============================================================================
--- stackless/trunk/Python/pystate.c	(original)
+++ stackless/trunk/Python/pystate.c	Fri Jul 14 14:39:40 2006
@@ -463,15 +463,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:
 
@@ -569,6 +569,54 @@
 		PyEval_SaveThread();
 }
 
+/* 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;
+}
+
 #ifdef __cplusplus
 }
 #endif

Modified: stackless/trunk/Python/pystrtod.c
==============================================================================
--- stackless/trunk/Python/pystrtod.c	(original)
+++ stackless/trunk/Python/pystrtod.c	Fri Jul 14 14:39:40 2006
@@ -90,6 +90,13 @@
 				p++;
 			end = p;
 		}
+		else if (strncmp(p, decimal_point, decimal_point_len) == 0)
+		{
+			/* Python bug #1417699 */
+			*endptr = (char*)nptr;
+			errno = EINVAL;
+			return val;
+		}
 		/* For the other cases, we need not convert the decimal point */
 	}
 

Modified: stackless/trunk/Python/sysmodule.c
==============================================================================
--- stackless/trunk/Python/sysmodule.c	(original)
+++ stackless/trunk/Python/sysmodule.c	Fri Jul 14 14:39:40 2006
@@ -664,6 +664,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\
@@ -726,6 +741,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},

Modified: stackless/trunk/README
==============================================================================
--- stackless/trunk/README	(original)
+++ stackless/trunk/README	Fri Jul 14 14:39:40 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.

Modified: stackless/trunk/Stackless/core/stacklesseval.c
==============================================================================
--- stackless/trunk/Stackless/core/stacklesseval.c	(original)
+++ stackless/trunk/Stackless/core/stacklesseval.c	Fri Jul 14 14:39:40 2006
@@ -614,7 +614,6 @@
 	while (1) {
 
 		retval = f->f_execute(f, exc, retval);
-		/* exc = 0;  Maybe we should be unpacking this. */
 		f = ts->frame;
 		if (STACKLESS_UNWINDING(retval))
 			STACKLESS_UNPACK(retval);

Modified: stackless/trunk/Stackless/module/scheduling.c
==============================================================================
--- stackless/trunk/Stackless/module/scheduling.c	(original)
+++ stackless/trunk/Stackless/module/scheduling.c	Fri Jul 14 14:39:40 2006
@@ -997,10 +997,8 @@
 		ts->st.nesting_level = 0;
 	}
 
-	/* update what's not yet updated 
-	This has been removed because PyObject_Call now adds a
-	recursion level, which causes the value here to differ.
-	assert(ts->recursion_depth == 0);*/
+	/* update what's not yet updated */
+	assert(ts->recursion_depth == 0);
 	prev->recursion_depth = 0;
 	assert(ts->frame == NULL);
 	prev->f.frame = NULL;

Modified: stackless/trunk/Tools/msi/msi.py
==============================================================================
--- stackless/trunk/Tools/msi/msi.py	(original)
+++ stackless/trunk/Tools/msi/msi.py	Fri Jul 14 14:39:40 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: stackless/trunk/configure
==============================================================================
--- stackless/trunk/configure	(original)
+++ stackless/trunk/configure	Fri Jul 14 14:39:40 2006
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.in Revision: .
+# From configure.in Revision: 47023 .
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.59 for python 2.5.
 #
@@ -722,13 +722,13 @@
   	  /^X\(\/\).*/{ s//\1/; q; }
   	  s/.*/./; q'`
   srcdir=$ac_confdir
-  if test ! -r "$srcdir/$ac_unique_file"; then
+  if test ! -r $srcdir/$ac_unique_file; then
     srcdir=..
   fi
 else
   ac_srcdir_defaulted=no
 fi
-if test ! -r "$srcdir/$ac_unique_file"; then
+if test ! -r $srcdir/$ac_unique_file; then
   if test "$ac_srcdir_defaulted" = yes; then
     { echo "$as_me: error: cannot find sources ($ac_unique_file) in $ac_confdir or .." >&2
    { (exit 1); exit 1; }; }
@@ -737,7 +737,7 @@
    { (exit 1); exit 1; }; }
   fi
 fi
-(cd $srcdir && test -r "./$ac_unique_file") 2>/dev/null ||
+(cd $srcdir && test -r ./$ac_unique_file) 2>/dev/null ||
   { echo "$as_me: error: sources are in $srcdir, but \`cd $srcdir' does not work" >&2
    { (exit 1); exit 1; }; }
 srcdir=`echo "$srcdir" | sed 's%\([^\\/]\)[\\/]*$%\1%'`
@@ -14901,6 +14901,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
@@ -14973,6 +14982,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

Modified: stackless/trunk/configure.in
==============================================================================
--- stackless/trunk/configure.in	(original)
+++ stackless/trunk/configure.in	Fri Jul 14 14:39:40 2006
@@ -2363,8 +2363,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" 

Modified: stackless/trunk/setup.py
==============================================================================
--- stackless/trunk/setup.py	(original)
+++ stackless/trunk/setup.py	Fri Jul 14 14:39:40 2006
@@ -638,6 +638,24 @@
             db_inc_paths.append('/pkg/db-3.%d/include' % x)
             db_inc_paths.append('/opt/db-3.%d/include' % x)
 
+        # Add some common subdirectories for Sleepycat DB to the list,
+        # based on the standard include directories. This way DB3/4 gets
+        # picked up when it is installed in a non-standard prefix and
+        # the user has added that prefix into inc_dirs.
+        std_variants = []
+        for dn in inc_dirs:
+            std_variants.append(os.path.join(dn, 'db3'))
+            std_variants.append(os.path.join(dn, 'db4'))
+            for x in (0,1,2,3,4):
+                std_variants.append(os.path.join(dn, "db4%d"%x))
+                std_variants.append(os.path.join(dn, "db4.%d"%x))
+            for x in (2,3):
+                std_variants.append(os.path.join(dn, "db3%d"%x))
+                std_variants.append(os.path.join(dn, "db3.%d"%x))
+
+        db_inc_paths = std_variants + db_inc_paths
+
+
         db_ver_inc_map = {}
 
         class db_found(Exception): pass
@@ -940,13 +958,23 @@
                     break
             if version >= version_req:
                 if (self.compiler.find_library_file(lib_dirs, 'z')):
+                    if sys.platform == "darwin":
+                        zlib_extra_link_args = ('-Wl,-search_paths_first',)
+                    else:
+                        zlib_extra_link_args = ()
                     exts.append( Extension('zlib', ['zlibmodule.c'],
-                                           libraries = ['z']) )
+                                           libraries = ['z'],
+                                           extra_link_args = zlib_extra_link_args))
 
         # Gustavo Niemeyer's bz2 module.
         if (self.compiler.find_library_file(lib_dirs, 'bz2')):
+            if sys.platform == "darwin":
+                bz2_extra_link_args = ('-Wl,-search_paths_first',)
+            else:
+                bz2_extra_link_args = ()
             exts.append( Extension('bz2', ['bz2module.c'],
-                                   libraries = ['bz2']) )
+                                   libraries = ['bz2'],
+                                   extra_link_args = bz2_extra_link_args) )
 
         # Interface to the Expat XML parser
         #

_______________________________________________
Stackless-checkins mailing list
Stackless-checkins at stackless.com
http://www.stackless.com/mailman/listinfo/stackless-checkins



More information about the Stackless-checkins mailing list