summaryrefslogtreecommitdiffstats
path: root/Python/bltinmodule.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2002-06-14 20:41:17 (GMT)
committerGuido van Rossum <guido@python.org>2002-06-14 20:41:17 (GMT)
commitbea18ccde6bc12e061c21bb6b944379d8b123845 (patch)
treed5366d2bba31bde0cf6d05e1b55cde64cf3d3864 /Python/bltinmodule.c
parent57454e57f83b407dd2653cbfcead7c9801beeff0 (diff)
downloadcpython-bea18ccde6bc12e061c21bb6b944379d8b123845.zip
cpython-bea18ccde6bc12e061c21bb6b944379d8b123845.tar.gz
cpython-bea18ccde6bc12e061c21bb6b944379d8b123845.tar.bz2
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]
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r--Python/bltinmodule.c50
1 files changed, 2 insertions, 48 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 8f28ea6..7126391 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -107,27 +107,6 @@ Note that classes are callable, as are instances with a __call__() method.");
static PyObject *
-builtin_buffer(PyObject *self, PyObject *args)
-{
- 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]]) -> object\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 PyObject *
builtin_callable(PyObject *self, PyObject *v)
{
return PyBool_FromLong((long)PyCallable_Check(v));
@@ -1079,31 +1058,6 @@ Return the number of items of a sequence or mapping.");
static PyObject *
-builtin_slice(PyObject *self, PyObject *args)
-{
- 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]) -> slice object\n\
-\n\
-Create a slice object. This is used for slicing by the Numeric extensions.");
-
-
-static PyObject *
builtin_locals(PyObject *self)
{
PyObject *d;
@@ -1775,7 +1729,6 @@ static PyMethodDef builtin_methods[] = {
{"__import__", builtin___import__, METH_VARARGS, import_doc},
{"abs", builtin_abs, METH_O, abs_doc},
{"apply", builtin_apply, METH_VARARGS, apply_doc},
- {"buffer", builtin_buffer, METH_VARARGS, buffer_doc},
{"callable", builtin_callable, METH_O, callable_doc},
{"chr", builtin_chr, METH_VARARGS, chr_doc},
{"cmp", builtin_cmp, METH_VARARGS, cmp_doc},
@@ -1813,7 +1766,6 @@ static PyMethodDef builtin_methods[] = {
{"repr", builtin_repr, METH_O, repr_doc},
{"round", builtin_round, METH_VARARGS, round_doc},
{"setattr", builtin_setattr, METH_VARARGS, setattr_doc},
- {"slice", builtin_slice, METH_VARARGS, slice_doc},
#ifdef Py_USING_UNICODE
{"unichr", builtin_unichr, METH_VARARGS, unichr_doc},
#endif
@@ -1849,6 +1801,7 @@ _PyBuiltin_Init(void)
SETBUILTIN("True", Py_True);
SETBUILTIN("basestring", &PyBaseString_Type);
SETBUILTIN("bool", &PyBool_Type);
+ SETBUILTIN("buffer", &PyBuffer_Type);
SETBUILTIN("classmethod", &PyClassMethod_Type);
#ifndef WITHOUT_COMPLEX
SETBUILTIN("complex", &PyComplex_Type);
@@ -1861,6 +1814,7 @@ _PyBuiltin_Init(void)
SETBUILTIN("list", &PyList_Type);
SETBUILTIN("long", &PyLong_Type);
SETBUILTIN("object", &PyBaseObject_Type);
+ SETBUILTIN("slice", &PySlice_Type);
SETBUILTIN("staticmethod", &PyStaticMethod_Type);
SETBUILTIN("str", &PyString_Type);
SETBUILTIN("super", &PySuper_Type);