Mercurial > cpython-lru_cache-weakref
diff Objects/bufferobject.c @ 23868:8e6760bf1884 legacy-trunk
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]
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Fri, 14 Jun 2002 20:41:17 +0000 |
| parents | f3a416b178c4 |
| children | 8149d978b006 |
line wrap: on
line diff
--- a/Objects/bufferobject.c Fri Jun 14 20:30:31 2002 +0000 +++ b/Objects/bufferobject.c Fri Jun 14 20:41:17 2002 +0000 @@ -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 */ };
