SF patch 568629 by Oren Tirosh: types made callable.

These built-in functions are replaced by their (now callable) type:

    slice()
    buffer()

and these types can also be called (but have no built-in named
function named after them)

    classobj (type name used to be "class")
    code
    function
    instance
    instancemethod (type name used to be "instance method")

The module "new" has been replaced with a small backward compatibility
placeholder in Python.

A large portion of the patch simply removes the new module from
various platform-specific build recipes.  The following binary Mac
project files still have references to it:

    Mac/Build/PythonCore.mcp
    Mac/Build/PythonStandSmall.mcp
    Mac/Build/PythonStandalone.mcp

[I've tweaked the code layout and the doc strings here and there, and
added a comment to types.py about StringTypes vs. basestring.  --Guido]
diff --git a/Objects/bufferobject.c b/Objects/bufferobject.c
index 51b9ef9..031c000 100644
--- a/Objects/bufferobject.c
+++ b/Objects/bufferobject.c
@@ -155,6 +155,27 @@
 
 /* Methods */
 
+static PyObject *
+buffer_new(PyTypeObject *type, PyObject *args, PyObject *kw)
+{
+	PyObject *ob;
+	int offset = 0;
+	int size = Py_END_OF_BUFFER;
+
+	if ( !PyArg_ParseTuple(args, "O|ii:buffer", &ob, &offset, &size) )
+	    return NULL;
+	return PyBuffer_FromObject(ob, offset, size);
+}
+
+PyDoc_STRVAR(buffer_doc,
+"buffer(object [, offset[, size]])\n\
+\n\
+Create a new buffer object which references the given object.\n\
+The buffer will reference a slice of the target object from the\n\
+start of the object (or at the specified offset). The slice will\n\
+extend to the end of the target object (or with the specified size).");
+
+
 static void
 buffer_dealloc(PyBufferObject *self)
 {
@@ -539,5 +560,22 @@
 	0,					/* tp_setattro */
 	&buffer_as_buffer,			/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT,			/* tp_flags */
-	0,					/* tp_doc */
+	buffer_doc,				/* tp_doc */
+	0,					/* tp_traverse */
+	0,					/* tp_clear */
+	0,					/* tp_richcompare */
+	0,					/* tp_weaklistoffset */
+	0,					/* tp_iter */
+	0,					/* tp_iternext */
+	0,					/* tp_methods */	
+	0,					/* tp_members */
+	0,					/* tp_getset */
+	0,					/* tp_base */
+	0,					/* tp_dict */
+	0,					/* tp_descr_get */
+	0,					/* tp_descr_set */
+	0,					/* tp_dictoffset */
+	0,					/* tp_init */
+	0,					/* tp_alloc */
+	buffer_new,				/* tp_new */
 };
diff --git a/Objects/classobject.c b/Objects/classobject.c
index 1033ab6..979c967 100644
--- a/Objects/classobject.c
+++ b/Objects/classobject.c
@@ -149,6 +149,27 @@
 	return ((PyMethodObject *)im)->im_class;
 }
 
+PyDoc_STRVAR(class_doc,
+"classobj(name, bases, dict)\n\
+\n\
+Create a class object.  The name must be a string; the second argument\n\
+a tuple of classes, and the third a dictionary.");
+
+static PyObject *
+new_class(PyObject* unused, PyObject* args)
+{
+	PyObject *name;
+	PyObject *classes;
+	PyObject *dict;
+  
+	if (!PyArg_ParseTuple(args, "SO!O!:class",
+			      &name,
+			      &PyTuple_Type, &classes,
+			      &PyDict_Type, &dict))
+		return NULL;
+	return PyClass_New(classes, dict, name);
+}
+
 static PyObject *
 class_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
@@ -435,7 +456,7 @@
 PyTypeObject PyClass_Type = {
 	PyObject_HEAD_INIT(&PyType_Type)
 	0,
-	"class",
+	"classobj",
 	sizeof(PyClassObject),
 	0,
 	(destructor)class_dealloc,		/* tp_dealloc */
@@ -454,7 +475,7 @@
 	(setattrofunc)class_setattr,		/* tp_setattro */
 	0,					/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
-	0,					/* tp_doc */
+	class_doc,				/* tp_doc */
 	(traverseproc)class_traverse,		/* tp_traverse */
  	0,					/* tp_clear */
 	0,					/* tp_richcompare */
@@ -575,6 +596,34 @@
 
 /* Instance methods */
 
+PyDoc_STRVAR(instance_doc,
+"instance(class[, dict])\n\
+\n\
+Create an instance without calling its __init__() method.\n\
+The class must be a classic class.\n\
+If present, dict must be a dictionary or None.");
+
+static PyObject *
+instance_new(PyTypeObject* type, PyObject* args, PyObject *kw)
+{
+	PyObject *klass;
+	PyObject *dict = Py_None;
+
+	if (!PyArg_ParseTuple(args, "O!|O:instance",
+			      &PyClass_Type, &klass, &dict))
+		return NULL;
+
+	if (dict == Py_None)
+		dict = NULL;
+	else if (!PyDict_Check(dict)) {
+		PyErr_SetString(PyExc_TypeError,
+		      "instance() second arg must be dictionary or None");
+		return NULL;
+	}
+	return PyInstance_NewRaw(klass, dict);
+}
+
+
 static void
 instance_dealloc(register PyInstanceObject *inst)
 {
@@ -2014,13 +2063,24 @@
 	(setattrofunc)instance_setattr,		/* tp_setattro */
 	0,					/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES,/*tp_flags*/
-	0,					/* tp_doc */
+	instance_doc,				/* tp_doc */
 	(traverseproc)instance_traverse,	/* tp_traverse */
 	0,					/* tp_clear */
 	instance_richcompare,			/* tp_richcompare */
  	offsetof(PyInstanceObject, in_weakreflist), /* tp_weaklistoffset */
 	(getiterfunc)instance_getiter,		/* tp_iter */
 	(iternextfunc)instance_iternext,	/* tp_iternext */
+	0,					/* tp_methods */
+	0,					/* tp_members */
+	0,					/* tp_getset */
+	0,					/* tp_base */
+	0,					/* tp_dict */
+	0,					/* tp_descr_get */
+	0,					/* tp_descr_set */
+	0,					/* tp_dictoffset */
+	0,					/* tp_init */
+	0,					/* tp_alloc */
+	instance_new,				/* tp_new */
 };
 
 
@@ -2125,6 +2185,31 @@
 	return NULL;
 }
 
+PyDoc_STRVAR(instancemethod_doc,
+"instancemethod(function, instance, class)\n\
+\n\
+Create an instance method object.");
+
+static PyObject *
+instancemethod_new(PyTypeObject* type, PyObject* args, PyObject *kw)
+{
+	PyObject *func;
+	PyObject *self;
+	PyObject *classObj;
+
+	if (!PyArg_ParseTuple(args, "OOO:instancemethod",
+			      &func, &self, &classObj))
+		return NULL;
+	if (!PyCallable_Check(func)) {
+		PyErr_SetString(PyExc_TypeError,
+				"first argument must be callable");
+		return NULL;
+	}
+	if (self == Py_None)
+		self = NULL;
+	return PyMethod_New(func, self, classObj);
+}
+
 static void
 instancemethod_dealloc(register PyMethodObject *im)
 {
@@ -2362,7 +2447,7 @@
 PyTypeObject PyMethod_Type = {
 	PyObject_HEAD_INIT(&PyType_Type)
 	0,
-	"instance method",
+	"instancemethod",
 	sizeof(PyMethodObject),
 	0,
 	(destructor)instancemethod_dealloc,	/* tp_dealloc */
@@ -2381,7 +2466,7 @@
 	PyObject_GenericSetAttr,		/* tp_setattro */
 	0,					/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
-	0,					/* tp_doc */
+	instancemethod_doc,			/* tp_doc */
 	(traverseproc)instancemethod_traverse,	/* tp_traverse */
 	0,					/* tp_clear */
 	0,					/* tp_richcompare */
@@ -2396,6 +2481,9 @@
 	instancemethod_descr_get,		/* tp_descr_get */
 	0,					/* tp_descr_set */
 	0,					/* tp_dictoffset */
+	0,					/* tp_init */
+	0,					/* tp_alloc */
+	instancemethod_new,			/* tp_new */
 };
 
 /* Clear out the free list */
diff --git a/Objects/descrobject.c b/Objects/descrobject.c
index 1130f86..2d926b4 100644
--- a/Objects/descrobject.c
+++ b/Objects/descrobject.c
@@ -725,7 +725,7 @@
 static PyTypeObject proxytype = {
 	PyObject_HEAD_INIT(&PyType_Type)
 	0,					/* ob_size */
-	"dict-proxy",				/* tp_name */
+	"dictproxy",				/* tp_name */
 	sizeof(proxyobject),			/* tp_basicsize */
 	0,					/* tp_itemsize */
 	/* methods */
diff --git a/Objects/funcobject.c b/Objects/funcobject.c
index f96d0dd..4eac035 100644
--- a/Objects/funcobject.c
+++ b/Objects/funcobject.c
@@ -266,6 +266,52 @@
 	{NULL} /* Sentinel */
 };
 
+PyDoc_STRVAR(func_doc,
+"function(code, globals[, name[, argdefs]])\n\
+\n\
+Create a function object from a code object and a dictionary.\n\
+The optional name string overrides the name from the code object.\n\
+The optional argdefs tuple specifies the default argument values.");
+
+static PyObject *
+func_new(PyTypeObject* type, PyObject* args, PyObject* kw)
+{
+	PyObject *code;
+	PyObject *globals;
+	PyObject *name = Py_None;
+	PyObject *defaults = Py_None;
+	PyFunctionObject *newfunc;
+
+	if (!PyArg_ParseTuple(args, "O!O!|OO!:function",
+			      &PyCode_Type, &code,
+			      &PyDict_Type, &globals,
+			      &name,
+			      &PyTuple_Type, &defaults))
+		return NULL;
+	if (name != Py_None && !PyString_Check(name)) {
+		PyErr_SetString(PyExc_TypeError,
+				"arg 3 (name) must be None or string");
+		return NULL;
+	}
+
+	newfunc = (PyFunctionObject *)PyFunction_New(code, globals);
+	if (newfunc == NULL)
+		return NULL;
+
+	if (name != Py_None) {
+		Py_XINCREF(name);
+		Py_XDECREF(newfunc->func_name);
+		newfunc->func_name = name;
+	}
+	if (defaults != Py_None) {
+		Py_XINCREF(defaults);
+		Py_XDECREF(newfunc->func_defaults);
+		newfunc->func_defaults  = defaults;
+	}
+
+	return (PyObject *)newfunc;
+}
+
 static void
 func_dealloc(PyFunctionObject *op)
 {
@@ -415,7 +461,7 @@
 	PyObject_GenericSetAttr,		/* tp_setattro */
 	0,					/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */
-	0,					/* tp_doc */
+	func_doc,				/* tp_doc */
 	(traverseproc)func_traverse,		/* tp_traverse */
 	0,					/* tp_clear */
 	0,					/* tp_richcompare */
@@ -430,6 +476,9 @@
 	func_descr_get,				/* tp_descr_get */
 	0,					/* tp_descr_set */
 	offsetof(PyFunctionObject, func_dict),	/* tp_dictoffset */
+	0,					/* tp_init */
+	0,					/* tp_alloc */
+	func_new,				/* tp_new */
 };
 
 
diff --git a/Objects/sliceobject.c b/Objects/sliceobject.c
index 9a268b7..a43644d 100644
--- a/Objects/sliceobject.c
+++ b/Objects/sliceobject.c
@@ -164,6 +164,30 @@
 	return 0;
 }
 
+static PyObject *
+slice_new(PyTypeObject *type, PyObject *args, PyObject *kw)
+{
+	PyObject *start, *stop, *step;
+
+	start = stop = step = NULL;
+
+	if (!PyArg_ParseTuple(args, "O|OO:slice", &start, &stop, &step))
+		return NULL;
+
+	/* This swapping of stop and start is to maintain similarity with
+	   range(). */
+	if (stop == NULL) {
+		stop = start;
+		start = NULL;
+	}
+	return PySlice_New(start, stop, step);
+}
+
+PyDoc_STRVAR(slice_doc,
+"slice([start,] stop[, step])\n\
+\n\
+Create a slice object.  This is used for extended slicing (e.g. a[0:10:2]).");
+
 static void
 slice_dealloc(PySliceObject *r)
 {
@@ -240,7 +264,7 @@
 	0,					/* tp_setattro */
 	0,					/* tp_as_buffer */
 	Py_TPFLAGS_DEFAULT,			/* tp_flags */
-	0,					/* tp_doc */
+	slice_doc,				/* tp_doc */
 	0,					/* tp_traverse */
 	0,					/* tp_clear */
 	0,					/* tp_richcompare */
@@ -252,4 +276,10 @@
 	0,					/* tp_getset */
 	0,					/* tp_base */
 	0,					/* tp_dict */
+	0,					/* tp_descr_get */
+	0,					/* tp_descr_set */
+	0,					/* tp_dictoffset */
+	0,					/* tp_init */
+	0,					/* tp_alloc */
+	slice_new,				/* tp_new */
 };