2001-08-02 01:15:00 -03:00
|
|
|
/* Descriptors -- a new, flexible way to describe attributes */
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
#include "structmember.h" /* Why is this not included in Python.h? */
|
|
|
|
|
|
|
|
static void
|
|
|
|
descr_dealloc(PyDescrObject *descr)
|
|
|
|
{
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
_PyObject_GC_UNTRACK(descr);
|
2001-08-02 01:15:00 -03:00
|
|
|
Py_XDECREF(descr->d_type);
|
|
|
|
Py_XDECREF(descr->d_name);
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
PyObject_GC_Del(descr);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static char *
|
|
|
|
descr_name(PyDescrObject *descr)
|
|
|
|
{
|
|
|
|
if (descr->d_name != NULL && PyString_Check(descr->d_name))
|
|
|
|
return PyString_AS_STRING(descr->d_name);
|
|
|
|
else
|
|
|
|
return "?";
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
descr_repr(PyDescrObject *descr, char *format)
|
|
|
|
{
|
2001-08-24 15:34:26 -03:00
|
|
|
return PyString_FromFormat(format, descr_name(descr),
|
|
|
|
descr->d_type->tp_name);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
method_repr(PyMethodDescrObject *descr)
|
|
|
|
{
|
|
|
|
return descr_repr((PyDescrObject *)descr,
|
2001-08-24 15:34:26 -03:00
|
|
|
"<method '%s' of '%s' objects>");
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
member_repr(PyMemberDescrObject *descr)
|
|
|
|
{
|
|
|
|
return descr_repr((PyDescrObject *)descr,
|
2001-08-24 15:34:26 -03:00
|
|
|
"<member '%s' of '%s' objects>");
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
getset_repr(PyGetSetDescrObject *descr)
|
|
|
|
{
|
|
|
|
return descr_repr((PyDescrObject *)descr,
|
2001-08-24 15:34:26 -03:00
|
|
|
"<attribute '%s' of '%s' objects>");
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2005-11-07 04:38:00 -04:00
|
|
|
wrapperdescr_repr(PyWrapperDescrObject *descr)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
return descr_repr((PyDescrObject *)descr,
|
2001-08-24 15:34:26 -03:00
|
|
|
"<slot wrapper '%s' of '%s' objects>");
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2003-02-11 14:44:42 -04:00
|
|
|
descr_check(PyDescrObject *descr, PyObject *obj, PyObject **pres)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2003-02-11 14:44:42 -04:00
|
|
|
if (obj == NULL) {
|
2001-08-02 01:15:00 -03:00
|
|
|
Py_INCREF(descr);
|
|
|
|
*pres = (PyObject *)descr;
|
|
|
|
return 1;
|
|
|
|
}
|
2002-08-19 13:02:33 -03:00
|
|
|
if (!PyObject_TypeCheck(obj, descr->d_type)) {
|
2001-08-02 01:15:00 -03:00
|
|
|
PyErr_Format(PyExc_TypeError,
|
2001-08-24 15:34:26 -03:00
|
|
|
"descriptor '%s' for '%s' objects "
|
|
|
|
"doesn't apply to '%s' object",
|
2001-08-02 01:15:00 -03:00
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
descr->d_type->tp_name,
|
|
|
|
obj->ob_type->tp_name);
|
|
|
|
*pres = NULL;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-12-09 18:56:13 -04:00
|
|
|
static PyObject *
|
2003-02-11 14:44:42 -04:00
|
|
|
classmethod_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type)
|
2002-12-09 18:56:13 -04:00
|
|
|
{
|
2003-02-11 14:44:42 -04:00
|
|
|
/* Ensure a valid type. Class methods ignore obj. */
|
|
|
|
if (type == NULL) {
|
|
|
|
if (obj != NULL)
|
|
|
|
type = (PyObject *)obj->ob_type;
|
|
|
|
else {
|
|
|
|
/* Wot - no type?! */
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%s' for type '%s' "
|
|
|
|
"needs either an object or a type",
|
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
descr->d_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!PyType_Check(type)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%s' for type '%s' "
|
|
|
|
"needs a type, not a '%s' as arg 2",
|
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
descr->d_type->tp_name,
|
|
|
|
type->ob_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!PyType_IsSubtype((PyTypeObject *)type, descr->d_type)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%s' for type '%s' "
|
|
|
|
"doesn't apply to type '%s'",
|
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
descr->d_type->tp_name,
|
|
|
|
((PyTypeObject *)type)->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return PyCFunction_New(descr->d_method, type);
|
2002-12-09 18:56:13 -04:00
|
|
|
}
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyObject *
|
2003-02-11 14:44:42 -04:00
|
|
|
method_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
PyObject *res;
|
|
|
|
|
2003-02-11 14:44:42 -04:00
|
|
|
if (descr_check((PyDescrObject *)descr, obj, &res))
|
2001-08-02 01:15:00 -03:00
|
|
|
return res;
|
|
|
|
return PyCFunction_New(descr->d_method, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2003-02-11 14:44:42 -04:00
|
|
|
member_get(PyMemberDescrObject *descr, PyObject *obj, PyObject *type)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
PyObject *res;
|
|
|
|
|
2003-02-11 14:44:42 -04:00
|
|
|
if (descr_check((PyDescrObject *)descr, obj, &res))
|
2001-08-02 01:15:00 -03:00
|
|
|
return res;
|
2001-09-20 17:46:19 -03:00
|
|
|
return PyMember_GetOne((char *)obj, descr->d_member);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2003-02-11 14:44:42 -04:00
|
|
|
getset_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *type)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
PyObject *res;
|
|
|
|
|
2003-02-11 14:44:42 -04:00
|
|
|
if (descr_check((PyDescrObject *)descr, obj, &res))
|
2001-08-02 01:15:00 -03:00
|
|
|
return res;
|
|
|
|
if (descr->d_getset->get != NULL)
|
|
|
|
return descr->d_getset->get(obj, descr->d_getset->closure);
|
2005-04-19 20:43:40 -03:00
|
|
|
PyErr_Format(PyExc_AttributeError,
|
2001-12-15 01:00:30 -04:00
|
|
|
"attribute '%.300s' of '%.100s' objects is not readable",
|
2001-08-02 01:15:00 -03:00
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
descr->d_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2005-11-07 04:38:00 -04:00
|
|
|
wrapperdescr_get(PyWrapperDescrObject *descr, PyObject *obj, PyObject *type)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
PyObject *res;
|
|
|
|
|
2003-02-11 14:44:42 -04:00
|
|
|
if (descr_check((PyDescrObject *)descr, obj, &res))
|
2001-08-02 01:15:00 -03:00
|
|
|
return res;
|
|
|
|
return PyWrapper_New((PyObject *)descr, obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
descr_setcheck(PyDescrObject *descr, PyObject *obj, PyObject *value,
|
|
|
|
int *pres)
|
|
|
|
{
|
|
|
|
assert(obj != NULL);
|
|
|
|
if (!PyObject_IsInstance(obj, (PyObject *)(descr->d_type))) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%.200s' for '%.100s' objects "
|
|
|
|
"doesn't apply to '%.100s' object",
|
|
|
|
descr_name(descr),
|
|
|
|
descr->d_type->tp_name,
|
|
|
|
obj->ob_type->tp_name);
|
|
|
|
*pres = -1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
member_set(PyMemberDescrObject *descr, PyObject *obj, PyObject *value)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
|
|
|
if (descr_setcheck((PyDescrObject *)descr, obj, value, &res))
|
|
|
|
return res;
|
2001-09-20 17:46:19 -03:00
|
|
|
return PyMember_SetOne((char *)obj, descr->d_member, value);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
getset_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
|
|
|
if (descr_setcheck((PyDescrObject *)descr, obj, value, &res))
|
|
|
|
return res;
|
|
|
|
if (descr->d_getset->set != NULL)
|
|
|
|
return descr->d_getset->set(obj, value,
|
|
|
|
descr->d_getset->closure);
|
2005-04-19 20:43:40 -03:00
|
|
|
PyErr_Format(PyExc_AttributeError,
|
2001-12-15 01:00:30 -04:00
|
|
|
"attribute '%.300s' of '%.100s' objects is not writable",
|
2001-08-02 01:15:00 -03:00
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
descr->d_type->tp_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
methoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwds)
|
|
|
|
{
|
2006-02-15 13:27:45 -04:00
|
|
|
Py_ssize_t argc;
|
2001-08-02 01:15:00 -03:00
|
|
|
PyObject *self, *func, *result;
|
|
|
|
|
|
|
|
/* Make sure that the first argument is acceptable as 'self' */
|
|
|
|
assert(PyTuple_Check(args));
|
|
|
|
argc = PyTuple_GET_SIZE(args);
|
|
|
|
if (argc < 1) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%.300s' of '%.100s' "
|
|
|
|
"object needs an argument",
|
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
descr->d_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
self = PyTuple_GET_ITEM(args, 0);
|
|
|
|
if (!PyObject_IsInstance(self, (PyObject *)(descr->d_type))) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%.200s' "
|
|
|
|
"requires a '%.100s' object "
|
|
|
|
"but received a '%.100s'",
|
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
descr->d_type->tp_name,
|
|
|
|
self->ob_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
func = PyCFunction_New(descr->d_method, self);
|
|
|
|
if (func == NULL)
|
|
|
|
return NULL;
|
|
|
|
args = PyTuple_GetSlice(args, 1, argc);
|
|
|
|
if (args == NULL) {
|
|
|
|
Py_DECREF(func);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
result = PyEval_CallObjectWithKeywords(func, args, kwds);
|
|
|
|
Py_DECREF(args);
|
|
|
|
Py_DECREF(func);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2002-12-09 18:56:13 -04:00
|
|
|
static PyObject *
|
|
|
|
classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args,
|
|
|
|
PyObject *kwds)
|
|
|
|
{
|
|
|
|
PyObject *func, *result;
|
|
|
|
|
|
|
|
func = PyCFunction_New(descr->d_method, (PyObject *)descr->d_type);
|
|
|
|
if (func == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
result = PyEval_CallObjectWithKeywords(func, args, kwds);
|
|
|
|
Py_DECREF(func);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyObject *
|
|
|
|
wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds)
|
|
|
|
{
|
2006-02-15 13:27:45 -04:00
|
|
|
Py_ssize_t argc;
|
2001-08-02 01:15:00 -03:00
|
|
|
PyObject *self, *func, *result;
|
|
|
|
|
|
|
|
/* Make sure that the first argument is acceptable as 'self' */
|
|
|
|
assert(PyTuple_Check(args));
|
|
|
|
argc = PyTuple_GET_SIZE(args);
|
|
|
|
if (argc < 1) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%.300s' of '%.100s' "
|
|
|
|
"object needs an argument",
|
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
descr->d_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
self = PyTuple_GET_ITEM(args, 0);
|
|
|
|
if (!PyObject_IsInstance(self, (PyObject *)(descr->d_type))) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%.200s' "
|
|
|
|
"requires a '%.100s' object "
|
|
|
|
"but received a '%.100s'",
|
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
descr->d_type->tp_name,
|
|
|
|
self->ob_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
func = PyWrapper_New((PyObject *)descr, self);
|
|
|
|
if (func == NULL)
|
|
|
|
return NULL;
|
|
|
|
args = PyTuple_GetSlice(args, 1, argc);
|
|
|
|
if (args == NULL) {
|
|
|
|
Py_DECREF(func);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
result = PyEval_CallObjectWithKeywords(func, args, kwds);
|
|
|
|
Py_DECREF(args);
|
|
|
|
Py_DECREF(func);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2001-09-20 17:46:19 -03:00
|
|
|
method_get_doc(PyMethodDescrObject *descr, void *closure)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
if (descr->d_method->ml_doc == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
return PyString_FromString(descr->d_method->ml_doc);
|
|
|
|
}
|
|
|
|
|
2001-09-20 17:46:19 -03:00
|
|
|
static PyMemberDef descr_members[] = {
|
2001-08-02 01:15:00 -03:00
|
|
|
{"__objclass__", T_OBJECT, offsetof(PyDescrObject, d_type), READONLY},
|
|
|
|
{"__name__", T_OBJECT, offsetof(PyDescrObject, d_name), READONLY},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2001-09-20 18:45:26 -03:00
|
|
|
static PyGetSetDef method_getset[] = {
|
2001-09-20 17:46:19 -03:00
|
|
|
{"__doc__", (getter)method_get_doc},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
member_get_doc(PyMemberDescrObject *descr, void *closure)
|
|
|
|
{
|
|
|
|
if (descr->d_member->doc == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
return PyString_FromString(descr->d_member->doc);
|
|
|
|
}
|
|
|
|
|
2001-09-20 18:45:26 -03:00
|
|
|
static PyGetSetDef member_getset[] = {
|
2001-08-02 01:15:00 -03:00
|
|
|
{"__doc__", (getter)member_get_doc},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2001-09-20 18:45:26 -03:00
|
|
|
static PyObject *
|
|
|
|
getset_get_doc(PyGetSetDescrObject *descr, void *closure)
|
|
|
|
{
|
|
|
|
if (descr->d_getset->doc == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
return PyString_FromString(descr->d_getset->doc);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyGetSetDef getset_getset[] = {
|
|
|
|
{"__doc__", (getter)getset_get_doc},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyObject *
|
2005-11-07 04:38:00 -04:00
|
|
|
wrapperdescr_get_doc(PyWrapperDescrObject *descr, void *closure)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
if (descr->d_base->doc == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
return PyString_FromString(descr->d_base->doc);
|
|
|
|
}
|
|
|
|
|
2005-11-07 04:38:00 -04:00
|
|
|
static PyGetSetDef wrapperdescr_getset[] = {
|
|
|
|
{"__doc__", (getter)wrapperdescr_get_doc},
|
2001-08-02 01:15:00 -03:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
static int
|
|
|
|
descr_traverse(PyObject *self, visitproc visit, void *arg)
|
|
|
|
{
|
|
|
|
PyDescrObject *descr = (PyDescrObject *)self;
|
2006-04-21 07:40:58 -03:00
|
|
|
Py_VISIT(descr->d_type);
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyTypeObject PyMethodDescr_Type = {
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
0,
|
|
|
|
"method_descriptor",
|
|
|
|
sizeof(PyMethodDescrObject),
|
|
|
|
0,
|
|
|
|
(destructor)descr_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_compare */
|
|
|
|
(reprfunc)method_repr, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
|
|
|
(ternaryfunc)methoddescr_call, /* tp_call */
|
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_doc */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
descr_traverse, /* tp_traverse */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_clear */
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
0, /* tp_methods */
|
|
|
|
descr_members, /* tp_members */
|
2001-09-20 17:46:19 -03:00
|
|
|
method_getset, /* tp_getset */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
(descrgetfunc)method_get, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
};
|
|
|
|
|
2003-02-11 14:44:42 -04:00
|
|
|
/* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */
|
2002-12-09 18:56:13 -04:00
|
|
|
static PyTypeObject PyClassMethodDescr_Type = {
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
0,
|
2003-02-11 14:44:42 -04:00
|
|
|
"classmethod_descriptor",
|
2002-12-09 18:56:13 -04:00
|
|
|
sizeof(PyMethodDescrObject),
|
|
|
|
0,
|
|
|
|
(destructor)descr_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_compare */
|
|
|
|
(reprfunc)method_repr, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
2003-02-11 14:44:42 -04:00
|
|
|
(ternaryfunc)classmethoddescr_call, /* tp_call */
|
2002-12-09 18:56:13 -04:00
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
|
|
|
0, /* tp_doc */
|
|
|
|
descr_traverse, /* tp_traverse */
|
|
|
|
0, /* tp_clear */
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
0, /* tp_methods */
|
|
|
|
descr_members, /* tp_members */
|
|
|
|
method_getset, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
(descrgetfunc)classmethod_get, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
};
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyTypeObject PyMemberDescr_Type = {
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
0,
|
|
|
|
"member_descriptor",
|
|
|
|
sizeof(PyMemberDescrObject),
|
|
|
|
0,
|
|
|
|
(destructor)descr_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_compare */
|
|
|
|
(reprfunc)member_repr, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
2006-04-21 07:40:58 -03:00
|
|
|
0, /* tp_call */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_doc */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
descr_traverse, /* tp_traverse */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_clear */
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
0, /* tp_methods */
|
|
|
|
descr_members, /* tp_members */
|
2001-09-20 17:46:19 -03:00
|
|
|
member_getset, /* tp_getset */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
(descrgetfunc)member_get, /* tp_descr_get */
|
|
|
|
(descrsetfunc)member_set, /* tp_descr_set */
|
|
|
|
};
|
|
|
|
|
|
|
|
static PyTypeObject PyGetSetDescr_Type = {
|
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
0,
|
|
|
|
"getset_descriptor",
|
|
|
|
sizeof(PyGetSetDescrObject),
|
|
|
|
0,
|
|
|
|
(destructor)descr_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_compare */
|
|
|
|
(reprfunc)getset_repr, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
2006-04-21 07:40:58 -03:00
|
|
|
0, /* tp_call */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_doc */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
descr_traverse, /* tp_traverse */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_clear */
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
0, /* tp_methods */
|
|
|
|
descr_members, /* tp_members */
|
2001-09-20 18:45:26 -03:00
|
|
|
getset_getset, /* tp_getset */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
(descrgetfunc)getset_get, /* tp_descr_get */
|
|
|
|
(descrsetfunc)getset_set, /* tp_descr_set */
|
|
|
|
};
|
|
|
|
|
2001-10-03 09:09:30 -03:00
|
|
|
PyTypeObject PyWrapperDescr_Type = {
|
2001-08-02 01:15:00 -03:00
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
0,
|
|
|
|
"wrapper_descriptor",
|
|
|
|
sizeof(PyWrapperDescrObject),
|
|
|
|
0,
|
|
|
|
(destructor)descr_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_compare */
|
2005-11-07 04:38:00 -04:00
|
|
|
(reprfunc)wrapperdescr_repr, /* tp_repr */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
|
|
|
(ternaryfunc)wrapperdescr_call, /* tp_call */
|
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_doc */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
descr_traverse, /* tp_traverse */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_clear */
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
0, /* tp_methods */
|
|
|
|
descr_members, /* tp_members */
|
2005-11-07 04:38:00 -04:00
|
|
|
wrapperdescr_getset, /* tp_getset */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
2005-11-07 04:38:00 -04:00
|
|
|
(descrgetfunc)wrapperdescr_get, /* tp_descr_get */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_descr_set */
|
|
|
|
};
|
|
|
|
|
|
|
|
static PyDescrObject *
|
2005-12-10 14:50:16 -04:00
|
|
|
descr_new(PyTypeObject *descrtype, PyTypeObject *type, const char *name)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
PyDescrObject *descr;
|
|
|
|
|
|
|
|
descr = (PyDescrObject *)PyType_GenericAlloc(descrtype, 0);
|
|
|
|
if (descr != NULL) {
|
|
|
|
Py_XINCREF(type);
|
|
|
|
descr->d_type = type;
|
|
|
|
descr->d_name = PyString_InternFromString(name);
|
|
|
|
if (descr->d_name == NULL) {
|
|
|
|
Py_DECREF(descr);
|
|
|
|
descr = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return descr;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyDescr_NewMethod(PyTypeObject *type, PyMethodDef *method)
|
|
|
|
{
|
|
|
|
PyMethodDescrObject *descr;
|
|
|
|
|
|
|
|
descr = (PyMethodDescrObject *)descr_new(&PyMethodDescr_Type,
|
|
|
|
type, method->ml_name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_method = method;
|
|
|
|
return (PyObject *)descr;
|
|
|
|
}
|
|
|
|
|
2002-12-09 18:56:13 -04:00
|
|
|
PyObject *
|
|
|
|
PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
|
|
|
|
{
|
|
|
|
PyMethodDescrObject *descr;
|
|
|
|
|
|
|
|
descr = (PyMethodDescrObject *)descr_new(&PyClassMethodDescr_Type,
|
|
|
|
type, method->ml_name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_method = method;
|
|
|
|
return (PyObject *)descr;
|
|
|
|
}
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
PyObject *
|
2001-09-20 17:46:19 -03:00
|
|
|
PyDescr_NewMember(PyTypeObject *type, PyMemberDef *member)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
PyMemberDescrObject *descr;
|
|
|
|
|
|
|
|
descr = (PyMemberDescrObject *)descr_new(&PyMemberDescr_Type,
|
|
|
|
type, member->name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_member = member;
|
|
|
|
return (PyObject *)descr;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
2001-09-20 18:45:26 -03:00
|
|
|
PyDescr_NewGetSet(PyTypeObject *type, PyGetSetDef *getset)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
PyGetSetDescrObject *descr;
|
|
|
|
|
|
|
|
descr = (PyGetSetDescrObject *)descr_new(&PyGetSetDescr_Type,
|
|
|
|
type, getset->name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_getset = getset;
|
|
|
|
return (PyObject *)descr;
|
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *base, void *wrapped)
|
|
|
|
{
|
|
|
|
PyWrapperDescrObject *descr;
|
|
|
|
|
|
|
|
descr = (PyWrapperDescrObject *)descr_new(&PyWrapperDescr_Type,
|
|
|
|
type, base->name);
|
|
|
|
if (descr != NULL) {
|
|
|
|
descr->d_base = base;
|
|
|
|
descr->d_wrapped = wrapped;
|
|
|
|
}
|
|
|
|
return (PyObject *)descr;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* --- Readonly proxy for dictionaries (actually any mapping) --- */
|
|
|
|
|
|
|
|
/* This has no reason to be in this file except that adding new files is a
|
|
|
|
bit of a pain */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
|
|
|
PyObject *dict;
|
|
|
|
} proxyobject;
|
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
static Py_ssize_t
|
2001-08-02 01:15:00 -03:00
|
|
|
proxy_len(proxyobject *pp)
|
|
|
|
{
|
|
|
|
return PyObject_Size(pp->dict);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
proxy_getitem(proxyobject *pp, PyObject *key)
|
|
|
|
{
|
|
|
|
return PyObject_GetItem(pp->dict, key);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMappingMethods proxy_as_mapping = {
|
2006-02-15 13:27:45 -04:00
|
|
|
(lenfunc)proxy_len, /* mp_length */
|
2001-08-02 01:15:00 -03:00
|
|
|
(binaryfunc)proxy_getitem, /* mp_subscript */
|
|
|
|
0, /* mp_ass_subscript */
|
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
|
|
|
proxy_contains(proxyobject *pp, PyObject *key)
|
|
|
|
{
|
2003-12-13 07:58:56 -04:00
|
|
|
return PyDict_Contains(pp->dict, key);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PySequenceMethods proxy_as_sequence = {
|
|
|
|
0, /* sq_length */
|
|
|
|
0, /* sq_concat */
|
|
|
|
0, /* sq_repeat */
|
|
|
|
0, /* sq_item */
|
|
|
|
0, /* sq_slice */
|
|
|
|
0, /* sq_ass_item */
|
|
|
|
0, /* sq_ass_slice */
|
|
|
|
(objobjproc)proxy_contains, /* sq_contains */
|
|
|
|
0, /* sq_inplace_concat */
|
|
|
|
0, /* sq_inplace_repeat */
|
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *
|
2001-08-16 10:15:00 -03:00
|
|
|
proxy_has_key(proxyobject *pp, PyObject *key)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2003-12-13 07:58:56 -04:00
|
|
|
int res = PyDict_Contains(pp->dict, key);
|
2003-10-09 00:47:08 -03:00
|
|
|
if (res < 0)
|
|
|
|
return NULL;
|
|
|
|
return PyBool_FromLong(res);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
proxy_get(proxyobject *pp, PyObject *args)
|
|
|
|
{
|
|
|
|
PyObject *key, *def = Py_None;
|
|
|
|
|
2002-12-29 12:33:45 -04:00
|
|
|
if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &def))
|
2001-08-02 01:15:00 -03:00
|
|
|
return NULL;
|
|
|
|
return PyObject_CallMethod(pp->dict, "get", "(OO)", key, def);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2001-08-16 10:15:00 -03:00
|
|
|
proxy_keys(proxyobject *pp)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
return PyMapping_Keys(pp->dict);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2001-08-16 10:15:00 -03:00
|
|
|
proxy_values(proxyobject *pp)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
return PyMapping_Values(pp->dict);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2001-08-16 10:15:00 -03:00
|
|
|
proxy_items(proxyobject *pp)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
return PyMapping_Items(pp->dict);
|
|
|
|
}
|
|
|
|
|
2002-03-25 13:43:22 -04:00
|
|
|
static PyObject *
|
|
|
|
proxy_iterkeys(proxyobject *pp)
|
|
|
|
{
|
|
|
|
return PyObject_CallMethod(pp->dict, "iterkeys", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
proxy_itervalues(proxyobject *pp)
|
|
|
|
{
|
|
|
|
return PyObject_CallMethod(pp->dict, "itervalues", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
proxy_iteritems(proxyobject *pp)
|
|
|
|
{
|
|
|
|
return PyObject_CallMethod(pp->dict, "iteritems", NULL);
|
|
|
|
}
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyObject *
|
2001-08-16 10:15:00 -03:00
|
|
|
proxy_copy(proxyobject *pp)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
|
|
|
return PyObject_CallMethod(pp->dict, "copy", NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef proxy_methods[] = {
|
2002-04-13 11:06:36 -03:00
|
|
|
{"has_key", (PyCFunction)proxy_has_key, METH_O,
|
2003-09-01 19:12:08 -03:00
|
|
|
PyDoc_STR("D.has_key(k) -> True if D has a key k, else False")},
|
2002-04-13 11:06:36 -03:00
|
|
|
{"get", (PyCFunction)proxy_get, METH_VARARGS,
|
2002-08-13 19:19:13 -03:00
|
|
|
PyDoc_STR("D.get(k[,d]) -> D[k] if D.has_key(k), else d."
|
|
|
|
" d defaults to None.")},
|
2002-04-13 11:06:36 -03:00
|
|
|
{"keys", (PyCFunction)proxy_keys, METH_NOARGS,
|
2002-08-13 19:19:13 -03:00
|
|
|
PyDoc_STR("D.keys() -> list of D's keys")},
|
2002-04-13 11:06:36 -03:00
|
|
|
{"values", (PyCFunction)proxy_values, METH_NOARGS,
|
2002-08-13 19:19:13 -03:00
|
|
|
PyDoc_STR("D.values() -> list of D's values")},
|
2002-04-13 11:06:36 -03:00
|
|
|
{"items", (PyCFunction)proxy_items, METH_NOARGS,
|
2002-08-13 19:19:13 -03:00
|
|
|
PyDoc_STR("D.items() -> list of D's (key, value) pairs, as 2-tuples")},
|
2002-04-13 11:06:36 -03:00
|
|
|
{"iterkeys", (PyCFunction)proxy_iterkeys, METH_NOARGS,
|
2002-08-13 19:19:13 -03:00
|
|
|
PyDoc_STR("D.iterkeys() -> an iterator over the keys of D")},
|
2002-04-13 11:06:36 -03:00
|
|
|
{"itervalues",(PyCFunction)proxy_itervalues, METH_NOARGS,
|
2002-08-13 19:19:13 -03:00
|
|
|
PyDoc_STR("D.itervalues() -> an iterator over the values of D")},
|
2002-04-13 11:06:36 -03:00
|
|
|
{"iteritems", (PyCFunction)proxy_iteritems, METH_NOARGS,
|
2002-08-13 19:19:13 -03:00
|
|
|
PyDoc_STR("D.iteritems() ->"
|
|
|
|
" an iterator over the (key, value) items of D")},
|
2002-04-13 11:06:36 -03:00
|
|
|
{"copy", (PyCFunction)proxy_copy, METH_NOARGS,
|
2002-08-13 19:19:13 -03:00
|
|
|
PyDoc_STR("D.copy() -> a shallow copy of D")},
|
2001-08-02 01:15:00 -03:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
|
|
|
proxy_dealloc(proxyobject *pp)
|
|
|
|
{
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
_PyObject_GC_UNTRACK(pp);
|
2001-08-02 01:15:00 -03:00
|
|
|
Py_DECREF(pp->dict);
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
PyObject_GC_Del(pp);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
proxy_getiter(proxyobject *pp)
|
|
|
|
{
|
|
|
|
return PyObject_GetIter(pp->dict);
|
|
|
|
}
|
|
|
|
|
2001-10-21 19:26:43 -03:00
|
|
|
static PyObject *
|
2001-08-02 01:15:00 -03:00
|
|
|
proxy_str(proxyobject *pp)
|
|
|
|
{
|
|
|
|
return PyObject_Str(pp->dict);
|
|
|
|
}
|
|
|
|
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
static int
|
|
|
|
proxy_traverse(PyObject *self, visitproc visit, void *arg)
|
|
|
|
{
|
|
|
|
proxyobject *pp = (proxyobject *)self;
|
2006-04-21 07:40:58 -03:00
|
|
|
Py_VISIT(pp->dict);
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-08-31 12:51:04 -03:00
|
|
|
static int
|
|
|
|
proxy_compare(proxyobject *v, PyObject *w)
|
|
|
|
{
|
|
|
|
return PyObject_Compare(v->dict, w);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
proxy_richcompare(proxyobject *v, PyObject *w, int op)
|
|
|
|
{
|
|
|
|
return PyObject_RichCompare(v->dict, w, op);
|
|
|
|
}
|
|
|
|
|
2001-10-21 19:26:43 -03:00
|
|
|
static PyTypeObject proxytype = {
|
2001-08-02 01:15:00 -03:00
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
0, /* ob_size */
|
2002-06-14 17:41:17 -03:00
|
|
|
"dictproxy", /* tp_name */
|
2001-08-02 01:15:00 -03:00
|
|
|
sizeof(proxyobject), /* tp_basicsize */
|
|
|
|
0, /* tp_itemsize */
|
|
|
|
/* methods */
|
|
|
|
(destructor)proxy_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2002-08-31 12:51:04 -03:00
|
|
|
(cmpfunc)proxy_compare, /* tp_compare */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
&proxy_as_sequence, /* tp_as_sequence */
|
|
|
|
&proxy_as_mapping, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
|
|
|
0, /* tp_call */
|
|
|
|
(reprfunc)proxy_str, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_doc */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
proxy_traverse, /* tp_traverse */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_clear */
|
2002-08-31 12:51:04 -03:00
|
|
|
(richcmpfunc)proxy_richcompare, /* tp_richcompare */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
(getiterfunc)proxy_getiter, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
proxy_methods, /* tp_methods */
|
|
|
|
0, /* tp_members */
|
|
|
|
0, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
};
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyDictProxy_New(PyObject *dict)
|
|
|
|
{
|
|
|
|
proxyobject *pp;
|
|
|
|
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
pp = PyObject_GC_New(proxyobject, &proxytype);
|
2001-08-02 01:15:00 -03:00
|
|
|
if (pp != NULL) {
|
|
|
|
Py_INCREF(dict);
|
|
|
|
pp->dict = dict;
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
_PyObject_GC_TRACK(pp);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
return (PyObject *)pp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* --- Wrapper object for "slot" methods --- */
|
|
|
|
|
|
|
|
/* This has no reason to be in this file except that adding new files is a
|
|
|
|
bit of a pain */
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
|
|
|
PyWrapperDescrObject *descr;
|
|
|
|
PyObject *self;
|
|
|
|
} wrapperobject;
|
|
|
|
|
|
|
|
static void
|
|
|
|
wrapper_dealloc(wrapperobject *wp)
|
|
|
|
{
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
_PyObject_GC_UNTRACK(wp);
|
2001-08-02 01:15:00 -03:00
|
|
|
Py_XDECREF(wp->descr);
|
|
|
|
Py_XDECREF(wp->self);
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
PyObject_GC_Del(wp);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2005-11-07 04:38:00 -04:00
|
|
|
static int
|
|
|
|
wrapper_compare(wrapperobject *a, wrapperobject *b)
|
|
|
|
{
|
Merge the rest of the trunk.
Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines
Updated version (win32-icons2.zip) from #1490384.
........
r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1472084] Fix description of do_tag
........
r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1475554] Strengthen text to say 'must' instead of 'should'
........
r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1441864] Clarify description of 'data' argument
........
r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line
Minor rewording
........
r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines
[Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler.
Fix by renaming the variable.
In a different module, Neal fixed it by renaming _self to self. There's
already a variable named 'self' here, so I used selfptr.
(I'm committing this on a Mac without Tk, but it's a simple search-and-replace.
<crosses fingers>, so I'll watch the buildbots and see what happens.)
........
r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines
"_self" is a said to be a reserved word in Watcom C 10.6. I'm
not sure that's really standard compliant behaviour, but I guess
we have to fix that anyway...
........
r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line
Update readme
........
r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line
Drop 0 parameter
........
r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line
Some code tidying; use curses.wrapper
........
r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line
Use True; value returned from main is unused
........
r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line
Use true division, and the True value
........
r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line
Docstring fix; use True
........
r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line
Put code in a main() function; loosen up the spacing to match current code style
........
r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line
Use functions; modernize code
........
r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line
This demo requires Medusa (not just asyncore); remove it
........
r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines
Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module.
........
r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line
Remove xmlrpc/ directory
........
r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line
Remove dangling reference
........
r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line
Add more whitespace; use a better socket name
........
r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines
Whitespace normalization.
........
r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines
In a PYMALLOC_DEBUG build obmalloc adds extra debugging info
to each allocated block. This was using 4 bytes for each such
piece of info regardless of platform. This didn't really matter
before (proof: no bug reports, and the debug-build obmalloc would
have assert-failed if it was ever asked for a chunk of memory
>= 2**32 bytes), since container indices were plain ints. But after
the Py_ssize_t changes, it's at least theoretically possible to
allocate a list or string whose guts exceed 2**32 bytes, and the
PYMALLOC_DEBUG routines would fail then (having only 4 bytes
to record the originally requested size).
Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG
build's extra debugging fields. This won't make any difference
on 32-bit boxes, but will add 16 bytes to each allocation in
a debug build on a 64-bit box.
........
r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines
_PyObject_DebugMalloc(): The return value should add
2*sizeof(size_t) now, not 8. This probably accounts for
current disasters on the 64-bit buildbot slaves.
........
r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line
SF #1499797, Fix for memory leak in WindowsError_str
........
r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines
Patch #1454481: Make thread stack size runtime tunable.
........
r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines
clean up function declarations to conform to PEP-7 style.
........
r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines
Fixes in struct and socket from merge reviews.
- Following Guido's comments, renamed
* pack_to -> pack_into
* recv_buf -> recv_into
* recvfrom_buf -> recvfrom_into
- Made fixes to _struct.c according to Neal Norwitz comments on the checkins
list.
- Converted some ints into the appropriate -- I hope -- ssize_t and size_t.
........
r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines
"Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with
the right compiler flags.
........
r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines
Drop Mac wrappers for the WASTE library.
........
r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines
s_methods[]: Stop compiler warnings by casting
s_unpack_from to PyCFunction.
........
r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines
Remove a redundant word
........
r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines
Markup fix
........
r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines
Patch #1359618: Speed-up charmap encoder.
........
r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines
Repair refleaks in unicodeobject.
........
r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines
Patch #1346214: correctly optimize away "if 0"-style stmts
(thanks to Neal for review)
........
r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines
Bug #1500293: fix memory leaks in _subprocess module.
........
r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines
Revert revisions:
46640 Patch #1454481: Make thread stack size runtime tunable.
46647 Markup fix
The first is causing many buildbots to fail test runs, and there
are multiple causes with seemingly no immediate prospects for
repairing them. See python-dev discussion.
Note that a branch can (and should) be created for resolving these
problems, like
svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH
followed by merging rev 46647 to the new branch.
........
r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line
Mention second encoding speedup
........
r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines
bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present
in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized
char **log_list.
feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2.
........
r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines
fix a bug in the previous commit. don't leak empty list on error return and
fix the additional rare (out of memory only) bug that it was supposed to fix
of not freeing log_list when the python allocator failed.
........
r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines
"Flat is better than nested."
Move the long-winded, multiply-nested -R support out
of runtest() and into some module-level helper functions.
This makes runtest() and the -R code easier to follow.
That in turn allowed seeing some opportunities for code
simplification, and made it obvious that reglog.txt
never got closed.
........
r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines
Fix a potentially invalid memory access of CJKCodecs' shift-jis
decoder. (found by Neal Norwitz)
........
r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines
* support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885]
........
r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines
Remove doctest.testmod's deprecated (in 2.4) `isprivate`
argument. A lot of hair went into supporting that!
........
r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines
Make doctest news more accurate.
........
r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines
* support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902]
........
r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines
mention the just committed bsddb changes
........
r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines
* add support for DBSequence objects [patch #1466734]
........
r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines
forgot to add this file in previous commit
........
r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines
* fix DBCursor.pget() bug with keyword argument names when no data= is
supplied [SF pybsddb bug #1477863]
........
r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line
Remove use of Trove name, which isn't very helpful to users
........
r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line
[Bug #1470026] Include link to list of classifiers
........
r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines
Access _struct attributes directly instead of mucking with getattr.
string_reverse(): Simplify.
assertRaises(): Raise TestFailed on failure.
test_unpack_from(), test_pack_into(), test_pack_into_fn(): never
use `assert` to test for an expected result (it doesn't test anything
when Python is run with -O).
........
r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines
add depends = ['md5.h'] to the _md5 module extension for correctness sake.
........
r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines
Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int.
Closes bug #1501223.
........
r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines
- bsddb: the __len__ method of a DB object has been fixed to return correct
results. It could previously incorrectly return 0 in some cases.
Fixes SF bug 1493322 (pybsddb bug 1184012).
........
r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines
_PySys_Init(): It's rarely a good idea to size a buffer to the
exact maximum size someone guesses is needed. In this case, if
we're really worried about extreme integers, then "cp%d" can
actually need 14 bytes (2 for "cp" + 1 for \0 at the end +
11 for -(2**31-1)). So reserve 128 bytes instead -- nothing is
actually saved by making a stack-local buffer tiny.
........
r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line
Remove unused variable (and stop compiler warning)
........
r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line
Fix a bunch of parameter strings
........
r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines
Convert CFieldObject tp_members to tp_getset, since there is no
structmember typecode for Py_ssize_t fields. This should fix some of
the errors on the PPC64 debian machine (64-bit, big endian).
Assigning to readonly fields now raises AttributeError instead of
TypeError, so the testcase has to be changed as well.
........
r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line
Damn - the sentinel was missing. And fix another silly mistake.
........
r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines
Normalized a few cases of whitespace in function declarations.
Found them using::
find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done
find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done
(I was doing this all over my own code anyway, because I'd been using spaces in
all defs, so I thought I'd make a run on the Python code as well. If you need
to do such fixes in your own code, you can use xx-rename or parenregu.el within
emacs.)
........
r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line
Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures
........
r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines
BSequence_set_range(): Rev 46688 ("Fix a bunch of
parameter strings") changed this function's signature
seemingly by mistake, which is causing buildbots to fail
test_bsddb3. Restored the pre-46688 signature.
........
r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines
On python-dev Thomas Heller said these were committed
by mistake in rev 46693, so reverting this part of
rev 46693.
........
r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line
Fix comment typo
........
r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines
Fix coding style guide bug.
........
r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines
Add a hack so that foreign functions returning float now do work on 64-bit
big endian platforms.
........
r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines
Use the same big-endian hack as in _ctypes/callproc.c for callback functions.
This fixes the callback function tests that return float.
........
r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines
* Ensure that "make altinstall" works when the tree was configured
with --enable-framework
* Also for --enable-framework: allow users to use --prefix to specify
the location of the compatibility symlinks (such as /usr/local/bin/python)
........
r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines
A quick hack to ensure the right key-bindings for IDLE on osx: install patched
configuration files during a framework install.
........
r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines
dash_R_cleanup(): Clear filecmp._cache. This accounts for
different results across -R runs (at least on Windows) of
test_filecmp.
........
r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines
SF patch 1501987: Remove randomness from test_exceptions,
from ?iga Seilnacht (sorry about the name, but Firefox
on my box can't display the first character of the name --
the SF "Unix name" is zseil).
This appears to cure the oddball intermittent leaks across
runs when running test_exceptions under -R. I'm not sure
why, but I'm too sleepy to care ;-)
The thrust of the SF patch was to remove randomness in the
pickle protocol used. I changed the patch to use
range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and
cPickle, and randomly mucked with other test lines to put
statements on their own lines.
Not a bugfix candidate (this is fiddling new-in-2.5 code).
........
r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line
Add an SQLite introduction, taken from the 'What's New' text
........
r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line
Mention other placeholders
........
r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line
Add an item; also, escape %
........
r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line
Mention other placeholders
........
r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/Tools one level up
........
r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/PythonLauncher one level up
........
r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines
mv Mac/OSX/BuildScript one level up
........
r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/* one level up
........
r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines
And the last bit: move IDLE one level up and adjust makefiles
........
r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines
- Patch the correct version of python in the Info.plists at build time, instead
of relying on a maintainer to update them before releases.
- Remove the now empty Mac/OSX directory
........
r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines
* If BuildApplet.py is used as an applet it starts with a version of
sys.exutable that isn't usuable on an #!-line. That results in generated
applets that don't actually work. Work around this problem by resetting
sys.executable.
* argvemulator.py didn't work on intel macs. This patch fixes this
(bug #1491468)
........
r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines
Whitespace normalization.
........
r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines
Fix for foreign functions returning small structures on 64-bit big
endian machines. Should fix the remaininf failure in the PPC64
Debian buildbot.
Thanks to Matthias Klose for providing access to a machine to debug
and test this.
........
r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines
Clarify documentation for bf_getcharbuffer.
........
r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line
Fix a refleak in recvfrom_into
........
r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines
- bsddb: the bsddb.dbtables Modify method now raises the proper error and
aborts the db transaction safely when a modifier callback fails.
Fixes SF python patch/bug #1408584.
Also cleans up the bsddb.dbtables docstrings since thats the only
documentation that exists for that unadvertised module. (people
really should really just use sqlite3)
........
r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines
* Turn the deadlock situation described in SF bug #775414 into a
DBDeadLockError exception.
* add the test case for my previous dbtables commit.
........
r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines
pasted set_lk_detect line in wrong spot in previous commit. fixed. passes tests this time.
........
r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines
(arre, arigo) SF bug #1350060
Give a consistent behavior for comparison and hashing of method objects
(both user- and built-in methods). Now compares the 'self' recursively.
The hash was already asking for the hash of 'self'.
........
r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line
Typo fix
........
r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines
Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking.
........
r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines
Bug #1502728: Correctly link against librt library on HP-UX.
........
r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines
Add news for recent bugfix.
........
r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines
Argh. "integer" is a very confusing word ;)
Actually, checking for INT_MAX and INT_MIN is correct since
the format code explicitly handles a C "int".
........
r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line
Add functools.update_wrapper() and functools.wraps() as described in PEP 356
........
r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines
Bug #1502805: don't alias file.__exit__ to file.close since the
latter can return something that's true.
........
r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines
Convert test_file to unittest.
........
2006-06-08 12:35:45 -03:00
|
|
|
if (a->descr == b->descr)
|
|
|
|
return PyObject_Compare(a->self, b->self);
|
2005-11-07 04:38:00 -04:00
|
|
|
else
|
|
|
|
return (a->descr < b->descr) ? -1 : 1;
|
|
|
|
}
|
|
|
|
|
Merge the rest of the trunk.
Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines
Updated version (win32-icons2.zip) from #1490384.
........
r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1472084] Fix description of do_tag
........
r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1475554] Strengthen text to say 'must' instead of 'should'
........
r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1441864] Clarify description of 'data' argument
........
r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line
Minor rewording
........
r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines
[Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler.
Fix by renaming the variable.
In a different module, Neal fixed it by renaming _self to self. There's
already a variable named 'self' here, so I used selfptr.
(I'm committing this on a Mac without Tk, but it's a simple search-and-replace.
<crosses fingers>, so I'll watch the buildbots and see what happens.)
........
r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines
"_self" is a said to be a reserved word in Watcom C 10.6. I'm
not sure that's really standard compliant behaviour, but I guess
we have to fix that anyway...
........
r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line
Update readme
........
r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line
Drop 0 parameter
........
r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line
Some code tidying; use curses.wrapper
........
r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line
Use True; value returned from main is unused
........
r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line
Use true division, and the True value
........
r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line
Docstring fix; use True
........
r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line
Put code in a main() function; loosen up the spacing to match current code style
........
r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line
Use functions; modernize code
........
r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line
This demo requires Medusa (not just asyncore); remove it
........
r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines
Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module.
........
r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line
Remove xmlrpc/ directory
........
r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line
Remove dangling reference
........
r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line
Add more whitespace; use a better socket name
........
r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines
Whitespace normalization.
........
r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines
In a PYMALLOC_DEBUG build obmalloc adds extra debugging info
to each allocated block. This was using 4 bytes for each such
piece of info regardless of platform. This didn't really matter
before (proof: no bug reports, and the debug-build obmalloc would
have assert-failed if it was ever asked for a chunk of memory
>= 2**32 bytes), since container indices were plain ints. But after
the Py_ssize_t changes, it's at least theoretically possible to
allocate a list or string whose guts exceed 2**32 bytes, and the
PYMALLOC_DEBUG routines would fail then (having only 4 bytes
to record the originally requested size).
Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG
build's extra debugging fields. This won't make any difference
on 32-bit boxes, but will add 16 bytes to each allocation in
a debug build on a 64-bit box.
........
r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines
_PyObject_DebugMalloc(): The return value should add
2*sizeof(size_t) now, not 8. This probably accounts for
current disasters on the 64-bit buildbot slaves.
........
r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line
SF #1499797, Fix for memory leak in WindowsError_str
........
r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines
Patch #1454481: Make thread stack size runtime tunable.
........
r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines
clean up function declarations to conform to PEP-7 style.
........
r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines
Fixes in struct and socket from merge reviews.
- Following Guido's comments, renamed
* pack_to -> pack_into
* recv_buf -> recv_into
* recvfrom_buf -> recvfrom_into
- Made fixes to _struct.c according to Neal Norwitz comments on the checkins
list.
- Converted some ints into the appropriate -- I hope -- ssize_t and size_t.
........
r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines
"Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with
the right compiler flags.
........
r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines
Drop Mac wrappers for the WASTE library.
........
r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines
s_methods[]: Stop compiler warnings by casting
s_unpack_from to PyCFunction.
........
r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines
Remove a redundant word
........
r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines
Markup fix
........
r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines
Patch #1359618: Speed-up charmap encoder.
........
r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines
Repair refleaks in unicodeobject.
........
r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines
Patch #1346214: correctly optimize away "if 0"-style stmts
(thanks to Neal for review)
........
r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines
Bug #1500293: fix memory leaks in _subprocess module.
........
r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines
Revert revisions:
46640 Patch #1454481: Make thread stack size runtime tunable.
46647 Markup fix
The first is causing many buildbots to fail test runs, and there
are multiple causes with seemingly no immediate prospects for
repairing them. See python-dev discussion.
Note that a branch can (and should) be created for resolving these
problems, like
svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH
followed by merging rev 46647 to the new branch.
........
r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line
Mention second encoding speedup
........
r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines
bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present
in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized
char **log_list.
feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2.
........
r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines
fix a bug in the previous commit. don't leak empty list on error return and
fix the additional rare (out of memory only) bug that it was supposed to fix
of not freeing log_list when the python allocator failed.
........
r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines
"Flat is better than nested."
Move the long-winded, multiply-nested -R support out
of runtest() and into some module-level helper functions.
This makes runtest() and the -R code easier to follow.
That in turn allowed seeing some opportunities for code
simplification, and made it obvious that reglog.txt
never got closed.
........
r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines
Fix a potentially invalid memory access of CJKCodecs' shift-jis
decoder. (found by Neal Norwitz)
........
r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines
* support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885]
........
r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines
Remove doctest.testmod's deprecated (in 2.4) `isprivate`
argument. A lot of hair went into supporting that!
........
r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines
Make doctest news more accurate.
........
r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines
* support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902]
........
r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines
mention the just committed bsddb changes
........
r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines
* add support for DBSequence objects [patch #1466734]
........
r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines
forgot to add this file in previous commit
........
r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines
* fix DBCursor.pget() bug with keyword argument names when no data= is
supplied [SF pybsddb bug #1477863]
........
r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line
Remove use of Trove name, which isn't very helpful to users
........
r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line
[Bug #1470026] Include link to list of classifiers
........
r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines
Access _struct attributes directly instead of mucking with getattr.
string_reverse(): Simplify.
assertRaises(): Raise TestFailed on failure.
test_unpack_from(), test_pack_into(), test_pack_into_fn(): never
use `assert` to test for an expected result (it doesn't test anything
when Python is run with -O).
........
r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines
add depends = ['md5.h'] to the _md5 module extension for correctness sake.
........
r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines
Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int.
Closes bug #1501223.
........
r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines
- bsddb: the __len__ method of a DB object has been fixed to return correct
results. It could previously incorrectly return 0 in some cases.
Fixes SF bug 1493322 (pybsddb bug 1184012).
........
r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines
_PySys_Init(): It's rarely a good idea to size a buffer to the
exact maximum size someone guesses is needed. In this case, if
we're really worried about extreme integers, then "cp%d" can
actually need 14 bytes (2 for "cp" + 1 for \0 at the end +
11 for -(2**31-1)). So reserve 128 bytes instead -- nothing is
actually saved by making a stack-local buffer tiny.
........
r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line
Remove unused variable (and stop compiler warning)
........
r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line
Fix a bunch of parameter strings
........
r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines
Convert CFieldObject tp_members to tp_getset, since there is no
structmember typecode for Py_ssize_t fields. This should fix some of
the errors on the PPC64 debian machine (64-bit, big endian).
Assigning to readonly fields now raises AttributeError instead of
TypeError, so the testcase has to be changed as well.
........
r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line
Damn - the sentinel was missing. And fix another silly mistake.
........
r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines
Normalized a few cases of whitespace in function declarations.
Found them using::
find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done
find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done
(I was doing this all over my own code anyway, because I'd been using spaces in
all defs, so I thought I'd make a run on the Python code as well. If you need
to do such fixes in your own code, you can use xx-rename or parenregu.el within
emacs.)
........
r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line
Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures
........
r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines
BSequence_set_range(): Rev 46688 ("Fix a bunch of
parameter strings") changed this function's signature
seemingly by mistake, which is causing buildbots to fail
test_bsddb3. Restored the pre-46688 signature.
........
r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines
On python-dev Thomas Heller said these were committed
by mistake in rev 46693, so reverting this part of
rev 46693.
........
r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line
Fix comment typo
........
r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines
Fix coding style guide bug.
........
r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines
Add a hack so that foreign functions returning float now do work on 64-bit
big endian platforms.
........
r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines
Use the same big-endian hack as in _ctypes/callproc.c for callback functions.
This fixes the callback function tests that return float.
........
r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines
* Ensure that "make altinstall" works when the tree was configured
with --enable-framework
* Also for --enable-framework: allow users to use --prefix to specify
the location of the compatibility symlinks (such as /usr/local/bin/python)
........
r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines
A quick hack to ensure the right key-bindings for IDLE on osx: install patched
configuration files during a framework install.
........
r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines
dash_R_cleanup(): Clear filecmp._cache. This accounts for
different results across -R runs (at least on Windows) of
test_filecmp.
........
r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines
SF patch 1501987: Remove randomness from test_exceptions,
from ?iga Seilnacht (sorry about the name, but Firefox
on my box can't display the first character of the name --
the SF "Unix name" is zseil).
This appears to cure the oddball intermittent leaks across
runs when running test_exceptions under -R. I'm not sure
why, but I'm too sleepy to care ;-)
The thrust of the SF patch was to remove randomness in the
pickle protocol used. I changed the patch to use
range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and
cPickle, and randomly mucked with other test lines to put
statements on their own lines.
Not a bugfix candidate (this is fiddling new-in-2.5 code).
........
r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line
Add an SQLite introduction, taken from the 'What's New' text
........
r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line
Mention other placeholders
........
r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line
Add an item; also, escape %
........
r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line
Mention other placeholders
........
r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/Tools one level up
........
r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/PythonLauncher one level up
........
r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines
mv Mac/OSX/BuildScript one level up
........
r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/* one level up
........
r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines
And the last bit: move IDLE one level up and adjust makefiles
........
r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines
- Patch the correct version of python in the Info.plists at build time, instead
of relying on a maintainer to update them before releases.
- Remove the now empty Mac/OSX directory
........
r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines
* If BuildApplet.py is used as an applet it starts with a version of
sys.exutable that isn't usuable on an #!-line. That results in generated
applets that don't actually work. Work around this problem by resetting
sys.executable.
* argvemulator.py didn't work on intel macs. This patch fixes this
(bug #1491468)
........
r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines
Whitespace normalization.
........
r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines
Fix for foreign functions returning small structures on 64-bit big
endian machines. Should fix the remaininf failure in the PPC64
Debian buildbot.
Thanks to Matthias Klose for providing access to a machine to debug
and test this.
........
r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines
Clarify documentation for bf_getcharbuffer.
........
r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line
Fix a refleak in recvfrom_into
........
r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines
- bsddb: the bsddb.dbtables Modify method now raises the proper error and
aborts the db transaction safely when a modifier callback fails.
Fixes SF python patch/bug #1408584.
Also cleans up the bsddb.dbtables docstrings since thats the only
documentation that exists for that unadvertised module. (people
really should really just use sqlite3)
........
r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines
* Turn the deadlock situation described in SF bug #775414 into a
DBDeadLockError exception.
* add the test case for my previous dbtables commit.
........
r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines
pasted set_lk_detect line in wrong spot in previous commit. fixed. passes tests this time.
........
r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines
(arre, arigo) SF bug #1350060
Give a consistent behavior for comparison and hashing of method objects
(both user- and built-in methods). Now compares the 'self' recursively.
The hash was already asking for the hash of 'self'.
........
r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line
Typo fix
........
r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines
Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking.
........
r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines
Bug #1502728: Correctly link against librt library on HP-UX.
........
r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines
Add news for recent bugfix.
........
r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines
Argh. "integer" is a very confusing word ;)
Actually, checking for INT_MAX and INT_MIN is correct since
the format code explicitly handles a C "int".
........
r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line
Add functools.update_wrapper() and functools.wraps() as described in PEP 356
........
r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines
Bug #1502805: don't alias file.__exit__ to file.close since the
latter can return something that's true.
........
r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines
Convert test_file to unittest.
........
2006-06-08 12:35:45 -03:00
|
|
|
static long
|
|
|
|
wrapper_hash(wrapperobject *wp)
|
|
|
|
{
|
|
|
|
int x, y;
|
|
|
|
x = _Py_HashPointer(wp->descr);
|
|
|
|
if (x == -1)
|
|
|
|
return -1;
|
|
|
|
y = PyObject_Hash(wp->self);
|
|
|
|
if (y == -1)
|
|
|
|
return -1;
|
|
|
|
x = x ^ y;
|
|
|
|
if (x == -1)
|
|
|
|
x = -2;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2005-11-07 04:38:00 -04:00
|
|
|
static PyObject *
|
|
|
|
wrapper_repr(wrapperobject *wp)
|
|
|
|
{
|
|
|
|
return PyString_FromFormat("<method-wrapper '%s' of %s object at %p>",
|
|
|
|
wp->descr->d_base->name,
|
|
|
|
wp->self->ob_type->tp_name,
|
|
|
|
wp->self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMemberDef wrapper_members[] = {
|
|
|
|
{"__self__", T_OBJECT, offsetof(wrapperobject, self), READONLY},
|
2001-08-02 01:15:00 -03:00
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
2005-11-07 04:38:00 -04:00
|
|
|
static PyObject *
|
|
|
|
wrapper_objclass(wrapperobject *wp)
|
|
|
|
{
|
|
|
|
PyObject *c = (PyObject *)wp->descr->d_type;
|
|
|
|
|
|
|
|
Py_INCREF(c);
|
|
|
|
return c;
|
|
|
|
}
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyObject *
|
|
|
|
wrapper_name(wrapperobject *wp)
|
|
|
|
{
|
|
|
|
char *s = wp->descr->d_base->name;
|
|
|
|
|
|
|
|
return PyString_FromString(s);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
wrapper_doc(wrapperobject *wp)
|
|
|
|
{
|
|
|
|
char *s = wp->descr->d_base->doc;
|
|
|
|
|
|
|
|
if (s == NULL) {
|
|
|
|
Py_INCREF(Py_None);
|
|
|
|
return Py_None;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return PyString_FromString(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-09-20 18:45:26 -03:00
|
|
|
static PyGetSetDef wrapper_getsets[] = {
|
2005-11-07 04:38:00 -04:00
|
|
|
{"__objclass__", (getter)wrapper_objclass},
|
2001-08-02 01:15:00 -03:00
|
|
|
{"__name__", (getter)wrapper_name},
|
|
|
|
{"__doc__", (getter)wrapper_doc},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
wrapper_call(wrapperobject *wp, PyObject *args, PyObject *kwds)
|
|
|
|
{
|
|
|
|
wrapperfunc wrapper = wp->descr->d_base->wrapper;
|
|
|
|
PyObject *self = wp->self;
|
|
|
|
|
2001-10-21 21:43:43 -03:00
|
|
|
if (wp->descr->d_base->flags & PyWrapperFlag_KEYWORDS) {
|
|
|
|
wrapperfunc_kwds wk = (wrapperfunc_kwds)wrapper;
|
|
|
|
return (*wk)(self, args, wp->descr->d_wrapped, kwds);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kwds != NULL && (!PyDict_Check(kwds) || PyDict_Size(kwds) != 0)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"wrapper %s doesn't take keyword arguments",
|
|
|
|
wp->descr->d_base->name);
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-08-02 01:15:00 -03:00
|
|
|
return (*wrapper)(self, args, wp->descr->d_wrapped);
|
|
|
|
}
|
|
|
|
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
static int
|
|
|
|
wrapper_traverse(PyObject *self, visitproc visit, void *arg)
|
|
|
|
{
|
|
|
|
wrapperobject *wp = (wrapperobject *)self;
|
2006-04-21 07:40:58 -03:00
|
|
|
Py_VISIT(wp->descr);
|
|
|
|
Py_VISIT(wp->self);
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-10-21 19:26:43 -03:00
|
|
|
static PyTypeObject wrappertype = {
|
2001-08-02 01:15:00 -03:00
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
0, /* ob_size */
|
|
|
|
"method-wrapper", /* tp_name */
|
|
|
|
sizeof(wrapperobject), /* tp_basicsize */
|
|
|
|
0, /* tp_itemsize */
|
|
|
|
/* methods */
|
|
|
|
(destructor)wrapper_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2005-11-07 04:38:00 -04:00
|
|
|
(cmpfunc)wrapper_compare, /* tp_compare */
|
|
|
|
(reprfunc)wrapper_repr, /* tp_repr */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
Merge the rest of the trunk.
Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines
Updated version (win32-icons2.zip) from #1490384.
........
r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1472084] Fix description of do_tag
........
r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1475554] Strengthen text to say 'must' instead of 'should'
........
r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1441864] Clarify description of 'data' argument
........
r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line
Minor rewording
........
r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines
[Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler.
Fix by renaming the variable.
In a different module, Neal fixed it by renaming _self to self. There's
already a variable named 'self' here, so I used selfptr.
(I'm committing this on a Mac without Tk, but it's a simple search-and-replace.
<crosses fingers>, so I'll watch the buildbots and see what happens.)
........
r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines
"_self" is a said to be a reserved word in Watcom C 10.6. I'm
not sure that's really standard compliant behaviour, but I guess
we have to fix that anyway...
........
r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line
Update readme
........
r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line
Drop 0 parameter
........
r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line
Some code tidying; use curses.wrapper
........
r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line
Use True; value returned from main is unused
........
r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line
Use true division, and the True value
........
r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line
Docstring fix; use True
........
r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line
Put code in a main() function; loosen up the spacing to match current code style
........
r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line
Use functions; modernize code
........
r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line
This demo requires Medusa (not just asyncore); remove it
........
r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines
Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module.
........
r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line
Remove xmlrpc/ directory
........
r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line
Remove dangling reference
........
r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line
Add more whitespace; use a better socket name
........
r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines
Whitespace normalization.
........
r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines
In a PYMALLOC_DEBUG build obmalloc adds extra debugging info
to each allocated block. This was using 4 bytes for each such
piece of info regardless of platform. This didn't really matter
before (proof: no bug reports, and the debug-build obmalloc would
have assert-failed if it was ever asked for a chunk of memory
>= 2**32 bytes), since container indices were plain ints. But after
the Py_ssize_t changes, it's at least theoretically possible to
allocate a list or string whose guts exceed 2**32 bytes, and the
PYMALLOC_DEBUG routines would fail then (having only 4 bytes
to record the originally requested size).
Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG
build's extra debugging fields. This won't make any difference
on 32-bit boxes, but will add 16 bytes to each allocation in
a debug build on a 64-bit box.
........
r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines
_PyObject_DebugMalloc(): The return value should add
2*sizeof(size_t) now, not 8. This probably accounts for
current disasters on the 64-bit buildbot slaves.
........
r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line
SF #1499797, Fix for memory leak in WindowsError_str
........
r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines
Patch #1454481: Make thread stack size runtime tunable.
........
r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines
clean up function declarations to conform to PEP-7 style.
........
r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines
Fixes in struct and socket from merge reviews.
- Following Guido's comments, renamed
* pack_to -> pack_into
* recv_buf -> recv_into
* recvfrom_buf -> recvfrom_into
- Made fixes to _struct.c according to Neal Norwitz comments on the checkins
list.
- Converted some ints into the appropriate -- I hope -- ssize_t and size_t.
........
r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines
"Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with
the right compiler flags.
........
r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines
Drop Mac wrappers for the WASTE library.
........
r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines
s_methods[]: Stop compiler warnings by casting
s_unpack_from to PyCFunction.
........
r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines
Remove a redundant word
........
r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines
Markup fix
........
r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines
Patch #1359618: Speed-up charmap encoder.
........
r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines
Repair refleaks in unicodeobject.
........
r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines
Patch #1346214: correctly optimize away "if 0"-style stmts
(thanks to Neal for review)
........
r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines
Bug #1500293: fix memory leaks in _subprocess module.
........
r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines
Revert revisions:
46640 Patch #1454481: Make thread stack size runtime tunable.
46647 Markup fix
The first is causing many buildbots to fail test runs, and there
are multiple causes with seemingly no immediate prospects for
repairing them. See python-dev discussion.
Note that a branch can (and should) be created for resolving these
problems, like
svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH
followed by merging rev 46647 to the new branch.
........
r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line
Mention second encoding speedup
........
r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines
bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present
in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized
char **log_list.
feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2.
........
r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines
fix a bug in the previous commit. don't leak empty list on error return and
fix the additional rare (out of memory only) bug that it was supposed to fix
of not freeing log_list when the python allocator failed.
........
r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines
"Flat is better than nested."
Move the long-winded, multiply-nested -R support out
of runtest() and into some module-level helper functions.
This makes runtest() and the -R code easier to follow.
That in turn allowed seeing some opportunities for code
simplification, and made it obvious that reglog.txt
never got closed.
........
r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines
Fix a potentially invalid memory access of CJKCodecs' shift-jis
decoder. (found by Neal Norwitz)
........
r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines
* support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885]
........
r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines
Remove doctest.testmod's deprecated (in 2.4) `isprivate`
argument. A lot of hair went into supporting that!
........
r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines
Make doctest news more accurate.
........
r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines
* support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902]
........
r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines
mention the just committed bsddb changes
........
r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines
* add support for DBSequence objects [patch #1466734]
........
r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines
forgot to add this file in previous commit
........
r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines
* fix DBCursor.pget() bug with keyword argument names when no data= is
supplied [SF pybsddb bug #1477863]
........
r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line
Remove use of Trove name, which isn't very helpful to users
........
r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line
[Bug #1470026] Include link to list of classifiers
........
r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines
Access _struct attributes directly instead of mucking with getattr.
string_reverse(): Simplify.
assertRaises(): Raise TestFailed on failure.
test_unpack_from(), test_pack_into(), test_pack_into_fn(): never
use `assert` to test for an expected result (it doesn't test anything
when Python is run with -O).
........
r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines
add depends = ['md5.h'] to the _md5 module extension for correctness sake.
........
r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines
Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int.
Closes bug #1501223.
........
r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines
- bsddb: the __len__ method of a DB object has been fixed to return correct
results. It could previously incorrectly return 0 in some cases.
Fixes SF bug 1493322 (pybsddb bug 1184012).
........
r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines
_PySys_Init(): It's rarely a good idea to size a buffer to the
exact maximum size someone guesses is needed. In this case, if
we're really worried about extreme integers, then "cp%d" can
actually need 14 bytes (2 for "cp" + 1 for \0 at the end +
11 for -(2**31-1)). So reserve 128 bytes instead -- nothing is
actually saved by making a stack-local buffer tiny.
........
r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line
Remove unused variable (and stop compiler warning)
........
r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line
Fix a bunch of parameter strings
........
r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines
Convert CFieldObject tp_members to tp_getset, since there is no
structmember typecode for Py_ssize_t fields. This should fix some of
the errors on the PPC64 debian machine (64-bit, big endian).
Assigning to readonly fields now raises AttributeError instead of
TypeError, so the testcase has to be changed as well.
........
r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line
Damn - the sentinel was missing. And fix another silly mistake.
........
r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines
Normalized a few cases of whitespace in function declarations.
Found them using::
find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done
find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done
(I was doing this all over my own code anyway, because I'd been using spaces in
all defs, so I thought I'd make a run on the Python code as well. If you need
to do such fixes in your own code, you can use xx-rename or parenregu.el within
emacs.)
........
r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line
Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures
........
r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines
BSequence_set_range(): Rev 46688 ("Fix a bunch of
parameter strings") changed this function's signature
seemingly by mistake, which is causing buildbots to fail
test_bsddb3. Restored the pre-46688 signature.
........
r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines
On python-dev Thomas Heller said these were committed
by mistake in rev 46693, so reverting this part of
rev 46693.
........
r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line
Fix comment typo
........
r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines
Fix coding style guide bug.
........
r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines
Add a hack so that foreign functions returning float now do work on 64-bit
big endian platforms.
........
r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines
Use the same big-endian hack as in _ctypes/callproc.c for callback functions.
This fixes the callback function tests that return float.
........
r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines
* Ensure that "make altinstall" works when the tree was configured
with --enable-framework
* Also for --enable-framework: allow users to use --prefix to specify
the location of the compatibility symlinks (such as /usr/local/bin/python)
........
r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines
A quick hack to ensure the right key-bindings for IDLE on osx: install patched
configuration files during a framework install.
........
r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines
dash_R_cleanup(): Clear filecmp._cache. This accounts for
different results across -R runs (at least on Windows) of
test_filecmp.
........
r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines
SF patch 1501987: Remove randomness from test_exceptions,
from ?iga Seilnacht (sorry about the name, but Firefox
on my box can't display the first character of the name --
the SF "Unix name" is zseil).
This appears to cure the oddball intermittent leaks across
runs when running test_exceptions under -R. I'm not sure
why, but I'm too sleepy to care ;-)
The thrust of the SF patch was to remove randomness in the
pickle protocol used. I changed the patch to use
range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and
cPickle, and randomly mucked with other test lines to put
statements on their own lines.
Not a bugfix candidate (this is fiddling new-in-2.5 code).
........
r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line
Add an SQLite introduction, taken from the 'What's New' text
........
r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line
Mention other placeholders
........
r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line
Add an item; also, escape %
........
r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line
Mention other placeholders
........
r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/Tools one level up
........
r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/PythonLauncher one level up
........
r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines
mv Mac/OSX/BuildScript one level up
........
r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/* one level up
........
r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines
And the last bit: move IDLE one level up and adjust makefiles
........
r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines
- Patch the correct version of python in the Info.plists at build time, instead
of relying on a maintainer to update them before releases.
- Remove the now empty Mac/OSX directory
........
r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines
* If BuildApplet.py is used as an applet it starts with a version of
sys.exutable that isn't usuable on an #!-line. That results in generated
applets that don't actually work. Work around this problem by resetting
sys.executable.
* argvemulator.py didn't work on intel macs. This patch fixes this
(bug #1491468)
........
r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines
Whitespace normalization.
........
r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines
Fix for foreign functions returning small structures on 64-bit big
endian machines. Should fix the remaininf failure in the PPC64
Debian buildbot.
Thanks to Matthias Klose for providing access to a machine to debug
and test this.
........
r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines
Clarify documentation for bf_getcharbuffer.
........
r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line
Fix a refleak in recvfrom_into
........
r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines
- bsddb: the bsddb.dbtables Modify method now raises the proper error and
aborts the db transaction safely when a modifier callback fails.
Fixes SF python patch/bug #1408584.
Also cleans up the bsddb.dbtables docstrings since thats the only
documentation that exists for that unadvertised module. (people
really should really just use sqlite3)
........
r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines
* Turn the deadlock situation described in SF bug #775414 into a
DBDeadLockError exception.
* add the test case for my previous dbtables commit.
........
r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines
pasted set_lk_detect line in wrong spot in previous commit. fixed. passes tests this time.
........
r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines
(arre, arigo) SF bug #1350060
Give a consistent behavior for comparison and hashing of method objects
(both user- and built-in methods). Now compares the 'self' recursively.
The hash was already asking for the hash of 'self'.
........
r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line
Typo fix
........
r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines
Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking.
........
r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines
Bug #1502728: Correctly link against librt library on HP-UX.
........
r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines
Add news for recent bugfix.
........
r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines
Argh. "integer" is a very confusing word ;)
Actually, checking for INT_MAX and INT_MIN is correct since
the format code explicitly handles a C "int".
........
r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line
Add functools.update_wrapper() and functools.wraps() as described in PEP 356
........
r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines
Bug #1502805: don't alias file.__exit__ to file.close since the
latter can return something that's true.
........
r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines
Convert test_file to unittest.
........
2006-06-08 12:35:45 -03:00
|
|
|
(hashfunc)wrapper_hash, /* tp_hash */
|
2001-08-02 01:15:00 -03:00
|
|
|
(ternaryfunc)wrapper_call, /* tp_call */
|
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_doc */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
wrapper_traverse, /* tp_traverse */
|
2001-08-02 01:15:00 -03:00
|
|
|
0, /* tp_clear */
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
2005-11-07 04:38:00 -04:00
|
|
|
0, /* tp_methods */
|
|
|
|
wrapper_members, /* tp_members */
|
2001-08-02 01:15:00 -03:00
|
|
|
wrapper_getsets, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
};
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyWrapper_New(PyObject *d, PyObject *self)
|
|
|
|
{
|
|
|
|
wrapperobject *wp;
|
|
|
|
PyWrapperDescrObject *descr;
|
|
|
|
|
|
|
|
assert(PyObject_TypeCheck(d, &PyWrapperDescr_Type));
|
|
|
|
descr = (PyWrapperDescrObject *)d;
|
|
|
|
assert(PyObject_IsInstance(self, (PyObject *)(descr->d_type)));
|
|
|
|
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
wp = PyObject_GC_New(wrapperobject, &wrappertype);
|
2001-08-02 01:15:00 -03:00
|
|
|
if (wp != NULL) {
|
|
|
|
Py_INCREF(descr);
|
|
|
|
wp->descr = descr;
|
|
|
|
Py_INCREF(self);
|
|
|
|
wp->self = self;
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
_PyObject_GC_TRACK(wp);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
return (PyObject *)wp;
|
|
|
|
}
|
2001-08-23 18:40:38 -03:00
|
|
|
|
|
|
|
|
2001-09-06 18:56:42 -03:00
|
|
|
/* A built-in 'property' type */
|
2001-08-23 18:40:38 -03:00
|
|
|
|
|
|
|
/*
|
2001-09-06 18:56:42 -03:00
|
|
|
class property(object):
|
2001-08-23 18:40:38 -03:00
|
|
|
|
2001-12-10 14:03:34 -04:00
|
|
|
def __init__(self, fget=None, fset=None, fdel=None, doc=None):
|
2006-03-08 14:09:27 -04:00
|
|
|
if doc is None and fget is not None and hasattr(fget, "__doc__"):
|
|
|
|
doc = fget.__doc__
|
2001-12-10 14:03:34 -04:00
|
|
|
self.__get = fget
|
|
|
|
self.__set = fset
|
|
|
|
self.__del = fdel
|
|
|
|
self.__doc__ = doc
|
|
|
|
|
|
|
|
def __get__(self, inst, type=None):
|
|
|
|
if inst is None:
|
|
|
|
return self
|
2001-12-10 14:06:21 -04:00
|
|
|
if self.__get is None:
|
|
|
|
raise AttributeError, "unreadable attribute"
|
2001-12-10 14:03:34 -04:00
|
|
|
return self.__get(inst)
|
|
|
|
|
|
|
|
def __set__(self, inst, value):
|
|
|
|
if self.__set is None:
|
|
|
|
raise AttributeError, "can't set attribute"
|
|
|
|
return self.__set(inst, value)
|
|
|
|
|
|
|
|
def __delete__(self, inst):
|
|
|
|
if self.__del is None:
|
|
|
|
raise AttributeError, "can't delete attribute"
|
|
|
|
return self.__del(inst)
|
|
|
|
|
2001-08-23 18:40:38 -03:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
PyObject_HEAD
|
2001-09-24 18:17:50 -03:00
|
|
|
PyObject *prop_get;
|
|
|
|
PyObject *prop_set;
|
|
|
|
PyObject *prop_del;
|
|
|
|
PyObject *prop_doc;
|
2001-09-06 18:56:42 -03:00
|
|
|
} propertyobject;
|
2001-08-23 18:40:38 -03:00
|
|
|
|
2001-09-24 18:17:50 -03:00
|
|
|
static PyMemberDef property_members[] = {
|
|
|
|
{"fget", T_OBJECT, offsetof(propertyobject, prop_get), READONLY},
|
|
|
|
{"fset", T_OBJECT, offsetof(propertyobject, prop_set), READONLY},
|
|
|
|
{"fdel", T_OBJECT, offsetof(propertyobject, prop_del), READONLY},
|
|
|
|
{"__doc__", T_OBJECT, offsetof(propertyobject, prop_doc), READONLY},
|
|
|
|
{0}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-08-23 18:40:38 -03:00
|
|
|
static void
|
2001-09-06 18:56:42 -03:00
|
|
|
property_dealloc(PyObject *self)
|
2001-08-23 18:40:38 -03:00
|
|
|
{
|
2001-09-06 18:56:42 -03:00
|
|
|
propertyobject *gs = (propertyobject *)self;
|
2001-08-23 18:40:38 -03:00
|
|
|
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
_PyObject_GC_UNTRACK(self);
|
2001-09-24 18:17:50 -03:00
|
|
|
Py_XDECREF(gs->prop_get);
|
|
|
|
Py_XDECREF(gs->prop_set);
|
|
|
|
Py_XDECREF(gs->prop_del);
|
|
|
|
Py_XDECREF(gs->prop_doc);
|
2001-08-23 18:40:38 -03:00
|
|
|
self->ob_type->tp_free(self);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2001-09-06 18:56:42 -03:00
|
|
|
property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
2001-08-23 18:40:38 -03:00
|
|
|
{
|
2001-09-06 18:56:42 -03:00
|
|
|
propertyobject *gs = (propertyobject *)self;
|
2001-08-23 18:40:38 -03:00
|
|
|
|
|
|
|
if (obj == NULL || obj == Py_None) {
|
|
|
|
Py_INCREF(self);
|
|
|
|
return self;
|
|
|
|
}
|
2001-12-10 14:00:15 -04:00
|
|
|
if (gs->prop_get == NULL) {
|
|
|
|
PyErr_SetString(PyExc_AttributeError, "unreadable attribute");
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-09-24 18:17:50 -03:00
|
|
|
return PyObject_CallFunction(gs->prop_get, "(O)", obj);
|
2001-08-23 18:40:38 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-09-06 18:56:42 -03:00
|
|
|
property_descr_set(PyObject *self, PyObject *obj, PyObject *value)
|
2001-08-23 18:40:38 -03:00
|
|
|
{
|
2001-09-06 18:56:42 -03:00
|
|
|
propertyobject *gs = (propertyobject *)self;
|
2001-08-24 12:23:20 -03:00
|
|
|
PyObject *func, *res;
|
2001-08-23 18:40:38 -03:00
|
|
|
|
2001-08-24 12:23:20 -03:00
|
|
|
if (value == NULL)
|
2001-09-24 18:17:50 -03:00
|
|
|
func = gs->prop_del;
|
2001-08-24 12:23:20 -03:00
|
|
|
else
|
2001-09-24 18:17:50 -03:00
|
|
|
func = gs->prop_set;
|
2001-08-24 12:23:20 -03:00
|
|
|
if (func == NULL) {
|
|
|
|
PyErr_SetString(PyExc_AttributeError,
|
|
|
|
value == NULL ?
|
|
|
|
"can't delete attribute" :
|
|
|
|
"can't set attribute");
|
2001-08-23 18:40:38 -03:00
|
|
|
return -1;
|
|
|
|
}
|
2001-08-24 07:17:36 -03:00
|
|
|
if (value == NULL)
|
2001-08-24 12:23:20 -03:00
|
|
|
res = PyObject_CallFunction(func, "(O)", obj);
|
2001-08-24 07:17:36 -03:00
|
|
|
else
|
2001-08-24 12:23:20 -03:00
|
|
|
res = PyObject_CallFunction(func, "(OO)", obj, value);
|
2001-08-23 18:40:38 -03:00
|
|
|
if (res == NULL)
|
|
|
|
return -1;
|
|
|
|
Py_DECREF(res);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-09-06 18:56:42 -03:00
|
|
|
property_init(PyObject *self, PyObject *args, PyObject *kwds)
|
2001-08-23 18:40:38 -03:00
|
|
|
{
|
2001-09-24 18:17:50 -03:00
|
|
|
PyObject *get = NULL, *set = NULL, *del = NULL, *doc = NULL;
|
2006-03-08 14:09:27 -04:00
|
|
|
PyObject *get_doc = NULL;
|
2006-02-27 12:46:16 -04:00
|
|
|
static char *kwlist[] = {"fget", "fset", "fdel", "doc", 0};
|
2001-09-06 18:56:42 -03:00
|
|
|
propertyobject *gs = (propertyobject *)self;
|
2001-08-23 18:40:38 -03:00
|
|
|
|
2001-09-24 18:17:50 -03:00
|
|
|
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|OOOO:property",
|
|
|
|
kwlist, &get, &set, &del, &doc))
|
2001-08-23 18:40:38 -03:00
|
|
|
return -1;
|
2001-09-24 18:17:50 -03:00
|
|
|
|
2001-08-23 18:40:38 -03:00
|
|
|
if (get == Py_None)
|
|
|
|
get = NULL;
|
|
|
|
if (set == Py_None)
|
|
|
|
set = NULL;
|
2001-09-24 18:17:50 -03:00
|
|
|
if (del == Py_None)
|
|
|
|
del = NULL;
|
|
|
|
|
2006-03-08 14:09:27 -04:00
|
|
|
/* if no docstring given and the getter has one, use that one */
|
|
|
|
if ((doc == NULL || doc == Py_None) && get != NULL &&
|
|
|
|
PyObject_HasAttrString(get, "__doc__")) {
|
|
|
|
if (!(get_doc = PyObject_GetAttrString(get, "__doc__")))
|
|
|
|
return -1;
|
|
|
|
Py_DECREF(get_doc); /* it is INCREF'd again below */
|
|
|
|
doc = get_doc;
|
|
|
|
}
|
|
|
|
|
2001-08-23 18:40:38 -03:00
|
|
|
Py_XINCREF(get);
|
|
|
|
Py_XINCREF(set);
|
2001-08-24 12:23:20 -03:00
|
|
|
Py_XINCREF(del);
|
2001-09-24 18:17:50 -03:00
|
|
|
Py_XINCREF(doc);
|
|
|
|
|
|
|
|
gs->prop_get = get;
|
|
|
|
gs->prop_set = set;
|
|
|
|
gs->prop_del = del;
|
|
|
|
gs->prop_doc = doc;
|
|
|
|
|
2001-08-23 18:40:38 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2002-06-13 17:33:02 -03:00
|
|
|
PyDoc_STRVAR(property_doc,
|
2001-09-24 18:17:50 -03:00
|
|
|
"property(fget=None, fset=None, fdel=None, doc=None) -> property attribute\n"
|
|
|
|
"\n"
|
|
|
|
"fget is a function to be used for getting an attribute value, and likewise\n"
|
|
|
|
"fset is a function for setting, and fdel a function for del'ing, an\n"
|
|
|
|
"attribute. Typical use is to define a managed attribute x:\n"
|
2001-08-24 06:55:51 -03:00
|
|
|
"class C(object):\n"
|
|
|
|
" def getx(self): return self.__x\n"
|
|
|
|
" def setx(self, value): self.__x = value\n"
|
2001-08-24 12:23:20 -03:00
|
|
|
" def delx(self): del self.__x\n"
|
2002-06-13 17:33:02 -03:00
|
|
|
" x = property(getx, setx, delx, \"I'm the 'x' property.\")");
|
2001-08-24 06:55:51 -03:00
|
|
|
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
static int
|
|
|
|
property_traverse(PyObject *self, visitproc visit, void *arg)
|
|
|
|
{
|
|
|
|
propertyobject *pp = (propertyobject *)self;
|
2006-04-21 07:40:58 -03:00
|
|
|
Py_VISIT(pp->prop_get);
|
|
|
|
Py_VISIT(pp->prop_set);
|
|
|
|
Py_VISIT(pp->prop_del);
|
|
|
|
Py_VISIT(pp->prop_doc);
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2001-09-06 18:56:42 -03:00
|
|
|
PyTypeObject PyProperty_Type = {
|
2001-08-23 18:40:38 -03:00
|
|
|
PyObject_HEAD_INIT(&PyType_Type)
|
|
|
|
0, /* ob_size */
|
2001-09-06 18:56:42 -03:00
|
|
|
"property", /* tp_name */
|
|
|
|
sizeof(propertyobject), /* tp_basicsize */
|
2001-08-23 18:40:38 -03:00
|
|
|
0, /* tp_itemsize */
|
|
|
|
/* methods */
|
2001-09-06 18:56:42 -03:00
|
|
|
property_dealloc, /* tp_dealloc */
|
2001-08-23 18:40:38 -03:00
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_compare */
|
|
|
|
0, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
|
|
|
0, /* tp_call */
|
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
|
|
|
Py_TPFLAGS_BASETYPE, /* tp_flags */
|
2001-09-06 18:56:42 -03:00
|
|
|
property_doc, /* tp_doc */
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
property_traverse, /* tp_traverse */
|
2001-08-23 18:40:38 -03:00
|
|
|
0, /* tp_clear */
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
0, /* tp_methods */
|
2001-09-24 18:17:50 -03:00
|
|
|
property_members, /* tp_members */
|
2001-08-23 18:40:38 -03:00
|
|
|
0, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
2001-09-06 18:56:42 -03:00
|
|
|
property_descr_get, /* tp_descr_get */
|
|
|
|
property_descr_set, /* tp_descr_set */
|
2001-08-23 18:40:38 -03:00
|
|
|
0, /* tp_dictoffset */
|
2001-09-06 18:56:42 -03:00
|
|
|
property_init, /* tp_init */
|
2001-08-23 18:40:38 -03:00
|
|
|
PyType_GenericAlloc, /* tp_alloc */
|
|
|
|
PyType_GenericNew, /* tp_new */
|
2002-04-11 23:44:22 -03:00
|
|
|
PyObject_GC_Del, /* tp_free */
|
2001-08-23 18:40:38 -03:00
|
|
|
};
|