Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
number of tests, all because of the codecs/_multibytecodecs issue described
here (it's not a Py3K issue, just something Py3K discovers):
http://mail.python.org/pipermail/python-dev/2006-April/064051.html

Hye-Shik Chang promised to look for a fix, so no need to fix it here. The
tests that are expected to break are:

test_codecencodings_cn
test_codecencodings_hk
test_codecencodings_jp
test_codecencodings_kr
test_codecencodings_tw
test_codecs
test_multibytecodec

This merge fixes an actual test failure (test_weakref) in this branch,
though, so I believe merging is the right thing to do anyway.
diff --git a/Doc/api/concrete.tex b/Doc/api/concrete.tex
index 5521b80..1982bae 100644
--- a/Doc/api/concrete.tex
+++ b/Doc/api/concrete.tex
@@ -156,7 +156,7 @@
   Create a new integer object with a value of \var{ival}.
 
   The current implementation keeps an array of integer objects for all
-  integers between \code{-1} and \code{100}, when you create an int in
+  integers between \code{-5} and \code{256}, when you create an int in
   that range you actually just get back a reference to the existing
   object. So it should be possible to change the value of \code{1}.  I
   suspect the behaviour of Python in this case is undefined. :-)
@@ -333,7 +333,9 @@
   The pointer value can be retrieved from the resulting value using
   \cfunction{PyLong_AsVoidPtr()}.
   \versionadded{1.5.2}
-\end{cfuncdesc}
+  \versionchanged[If the integer is larger than LONG_MAX,
+  a positive long integer is returned]{2.5}
+ \end{cfuncdesc}
 
 \begin{cfuncdesc}{long}{PyLong_AsLong}{PyObject *pylong}
   Return a C \ctype{long} representation of the contents of
@@ -394,6 +396,8 @@
   produce a usable \ctype{void} pointer for values created with
   \cfunction{PyLong_FromVoidPtr()}.
   \versionadded{1.5.2}
+  \versionchanged[For values outside 0..LONG_MAX, both signed and
+  unsigned integers are acccepted]{2.5}
 \end{cfuncdesc}
 
 
@@ -1803,8 +1807,9 @@
 
 \begin{cfuncdesc}{PyObject*}{PyList_GetItem}{PyObject *list, Py_ssize_t index}
   Return the object at position \var{pos} in the list pointed to by
-  \var{p}.  If \var{pos} is out of bounds, return \NULL{} and set an
-  \exception{IndexError} exception.
+  \var{p}.  The position must be positive, indexing from the end of the
+  list is not supported.  If \var{pos} is out of bounds, return \NULL{}
+  and set an \exception{IndexError} exception.
 \end{cfuncdesc}
 
 \begin{cfuncdesc}{PyObject*}{PyList_GET_ITEM}{PyObject *list, Py_ssize_t i}
@@ -2264,8 +2269,8 @@
 \begin{cfuncdesc}{PyObject*}{PyFunction_New}{PyObject *code,
                                              PyObject *globals}
   Return a new function object associated with the code object
-  \var{code}. \var{globals} must be a dictionary with the the global
-  varaibles accessible to the function.
+  \var{code}. \var{globals} must be a dictionary with the global
+  variables accessible to the function.
 
   The function's docstring, name and \var{__module__} are retrieved
   from the code object, the argument defaults and closure are set to
@@ -2811,6 +2816,7 @@
 
 \begin{cfuncdesc}{PyObject*}{PyGen_New}{PyFrameObject *frame}
   Create and return a new generator object based on the \var{frame} object.
+  A reference to \var{frame} is stolen by this function.
   The parameter must not be \NULL{}.
 \end{cfuncdesc}
 
@@ -3025,9 +3031,7 @@
 \cfunction{PyNumber_Or()}, \cfunction{PyNumber_Xor()},
 \cfunction{PyNumber_InPlaceAdd()}, \cfunction{PyNumber_InPlaceSubtract()},
 \cfunction{PyNumber_InPlaceOr()}, and \cfunction{PyNumber_InPlaceXor()}).
-Note, \cfunction{PyNumber_InPlaceSubtract()} is also useful clearing
-clearing a set (\code{s-=s}).                         
-                      
+
 \begin{ctypedesc}{PySetObject}
   This subtype of \ctype{PyObject} is used to hold the internal data for
   both \class{set} and \class{frozenset} objects.  It is like a
@@ -3111,7 +3115,6 @@
   \class{frozenset}, or an instance of a subtype.                         
 \end{cfuncdesc}
 
-
 The following functions are available for instances of \class{set} or
 its subtypes but not for instances of \class{frozenset} or its subtypes.
 
@@ -3142,4 +3145,6 @@
   of \class{set} or its subtype.                        
 \end{cfuncdesc}
 
-
+\begin{cfuncdesc}{int}{PySet_Clear}{PyObject *set}
+  Empty an existing set of all elements.
+\end{cfuncdesc}
diff --git a/Doc/api/intro.tex b/Doc/api/intro.tex
index 608d562..96f18ec 100644
--- a/Doc/api/intro.tex
+++ b/Doc/api/intro.tex
@@ -569,8 +569,11 @@
 Sometimes, it is desirable to ``uninitialize'' Python.  For instance, 
 the application may want to start over (make another call to 
 \cfunction{Py_Initialize()}) or the application is simply done with its 
-use of Python and wants to free all memory allocated by Python.  This
+use of Python and wants to free memory allocated by Python.  This
 can be accomplished by calling \cfunction{Py_Finalize()}.  The function
 \cfunction{Py_IsInitialized()}\ttindex{Py_IsInitialized()} returns
 true if Python is currently in the initialized state.  More
 information about these functions is given in a later chapter.
+Notice that \cfunction{Py_Finalize} does \emph{not} free all memory
+allocated by the Python interpreter, e.g. memory allocated by extension
+modules currently cannot be released.
diff --git a/Doc/api/memory.tex b/Doc/api/memory.tex
index 3dbe9a5..4bc2c7a 100644
--- a/Doc/api/memory.tex
+++ b/Doc/api/memory.tex
@@ -195,9 +195,7 @@
 In addition to the functions aimed at handling raw memory blocks from
 the Python heap, objects in Python are allocated and released with
 \cfunction{PyObject_New()}, \cfunction{PyObject_NewVar()} and
-\cfunction{PyObject_Del()}, or with their corresponding macros
-\cfunction{PyObject_NEW()}, \cfunction{PyObject_NEW_VAR()} and
-\cfunction{PyObject_DEL()}.
+\cfunction{PyObject_Del()}.
 
 These will be explained in the next chapter on defining and
 implementing new object types in C.
diff --git a/Doc/api/newtypes.tex b/Doc/api/newtypes.tex
index b7e25b9..2d758b0 100644
--- a/Doc/api/newtypes.tex
+++ b/Doc/api/newtypes.tex
@@ -62,23 +62,6 @@
   after this call as the memory is no longer a valid Python object.
 \end{cfuncdesc}
 
-\begin{cfuncdesc}{\var{TYPE}*}{PyObject_NEW}{TYPE, PyTypeObject *type}
-  Macro version of \cfunction{PyObject_New()}, to gain performance at
-  the expense of safety.  This does not check \var{type} for a \NULL{}
-  value.
-\end{cfuncdesc}
-
-\begin{cfuncdesc}{\var{TYPE}*}{PyObject_NEW_VAR}{TYPE, PyTypeObject *type,
-                                                Py_ssize_t size}
-  Macro version of \cfunction{PyObject_NewVar()}, to gain performance
-  at the expense of safety.  This does not check \var{type} for a
-  \NULL{} value.
-\end{cfuncdesc}
-
-\begin{cfuncdesc}{void}{PyObject_DEL}{PyObject *op}
-  Macro version of \cfunction{PyObject_Del()}.
-\end{cfuncdesc}
-
 \begin{cfuncdesc}{PyObject*}{Py_InitModule}{char *name,
                                             PyMethodDef *methods}
   Create a new module object based on a name and table of functions,
diff --git a/Doc/api/refcounts.dat b/Doc/api/refcounts.dat
index f3bd32e..7bba011 100644
--- a/Doc/api/refcounts.dat
+++ b/Doc/api/refcounts.dat
@@ -31,6 +31,9 @@
 # The parameter names are as they appear in the API manual, not the source
 # code. 
 
+PyBool_FromLong:PyObject*::+1:
+PyBool_FromLong:long:v:0:
+
 PyBuffer_FromObject:PyObject*::+1:
 PyBuffer_FromObject:PyObject*:base:+1:
 PyBuffer_FromObject:int:offset::
@@ -110,6 +113,35 @@
 PyComplex_RealAsDouble:double:::
 PyComplex_RealAsDouble:PyObject*:op:0:
 
+PyDate_FromDate:PyObject*::+1:
+PyDate_FromDate:int:year::
+PyDate_FromDate:int:month::
+PyDate_FromDate:int:day::
+
+PyDate_FromTimestamp:PyObject*::+1:
+PyDate_FromTimestamp:PyObject*:args:0:
+
+PyDateTime_FromDateAndTime:PyObject*::+1:
+PyDateTime_FromDateAndTime:int:year::
+PyDateTime_FromDateAndTime:int:month::
+PyDateTime_FromDateAndTime:int:day::
+PyDateTime_FromDateAndTime:int:hour::
+PyDateTime_FromDateAndTime:int:minute::
+PyDateTime_FromDateAndTime:int:second::
+PyDateTime_FromDateAndTime:int:usecond::
+
+PyDateTime_FromTimestamp:PyObject*::+1:
+PyDateTime_FromTimestamp:PyObject*:args:0:
+
+PyDelta_FromDSU:PyObject*::+1:
+PyDelta_FromDSU:int:days::
+PyDelta_FromDSU:int:seconds::
+PyDelta_FromDSU:int:useconds::
+
+PyDescr_NewClassMethod:PyObject*::+1:
+PyDescr_NewClassMethod:PyTypeObject*:type::
+PyDescr_NewClassMethod:PyMethodDef*:method::
+
 PyDescr_NewGetSet:PyObject*::+1:
 PyDescr_NewGetSet:PyTypeObject*:type::
 PyDescr_NewGetSet:PyGetSetDef*:getset::
@@ -226,6 +258,15 @@
 PyErr_Restore:PyObject*:value:-1:
 PyErr_Restore:PyObject*:traceback:-1:
 
+PyErr_SetExcFromWindowsErr:PyObject*::null:
+PyErr_SetExcFromWindowsErr:PyObject*:type:0:
+PyErr_SetExcFromWindowsErr:int:ierr::
+
+PyErr_SetExcFromWindowsErrWithFilename:PyObject*::null:
+PyErr_SetExcFromWindowsErrWithFilename:PyObject*:type:0:
+PyErr_SetExcFromWindowsErrWithFilename:int:ierr::
+PyErr_SetExcFromWindowsErrWithFilename:char*:filename::
+
 PyErr_SetFromErrno:PyObject*::null:
 PyErr_SetFromErrno:PyObject*:type:0:
 
@@ -337,6 +378,13 @@
 PyFloat_FromDouble:PyObject*::+1:
 PyFloat_FromDouble:double:v::
 
+PyFloat_FromString:PyObject*::+1:
+PyFloat_FromString:PyObject*:str:0:
+PyFloat_FromString:char**:pend:0:ignored
+
+PyFrozenSet_New:PyObject*::+1:
+PyFrozenSet_New:PyObject*:iterable:0:
+
 PyFunction_GetClosure:PyObject*::0:
 PyFunction_GetClosure:PyObject*:op:0:
 
@@ -364,6 +412,9 @@
 PyFunction_SetDefaults:PyObject*:op:0:
 PyFunction_SetDefaults:PyObject*:defaults:+1:
 
+PyGen_New:PyObject*::+1:
+PyGen_New:PyFrameObject*:frame:0:
+
 Py_InitModule:PyObject*::0:
 Py_InitModule:char*:name::
 Py_InitModule:PyMethodDef[]:methods::
@@ -432,6 +483,14 @@
 PyInt_FromLong:PyObject*::+1:
 PyInt_FromLong:long:ival::
 
+PyInt_FromString:PyObject*::+1:
+PyInt_FromString:char*:str:0:
+PyInt_FromString:char**:pend:0:
+PyInt_FromString:int:base:0:
+
+PyInt_FromSsize_t:PyObject*::+1:
+PyInt_FromSsize_t:Py_ssize_t:ival::
+
 PyInt_GetMax:long:::
 
 PyInterpreterState_Clear:void:::
@@ -939,6 +998,31 @@
 PyRun_File:PyObject*:globals:0:
 PyRun_File:PyObject*:locals:0:
 
+PyRun_FileEx:PyObject*::+1:??? -- same as eval_code2()
+PyRun_FileEx:FILE*:fp::
+PyRun_FileEx:char*:filename::
+PyRun_FileEx:int:start::
+PyRun_FileEx:PyObject*:globals:0:
+PyRun_FileEx:PyObject*:locals:0:
+PyRun_FileEx:int:closeit::
+
+PyRun_FileFlags:PyObject*::+1:??? -- same as eval_code2()
+PyRun_FileFlags:FILE*:fp::
+PyRun_FileFlags:char*:filename::
+PyRun_FileFlags:int:start::
+PyRun_FileFlags:PyObject*:globals:0:
+PyRun_FileFlags:PyObject*:locals:0:
+PyRun_FileFlags:PyCompilerFlags*:flags::
+
+PyRun_FileExFlags:PyObject*::+1:??? -- same as eval_code2()
+PyRun_FileExFlags:FILE*:fp::
+PyRun_FileExFlags:char*:filename::
+PyRun_FileExFlags:int:start::
+PyRun_FileExFlags:PyObject*:globals:0:
+PyRun_FileExFlags:PyObject*:locals:0:
+PyRun_FileExFlags:int:closeit::
+PyRun_FileExFlags:PyCompilerFlags*:flags::
+
 PyRun_InteractiveLoop:int:::
 PyRun_InteractiveLoop:FILE*:fp::
 PyRun_InteractiveLoop:char*:filename::
@@ -960,6 +1044,13 @@
 PyRun_String:PyObject*:globals:0:
 PyRun_String:PyObject*:locals:0:
 
+PyRun_StringFlags:PyObject*::+1:??? -- same as eval_code2()
+PyRun_StringFlags:char*:str::
+PyRun_StringFlags:int:start::
+PyRun_StringFlags:PyObject*:globals:0:
+PyRun_StringFlags:PyObject*:locals:0:
+PyRun_StringFlags:PyCompilerFlags*:flags::
+
 PySeqIter_New:PyObject*::+1:
 PySeqIter_New:PyObject*:seq::
 
@@ -1053,6 +1144,9 @@
 PySet_Discard:PyObject*:set:0:
 PySet_Discard:PyObject*:key:-1:no effect if key not found
 
+PySet_New:PyObject*::+1:
+PySet_New:PyObject*:iterable:0:
+
 PySet_Pop:PyObject*::0:or returns NULL and raises KeyError if set is empty
 PySet_Pop:PyObject*:set:0:
 
@@ -1167,6 +1261,12 @@
 PyThreadState_Swap:PyThreadState*:::
 PyThreadState_Swap:PyThreadState*:tstate::
 
+PyTime_FromTime:PyObject*::+1:
+PyTime_FromTime:int:hour::
+PyTime_FromTime:int:minute::
+PyTime_FromTime:int:second::
+PyTime_FromTime:int:usecond::
+
 PyTuple_Check:int:::
 PyTuple_Check:PyObject*:p:0:
 
@@ -1186,6 +1286,10 @@
 PyTuple_New:PyObject*::+1:
 PyTuple_New:int:len::
 
+PyTuple_Pack:PyObject*::+1:
+PyTuple_Pack:int:len::
+PyTuple_Pack:PyObject*:...:0:
+
 PyTuple_SET_ITEM:void:::
 PyTuple_SET_ITEM:PyTupleObject*:p:0:
 PyTuple_SET_ITEM:int:pos::
@@ -1298,6 +1402,19 @@
 PyUnicode_Decode:const char*:encoding::
 PyUnicode_Decode:const char*:errors::
 
+PyUnicode_DecodeUTF16Stateful:PyObject*::+1:
+PyUnicode_DecodeUTF16Stateful:const char*:s::
+PyUnicode_DecodeUTF16Stateful:int:size::
+PyUnicode_DecodeUTF16Stateful:const char*:errors::
+PyUnicode_DecodeUTF16Stateful:int*:byteorder::
+PyUnicode_DecodeUTF16Stateful:int*:consumed::
+
+PyUnicode_DecodeUTF8Stateful:PyObject*::+1:
+PyUnicode_DecodeUTF8Stateful:const char*:s::
+PyUnicode_DecodeUTF8Stateful:int:size::
+PyUnicode_DecodeUTF8Stateful:const char*:errors::
+PyUnicode_DecodeUTF8Stateful:int*:consumed::
+
 PyUnicode_Encode:PyObject*::+1:
 PyUnicode_Encode:const Py_UNICODE*:s::
 PyUnicode_Encode:int:size::
@@ -1513,6 +1630,12 @@
 Py_CompileString:char*:filename::
 Py_CompileString:int:start::
 
+Py_CompileStringFlags:PyObject*::+1:
+Py_CompileStringFlags:char*:str::
+Py_CompileStringFlags:char*:filename::
+Py_CompileStringFlags:int:start::
+Py_CompileStringFlags:PyCompilerFlags*:flags::
+
 Py_DECREF:void:::
 Py_DECREF:PyObject*:o:-1: