2001-08-02 04:15:00 +00:00
|
|
|
/* Descriptors -- a new, flexible way to describe attributes */
|
|
|
|
|
|
|
|
#include "Python.h"
|
|
|
|
#include "structmember.h" /* Why is this not included in Python.h? */
|
|
|
|
|
2017-03-19 06:51:07 +00:00
|
|
|
/*[clinic input]
|
|
|
|
class mappingproxy "mappingproxyobject *" "&PyDictProxy_Type"
|
|
|
|
class property "propertyobject *" "&PyProperty_Type"
|
|
|
|
[clinic start generated code]*/
|
|
|
|
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=556352653fd4c02e]*/
|
|
|
|
|
2001-08-02 04:15:00 +00:00
|
|
|
static void
|
|
|
|
descr_dealloc(PyDescrObject *descr)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
_PyObject_GC_UNTRACK(descr);
|
|
|
|
Py_XDECREF(descr->d_type);
|
|
|
|
Py_XDECREF(descr->d_name);
|
2011-12-12 12:47:25 +00:00
|
|
|
Py_XDECREF(descr->d_qualname);
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject_GC_Del(descr);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2007-06-11 16:36:59 +00:00
|
|
|
static PyObject *
|
2001-08-02 04:15:00 +00:00
|
|
|
descr_name(PyDescrObject *descr)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
if (descr->d_name != NULL && PyUnicode_Check(descr->d_name))
|
|
|
|
return descr->d_name;
|
|
|
|
return NULL;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2015-12-25 18:01:53 +00:00
|
|
|
descr_repr(PyDescrObject *descr, const char *format)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *name = NULL;
|
|
|
|
if (descr->d_name != NULL && PyUnicode_Check(descr->d_name))
|
|
|
|
name = descr->d_name;
|
2007-06-11 16:36:59 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
return PyUnicode_FromFormat(format, name, "?", descr->d_type->tp_name);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
method_repr(PyMethodDescrObject *descr)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
return descr_repr((PyDescrObject *)descr,
|
|
|
|
"<method '%V' of '%s' objects>");
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
member_repr(PyMemberDescrObject *descr)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
return descr_repr((PyDescrObject *)descr,
|
|
|
|
"<member '%V' of '%s' objects>");
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
getset_repr(PyGetSetDescrObject *descr)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
return descr_repr((PyDescrObject *)descr,
|
|
|
|
"<attribute '%V' of '%s' objects>");
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2005-11-07 08:38:00 +00:00
|
|
|
wrapperdescr_repr(PyWrapperDescrObject *descr)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
return descr_repr((PyDescrObject *)descr,
|
|
|
|
"<slot wrapper '%V' of '%s' objects>");
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2003-02-11 18:44:42 +00:00
|
|
|
descr_check(PyDescrObject *descr, PyObject *obj, PyObject **pres)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
if (obj == NULL) {
|
|
|
|
Py_INCREF(descr);
|
|
|
|
*pres = (PyObject *)descr;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (!PyObject_TypeCheck(obj, descr->d_type)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' for '%s' objects "
|
|
|
|
"doesn't apply to '%s' object",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
descr->d_type->tp_name,
|
|
|
|
obj->ob_type->tp_name);
|
|
|
|
*pres = NULL;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2002-12-09 22:56:13 +00:00
|
|
|
static PyObject *
|
2003-02-11 18:44:42 +00:00
|
|
|
classmethod_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type)
|
2002-12-09 22:56:13 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00: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 '%V' for type '%s' "
|
|
|
|
"needs either an object or a type",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!PyType_Check(type)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' for type '%s' "
|
|
|
|
"needs a type, not a '%s' as arg 2",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name,
|
|
|
|
type->ob_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!PyType_IsSubtype((PyTypeObject *)type, PyDescr_TYPE(descr))) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' for type '%s' "
|
|
|
|
"doesn't apply to type '%s'",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name,
|
|
|
|
((PyTypeObject *)type)->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
2012-12-25 11:32:35 +00:00
|
|
|
return PyCFunction_NewEx(descr->d_method, type, NULL);
|
2002-12-09 22:56:13 +00:00
|
|
|
}
|
|
|
|
|
2001-08-02 04:15:00 +00:00
|
|
|
static PyObject *
|
2003-02-11 18:44:42 +00:00
|
|
|
method_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *res;
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (descr_check((PyDescrObject *)descr, obj, &res))
|
|
|
|
return res;
|
2012-12-25 11:32:35 +00:00
|
|
|
return PyCFunction_NewEx(descr->d_method, obj, NULL);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2003-02-11 18:44:42 +00:00
|
|
|
member_get(PyMemberDescrObject *descr, PyObject *obj, PyObject *type)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *res;
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (descr_check((PyDescrObject *)descr, obj, &res))
|
|
|
|
return res;
|
|
|
|
return PyMember_GetOne((char *)obj, descr->d_member);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2003-02-11 18:44:42 +00:00
|
|
|
getset_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *type)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *res;
|
|
|
|
|
|
|
|
if (descr_check((PyDescrObject *)descr, obj, &res))
|
|
|
|
return res;
|
|
|
|
if (descr->d_getset->get != NULL)
|
|
|
|
return descr->d_getset->get(obj, descr->d_getset->closure);
|
|
|
|
PyErr_Format(PyExc_AttributeError,
|
|
|
|
"attribute '%V' of '%.100s' objects is not readable",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name);
|
|
|
|
return NULL;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2005-11-07 08:38:00 +00:00
|
|
|
wrapperdescr_get(PyWrapperDescrObject *descr, PyObject *obj, PyObject *type)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *res;
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (descr_check((PyDescrObject *)descr, obj, &res))
|
|
|
|
return res;
|
|
|
|
return PyWrapper_New((PyObject *)descr, obj);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
descr_setcheck(PyDescrObject *descr, PyObject *obj, PyObject *value,
|
2010-05-09 15:52:27 +00:00
|
|
|
int *pres)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
assert(obj != NULL);
|
|
|
|
if (!PyObject_TypeCheck(obj, descr->d_type)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' 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;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
member_set(PyMemberDescrObject *descr, PyObject *obj, PyObject *value)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
int res;
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (descr_setcheck((PyDescrObject *)descr, obj, value, &res))
|
|
|
|
return res;
|
|
|
|
return PyMember_SetOne((char *)obj, descr->d_member, value);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
getset_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
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);
|
|
|
|
PyErr_Format(PyExc_AttributeError,
|
|
|
|
"attribute '%V' of '%.100s' objects is not writable",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name);
|
|
|
|
return -1;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2017-01-18 09:38:09 +00:00
|
|
|
methoddescr_call(PyMethodDescrObject *descr, PyObject *args, PyObject *kwargs)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2017-01-18 09:38:09 +00:00
|
|
|
Py_ssize_t nargs;
|
|
|
|
PyObject *self, *result;
|
2010-05-09 15:52:27 +00:00
|
|
|
|
|
|
|
/* Make sure that the first argument is acceptable as 'self' */
|
|
|
|
assert(PyTuple_Check(args));
|
2017-01-18 09:38:09 +00:00
|
|
|
nargs = PyTuple_GET_SIZE(args);
|
|
|
|
if (nargs < 1) {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' of '%.100s' "
|
|
|
|
"object needs an argument",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
self = PyTuple_GET_ITEM(args, 0);
|
2011-05-01 21:19:15 +00:00
|
|
|
if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
|
2011-05-01 21:31:36 +00:00
|
|
|
(PyObject *)PyDescr_TYPE(descr))) {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' "
|
|
|
|
"requires a '%.100s' object "
|
|
|
|
"but received a '%.100s'",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name,
|
|
|
|
self->ob_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-01-18 09:38:09 +00:00
|
|
|
result = _PyMethodDef_RawFastCallDict(descr->d_method, self,
|
|
|
|
&PyTuple_GET_ITEM(args, 1), nargs - 1,
|
|
|
|
kwargs);
|
|
|
|
result = _Py_CheckFunctionResult((PyObject *)descr, result, NULL);
|
2010-05-09 15:52:27 +00:00
|
|
|
return result;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2017-02-02 22:43:03 +00:00
|
|
|
// same to methoddescr_call(), but use FASTCALL convention.
|
|
|
|
PyObject *
|
|
|
|
_PyMethodDescr_FastCallKeywords(PyObject *descrobj,
|
|
|
|
PyObject **args, Py_ssize_t nargs,
|
|
|
|
PyObject *kwnames)
|
|
|
|
{
|
|
|
|
assert(Py_TYPE(descrobj) == &PyMethodDescr_Type);
|
|
|
|
PyMethodDescrObject *descr = (PyMethodDescrObject *)descrobj;
|
|
|
|
PyObject *self, *result;
|
|
|
|
|
|
|
|
/* Make sure that the first argument is acceptable as 'self' */
|
|
|
|
if (nargs < 1) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' of '%.100s' "
|
|
|
|
"object needs an argument",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
self = args[0];
|
|
|
|
if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
|
|
|
|
(PyObject *)PyDescr_TYPE(descr))) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' "
|
|
|
|
"requires a '%.100s' object "
|
|
|
|
"but received a '%.100s'",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name,
|
|
|
|
self->ob_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = _PyMethodDef_RawFastCallKeywords(descr->d_method, self,
|
|
|
|
args+1, nargs-1, kwnames);
|
|
|
|
result = _Py_CheckFunctionResult((PyObject *)descr, result, NULL);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2002-12-09 22:56:13 +00:00
|
|
|
static PyObject *
|
|
|
|
classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args,
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *kwds)
|
2002-12-09 22:56:13 +00:00
|
|
|
{
|
2012-05-01 13:51:09 +00:00
|
|
|
Py_ssize_t argc;
|
2016-08-22 21:21:55 +00:00
|
|
|
PyObject *self, *func, *result, **stack;
|
2002-12-09 22:56:13 +00:00
|
|
|
|
2012-05-01 13:51:09 +00:00
|
|
|
/* 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 '%V' of '%.100s' "
|
|
|
|
"object needs an argument",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name);
|
2010-05-09 15:52:27 +00:00
|
|
|
return NULL;
|
2012-05-01 13:51:09 +00:00
|
|
|
}
|
|
|
|
self = PyTuple_GET_ITEM(args, 0);
|
|
|
|
if (!PyType_Check(self)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' requires a type "
|
|
|
|
"but received a '%.100s'",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name,
|
|
|
|
self->ob_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!PyType_IsSubtype((PyTypeObject *)self, PyDescr_TYPE(descr))) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' "
|
|
|
|
"requires a subtype of '%.100s' "
|
|
|
|
"but received '%.100s",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name,
|
|
|
|
self->ob_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-12-09 22:56:13 +00:00
|
|
|
|
2012-12-25 11:32:35 +00:00
|
|
|
func = PyCFunction_NewEx(descr->d_method, self, NULL);
|
2012-05-01 13:51:09 +00:00
|
|
|
if (func == NULL)
|
|
|
|
return NULL;
|
2016-08-22 21:21:55 +00:00
|
|
|
stack = &PyTuple_GET_ITEM(args, 1);
|
|
|
|
result = _PyObject_FastCallDict(func, stack, argc - 1, kwds);
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_DECREF(func);
|
|
|
|
return result;
|
2002-12-09 22:56:13 +00:00
|
|
|
}
|
|
|
|
|
2001-08-02 04:15:00 +00:00
|
|
|
static PyObject *
|
|
|
|
wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_ssize_t argc;
|
2016-08-22 21:21:55 +00:00
|
|
|
PyObject *self, *func, *result, **stack;
|
2010-05-09 15:52:27 +00:00
|
|
|
|
|
|
|
/* 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 '%V' of '%.100s' "
|
|
|
|
"object needs an argument",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
self = PyTuple_GET_ITEM(args, 0);
|
2011-05-01 21:19:15 +00:00
|
|
|
if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
|
2011-05-01 21:31:36 +00:00
|
|
|
(PyObject *)PyDescr_TYPE(descr))) {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' "
|
|
|
|
"requires a '%.100s' object "
|
|
|
|
"but received a '%.100s'",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name,
|
|
|
|
self->ob_type->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
func = PyWrapper_New((PyObject *)descr, self);
|
|
|
|
if (func == NULL)
|
|
|
|
return NULL;
|
2016-08-22 21:21:55 +00:00
|
|
|
|
|
|
|
stack = &PyTuple_GET_ITEM(args, 1);
|
|
|
|
result = _PyObject_FastCallDict(func, stack, argc - 1, kwds);
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_DECREF(func);
|
|
|
|
return result;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2001-09-20 20:46:19 +00:00
|
|
|
method_get_doc(PyMethodDescrObject *descr, void *closure)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2014-02-09 06:15:29 +00:00
|
|
|
return _PyType_GetDocFromInternalDoc(descr->d_method->ml_name, descr->d_method->ml_doc);
|
2014-01-24 14:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
method_get_text_signature(PyMethodDescrObject *descr, void *closure)
|
|
|
|
{
|
2014-02-09 06:15:29 +00:00
|
|
|
return _PyType_GetTextSignatureFromInternalDoc(descr->d_method->ml_name, descr->d_method->ml_doc);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2011-12-12 12:47:25 +00:00
|
|
|
static PyObject *
|
|
|
|
calculate_qualname(PyDescrObject *descr)
|
|
|
|
{
|
|
|
|
PyObject *type_qualname, *res;
|
|
|
|
_Py_IDENTIFIER(__qualname__);
|
|
|
|
|
|
|
|
if (descr->d_name == NULL || !PyUnicode_Check(descr->d_name)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"<descriptor>.__name__ is not a unicode object");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
type_qualname = _PyObject_GetAttrId((PyObject *)descr->d_type,
|
|
|
|
&PyId___qualname__);
|
|
|
|
if (type_qualname == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (!PyUnicode_Check(type_qualname)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError, "<descriptor>.__objclass__."
|
|
|
|
"__qualname__ is not a unicode object");
|
|
|
|
Py_XDECREF(type_qualname);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = PyUnicode_FromFormat("%S.%S", type_qualname, descr->d_name);
|
|
|
|
Py_DECREF(type_qualname);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
descr_get_qualname(PyDescrObject *descr)
|
|
|
|
{
|
|
|
|
if (descr->d_qualname == NULL)
|
|
|
|
descr->d_qualname = calculate_qualname(descr);
|
|
|
|
Py_XINCREF(descr->d_qualname);
|
|
|
|
return descr->d_qualname;
|
|
|
|
}
|
|
|
|
|
2013-11-23 17:59:12 +00:00
|
|
|
static PyObject *
|
|
|
|
descr_reduce(PyDescrObject *descr)
|
|
|
|
{
|
|
|
|
PyObject *builtins;
|
|
|
|
PyObject *getattr;
|
|
|
|
_Py_IDENTIFIER(getattr);
|
|
|
|
|
|
|
|
builtins = PyEval_GetBuiltins();
|
|
|
|
getattr = _PyDict_GetItemId(builtins, &PyId_getattr);
|
|
|
|
return Py_BuildValue("O(OO)", getattr, PyDescr_TYPE(descr),
|
|
|
|
PyDescr_NAME(descr));
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef descr_methods[] = {
|
|
|
|
{"__reduce__", (PyCFunction)descr_reduce, METH_NOARGS, NULL},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2001-09-20 20:46:19 +00:00
|
|
|
static PyMemberDef descr_members[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"__objclass__", T_OBJECT, offsetof(PyDescrObject, d_type), READONLY},
|
|
|
|
{"__name__", T_OBJECT, offsetof(PyDescrObject, d_name), READONLY},
|
|
|
|
{0}
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
2001-09-20 21:45:26 +00:00
|
|
|
static PyGetSetDef method_getset[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"__doc__", (getter)method_get_doc},
|
2011-12-12 12:47:25 +00:00
|
|
|
{"__qualname__", (getter)descr_get_qualname},
|
2014-01-24 14:17:25 +00:00
|
|
|
{"__text_signature__", (getter)method_get_text_signature},
|
2010-05-09 15:52:27 +00:00
|
|
|
{0}
|
2001-09-20 20:46:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
member_get_doc(PyMemberDescrObject *descr, void *closure)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
if (descr->d_member->doc == NULL) {
|
2017-01-23 07:47:21 +00:00
|
|
|
Py_RETURN_NONE;
|
2010-05-09 15:52:27 +00:00
|
|
|
}
|
|
|
|
return PyUnicode_FromString(descr->d_member->doc);
|
2001-09-20 20:46:19 +00:00
|
|
|
}
|
|
|
|
|
2001-09-20 21:45:26 +00:00
|
|
|
static PyGetSetDef member_getset[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"__doc__", (getter)member_get_doc},
|
2011-12-12 12:47:25 +00:00
|
|
|
{"__qualname__", (getter)descr_get_qualname},
|
2010-05-09 15:52:27 +00:00
|
|
|
{0}
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
2001-09-20 21:45:26 +00:00
|
|
|
static PyObject *
|
|
|
|
getset_get_doc(PyGetSetDescrObject *descr, void *closure)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
if (descr->d_getset->doc == NULL) {
|
2017-01-23 07:47:21 +00:00
|
|
|
Py_RETURN_NONE;
|
2010-05-09 15:52:27 +00:00
|
|
|
}
|
|
|
|
return PyUnicode_FromString(descr->d_getset->doc);
|
2001-09-20 21:45:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyGetSetDef getset_getset[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"__doc__", (getter)getset_get_doc},
|
2011-12-12 12:47:25 +00:00
|
|
|
{"__qualname__", (getter)descr_get_qualname},
|
2010-05-09 15:52:27 +00:00
|
|
|
{0}
|
2001-09-20 21:45:26 +00:00
|
|
|
};
|
|
|
|
|
2001-08-02 04:15:00 +00:00
|
|
|
static PyObject *
|
2005-11-07 08:38:00 +00:00
|
|
|
wrapperdescr_get_doc(PyWrapperDescrObject *descr, void *closure)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2014-02-09 06:15:29 +00:00
|
|
|
return _PyType_GetDocFromInternalDoc(descr->d_base->name, descr->d_base->doc);
|
2014-01-24 14:17:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
wrapperdescr_get_text_signature(PyWrapperDescrObject *descr, void *closure)
|
|
|
|
{
|
2014-02-09 06:15:29 +00:00
|
|
|
return _PyType_GetTextSignatureFromInternalDoc(descr->d_base->name, descr->d_base->doc);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2005-11-07 08:38:00 +00:00
|
|
|
static PyGetSetDef wrapperdescr_getset[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"__doc__", (getter)wrapperdescr_get_doc},
|
2011-12-12 12:47:25 +00:00
|
|
|
{"__qualname__", (getter)descr_get_qualname},
|
2014-01-24 14:17:25 +00:00
|
|
|
{"__text_signature__", (getter)wrapperdescr_get_text_signature},
|
2010-05-09 15:52:27 +00:00
|
|
|
{0}
|
2001-08-02 04:15:00 +00: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 21:24:57 +00:00
|
|
|
static int
|
|
|
|
descr_traverse(PyObject *self, visitproc visit, void *arg)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyDescrObject *descr = (PyDescrObject *)self;
|
|
|
|
Py_VISIT(descr->d_type);
|
|
|
|
return 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 21:24:57 +00:00
|
|
|
}
|
|
|
|
|
2007-11-29 22:35:39 +00:00
|
|
|
PyTypeObject PyMethodDescr_Type = {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyVarObject_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_reserved */
|
|
|
|
(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 */
|
|
|
|
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 */
|
2013-11-23 17:59:12 +00:00
|
|
|
descr_methods, /* tp_methods */
|
2010-05-09 15:52:27 +00:00
|
|
|
descr_members, /* tp_members */
|
|
|
|
method_getset, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
(descrgetfunc)method_get, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
2003-02-11 18:44:42 +00:00
|
|
|
/* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */
|
2007-11-29 22:35:39 +00:00
|
|
|
PyTypeObject PyClassMethodDescr_Type = {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"classmethod_descriptor",
|
|
|
|
sizeof(PyMethodDescrObject),
|
|
|
|
0,
|
|
|
|
(destructor)descr_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_reserved */
|
|
|
|
(reprfunc)method_repr, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
|
|
|
(ternaryfunc)classmethoddescr_call, /* tp_call */
|
|
|
|
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 */
|
2013-11-23 17:59:12 +00:00
|
|
|
descr_methods, /* tp_methods */
|
2010-05-09 15:52:27 +00:00
|
|
|
descr_members, /* tp_members */
|
|
|
|
method_getset, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
(descrgetfunc)classmethod_get, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
2002-12-09 22:56:13 +00:00
|
|
|
};
|
|
|
|
|
2007-11-29 22:35:39 +00:00
|
|
|
PyTypeObject PyMemberDescr_Type = {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyVarObject_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_reserved */
|
|
|
|
(reprfunc)member_repr, /* 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 */
|
|
|
|
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 */
|
2013-11-23 17:59:12 +00:00
|
|
|
descr_methods, /* tp_methods */
|
2010-05-09 15:52:27 +00:00
|
|
|
descr_members, /* tp_members */
|
|
|
|
member_getset, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
(descrgetfunc)member_get, /* tp_descr_get */
|
|
|
|
(descrsetfunc)member_set, /* tp_descr_set */
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
2007-11-29 22:35:39 +00:00
|
|
|
PyTypeObject PyGetSetDescr_Type = {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyVarObject_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_reserved */
|
|
|
|
(reprfunc)getset_repr, /* 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 */
|
|
|
|
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 */
|
|
|
|
getset_getset, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
(descrgetfunc)getset_get, /* tp_descr_get */
|
|
|
|
(descrsetfunc)getset_set, /* tp_descr_set */
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
2001-10-03 12:09:30 +00:00
|
|
|
PyTypeObject PyWrapperDescr_Type = {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyVarObject_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_reserved */
|
|
|
|
(reprfunc)wrapperdescr_repr, /* tp_repr */
|
|
|
|
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 */
|
|
|
|
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 */
|
2013-11-23 17:59:12 +00:00
|
|
|
descr_methods, /* tp_methods */
|
2010-05-09 15:52:27 +00:00
|
|
|
descr_members, /* tp_members */
|
|
|
|
wrapperdescr_getset, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
(descrgetfunc)wrapperdescr_get, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyDescrObject *
|
2005-12-10 18:50:16 +00:00
|
|
|
descr_new(PyTypeObject *descrtype, PyTypeObject *type, const char *name)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyDescrObject *descr;
|
|
|
|
|
|
|
|
descr = (PyDescrObject *)PyType_GenericAlloc(descrtype, 0);
|
|
|
|
if (descr != NULL) {
|
|
|
|
Py_XINCREF(type);
|
|
|
|
descr->d_type = type;
|
|
|
|
descr->d_name = PyUnicode_InternFromString(name);
|
|
|
|
if (descr->d_name == NULL) {
|
|
|
|
Py_DECREF(descr);
|
|
|
|
descr = NULL;
|
|
|
|
}
|
2011-12-17 13:02:20 +00:00
|
|
|
else {
|
|
|
|
descr->d_qualname = NULL;
|
|
|
|
}
|
2010-05-09 15:52:27 +00:00
|
|
|
}
|
|
|
|
return descr;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyDescr_NewMethod(PyTypeObject *type, PyMethodDef *method)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyMethodDescrObject *descr;
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
descr = (PyMethodDescrObject *)descr_new(&PyMethodDescr_Type,
|
|
|
|
type, method->ml_name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_method = method;
|
|
|
|
return (PyObject *)descr;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2002-12-09 22:56:13 +00:00
|
|
|
PyObject *
|
|
|
|
PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyMethodDescrObject *descr;
|
2002-12-09 22:56:13 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
descr = (PyMethodDescrObject *)descr_new(&PyClassMethodDescr_Type,
|
|
|
|
type, method->ml_name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_method = method;
|
|
|
|
return (PyObject *)descr;
|
2002-12-09 22:56:13 +00:00
|
|
|
}
|
|
|
|
|
2001-08-02 04:15:00 +00:00
|
|
|
PyObject *
|
2001-09-20 20:46:19 +00:00
|
|
|
PyDescr_NewMember(PyTypeObject *type, PyMemberDef *member)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyMemberDescrObject *descr;
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
descr = (PyMemberDescrObject *)descr_new(&PyMemberDescr_Type,
|
|
|
|
type, member->name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_member = member;
|
|
|
|
return (PyObject *)descr;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
2001-09-20 21:45:26 +00:00
|
|
|
PyDescr_NewGetSet(PyTypeObject *type, PyGetSetDef *getset)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyGetSetDescrObject *descr;
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
descr = (PyGetSetDescrObject *)descr_new(&PyGetSetDescr_Type,
|
|
|
|
type, getset->name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_getset = getset;
|
|
|
|
return (PyObject *)descr;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *base, void *wrapped)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
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;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-15 22:16:30 +00:00
|
|
|
/* --- mappingproxy: read-only proxy for mappings --- */
|
2001-08-02 04:15:00 +00:00
|
|
|
|
|
|
|
/* This has no reason to be in this file except that adding new files is a
|
|
|
|
bit of a pain */
|
|
|
|
|
|
|
|
typedef struct {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject_HEAD
|
2012-04-15 22:16:30 +00:00
|
|
|
PyObject *mapping;
|
|
|
|
} mappingproxyobject;
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2006-02-15 17:27:45 +00:00
|
|
|
static Py_ssize_t
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_len(mappingproxyobject *pp)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2012-04-15 22:16:30 +00:00
|
|
|
return PyObject_Size(pp->mapping);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_getitem(mappingproxyobject *pp, PyObject *key)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2012-04-15 22:16:30 +00:00
|
|
|
return PyObject_GetItem(pp->mapping, key);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2012-04-15 22:16:30 +00:00
|
|
|
static PyMappingMethods mappingproxy_as_mapping = {
|
|
|
|
(lenfunc)mappingproxy_len, /* mp_length */
|
|
|
|
(binaryfunc)mappingproxy_getitem, /* mp_subscript */
|
2010-05-09 15:52:27 +00:00
|
|
|
0, /* mp_ass_subscript */
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_contains(mappingproxyobject *pp, PyObject *key)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2012-04-15 22:16:30 +00:00
|
|
|
if (PyDict_CheckExact(pp->mapping))
|
|
|
|
return PyDict_Contains(pp->mapping, key);
|
|
|
|
else
|
|
|
|
return PySequence_Contains(pp->mapping, key);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2012-04-15 22:16:30 +00:00
|
|
|
static PySequenceMethods mappingproxy_as_sequence = {
|
2010-05-09 15:52:27 +00:00
|
|
|
0, /* sq_length */
|
|
|
|
0, /* sq_concat */
|
|
|
|
0, /* sq_repeat */
|
|
|
|
0, /* sq_item */
|
|
|
|
0, /* sq_slice */
|
|
|
|
0, /* sq_ass_item */
|
|
|
|
0, /* sq_ass_slice */
|
2012-04-15 22:16:30 +00:00
|
|
|
(objobjproc)mappingproxy_contains, /* sq_contains */
|
2010-05-09 15:52:27 +00:00
|
|
|
0, /* sq_inplace_concat */
|
|
|
|
0, /* sq_inplace_repeat */
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_get(mappingproxyobject *pp, PyObject *args)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *key, *def = Py_None;
|
2011-10-14 08:20:37 +00:00
|
|
|
_Py_IDENTIFIER(get);
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
if (!PyArg_UnpackTuple(args, "get", 1, 2, &key, &def))
|
|
|
|
return NULL;
|
2016-12-08 23:36:19 +00:00
|
|
|
return _PyObject_CallMethodIdObjArgs(pp->mapping, &PyId_get,
|
|
|
|
key, def, NULL);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_keys(mappingproxyobject *pp)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2011-10-14 08:20:37 +00:00
|
|
|
_Py_IDENTIFIER(keys);
|
2012-04-15 22:16:30 +00:00
|
|
|
return _PyObject_CallMethodId(pp->mapping, &PyId_keys, NULL);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_values(mappingproxyobject *pp)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2011-10-14 08:20:37 +00:00
|
|
|
_Py_IDENTIFIER(values);
|
2012-04-15 22:16:30 +00:00
|
|
|
return _PyObject_CallMethodId(pp->mapping, &PyId_values, NULL);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_items(mappingproxyobject *pp)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2011-10-14 08:20:37 +00:00
|
|
|
_Py_IDENTIFIER(items);
|
2012-04-15 22:16:30 +00:00
|
|
|
return _PyObject_CallMethodId(pp->mapping, &PyId_items, NULL);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_copy(mappingproxyobject *pp)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2011-10-14 08:20:37 +00:00
|
|
|
_Py_IDENTIFIER(copy);
|
2012-04-15 22:16:30 +00:00
|
|
|
return _PyObject_CallMethodId(pp->mapping, &PyId_copy, NULL);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2012-04-15 22:16:30 +00:00
|
|
|
/* WARNING: mappingproxy methods must not give access
|
|
|
|
to the underlying mapping */
|
|
|
|
|
|
|
|
static PyMethodDef mappingproxy_methods[] = {
|
|
|
|
{"get", (PyCFunction)mappingproxy_get, METH_VARARGS,
|
2010-05-09 15:52:27 +00:00
|
|
|
PyDoc_STR("D.get(k[,d]) -> D[k] if k in D, else d."
|
2012-04-15 22:16:30 +00:00
|
|
|
" d defaults to None.")},
|
|
|
|
{"keys", (PyCFunction)mappingproxy_keys, METH_NOARGS,
|
2010-05-09 15:52:27 +00:00
|
|
|
PyDoc_STR("D.keys() -> list of D's keys")},
|
2012-04-15 22:16:30 +00:00
|
|
|
{"values", (PyCFunction)mappingproxy_values, METH_NOARGS,
|
2010-05-09 15:52:27 +00:00
|
|
|
PyDoc_STR("D.values() -> list of D's values")},
|
2012-04-15 22:16:30 +00:00
|
|
|
{"items", (PyCFunction)mappingproxy_items, METH_NOARGS,
|
2010-05-09 15:52:27 +00:00
|
|
|
PyDoc_STR("D.items() -> list of D's (key, value) pairs, as 2-tuples")},
|
2012-04-15 22:16:30 +00:00
|
|
|
{"copy", (PyCFunction)mappingproxy_copy, METH_NOARGS,
|
2010-05-09 15:52:27 +00:00
|
|
|
PyDoc_STR("D.copy() -> a shallow copy of D")},
|
|
|
|
{0}
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_dealloc(mappingproxyobject *pp)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
_PyObject_GC_UNTRACK(pp);
|
2012-04-15 22:16:30 +00:00
|
|
|
Py_DECREF(pp->mapping);
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject_GC_Del(pp);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_getiter(mappingproxyobject *pp)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2012-04-15 22:16:30 +00:00
|
|
|
return PyObject_GetIter(pp->mapping);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2001-10-21 22:26:43 +00:00
|
|
|
static PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_str(mappingproxyobject *pp)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2012-04-15 22:16:30 +00:00
|
|
|
return PyObject_Str(pp->mapping);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2010-12-18 14:59:43 +00:00
|
|
|
static PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_repr(mappingproxyobject *pp)
|
2010-12-18 14:59:43 +00:00
|
|
|
{
|
2012-04-15 22:16:30 +00:00
|
|
|
return PyUnicode_FromFormat("mappingproxy(%R)", pp->mapping);
|
2010-12-18 14:59:43 +00: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 21:24:57 +00:00
|
|
|
static int
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_traverse(PyObject *self, visitproc visit, void *arg)
|
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 21:24:57 +00:00
|
|
|
{
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
|
|
|
Py_VISIT(pp->mapping);
|
2010-05-09 15:52:27 +00:00
|
|
|
return 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 21:24:57 +00:00
|
|
|
}
|
|
|
|
|
2002-08-31 15:51:04 +00:00
|
|
|
static PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxy_richcompare(mappingproxyobject *v, PyObject *w, int op)
|
|
|
|
{
|
|
|
|
return PyObject_RichCompare(v->mapping, w, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mappingproxy_check_mapping(PyObject *mapping)
|
2002-08-31 15:51:04 +00:00
|
|
|
{
|
2012-04-15 22:16:30 +00:00
|
|
|
if (!PyMapping_Check(mapping)
|
|
|
|
|| PyList_Check(mapping)
|
|
|
|
|| PyTuple_Check(mapping)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"mappingproxy() argument must be a mapping, not %s",
|
|
|
|
Py_TYPE(mapping)->tp_name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-19 06:51:07 +00:00
|
|
|
/*[clinic input]
|
|
|
|
@classmethod
|
|
|
|
mappingproxy.__new__ as mappingproxy_new
|
|
|
|
|
|
|
|
mapping: object
|
|
|
|
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
mappingproxy_new_impl(PyTypeObject *type, PyObject *mapping)
|
|
|
|
/*[clinic end generated code: output=65f27f02d5b68fa7 input=d2d620d4f598d4f8]*/
|
2012-04-15 22:16:30 +00:00
|
|
|
{
|
|
|
|
mappingproxyobject *mappingproxy;
|
|
|
|
|
|
|
|
if (mappingproxy_check_mapping(mapping) == -1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
mappingproxy = PyObject_GC_New(mappingproxyobject, &PyDictProxy_Type);
|
|
|
|
if (mappingproxy == NULL)
|
|
|
|
return NULL;
|
|
|
|
Py_INCREF(mapping);
|
|
|
|
mappingproxy->mapping = mapping;
|
|
|
|
_PyObject_GC_TRACK(mappingproxy);
|
|
|
|
return (PyObject *)mappingproxy;
|
2002-08-31 15:51:04 +00:00
|
|
|
}
|
|
|
|
|
2001-08-02 04:15:00 +00:00
|
|
|
PyObject *
|
2012-04-15 22:16:30 +00:00
|
|
|
PyDictProxy_New(PyObject *mapping)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2012-04-15 22:16:30 +00:00
|
|
|
mappingproxyobject *pp;
|
|
|
|
|
|
|
|
if (mappingproxy_check_mapping(mapping) == -1)
|
|
|
|
return NULL;
|
2010-05-09 15:52:27 +00:00
|
|
|
|
2012-04-15 22:16:30 +00:00
|
|
|
pp = PyObject_GC_New(mappingproxyobject, &PyDictProxy_Type);
|
2010-05-09 15:52:27 +00:00
|
|
|
if (pp != NULL) {
|
2012-04-15 22:16:30 +00:00
|
|
|
Py_INCREF(mapping);
|
|
|
|
pp->mapping = mapping;
|
2010-05-09 15:52:27 +00:00
|
|
|
_PyObject_GC_TRACK(pp);
|
|
|
|
}
|
|
|
|
return (PyObject *)pp;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* --- 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 {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject_HEAD
|
|
|
|
PyWrapperDescrObject *descr;
|
|
|
|
PyObject *self;
|
2001-08-02 04:15:00 +00:00
|
|
|
} wrapperobject;
|
|
|
|
|
2011-09-01 20:32:31 +00:00
|
|
|
#define Wrapper_Check(v) (Py_TYPE(v) == &_PyMethodWrapper_Type)
|
2009-02-01 10:28:51 +00:00
|
|
|
|
2001-08-02 04:15:00 +00:00
|
|
|
static void
|
|
|
|
wrapper_dealloc(wrapperobject *wp)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject_GC_UnTrack(wp);
|
|
|
|
Py_TRASHCAN_SAFE_BEGIN(wp)
|
|
|
|
Py_XDECREF(wp->descr);
|
|
|
|
Py_XDECREF(wp->self);
|
|
|
|
PyObject_GC_Del(wp);
|
|
|
|
Py_TRASHCAN_SAFE_END(wp)
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2009-02-01 10:28:51 +00:00
|
|
|
#define TEST_COND(cond) ((cond) ? Py_True : Py_False)
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
wrapper_richcompare(PyObject *a, PyObject *b, int op)
|
2005-11-07 08:38:00 +00:00
|
|
|
{
|
2016-09-06 20:47:26 +00:00
|
|
|
intptr_t result;
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *v;
|
|
|
|
PyWrapperDescrObject *a_descr, *b_descr;
|
|
|
|
|
|
|
|
assert(a != NULL && b != NULL);
|
|
|
|
|
|
|
|
/* both arguments should be wrapperobjects */
|
|
|
|
if (!Wrapper_Check(a) || !Wrapper_Check(b)) {
|
|
|
|
v = Py_NotImplemented;
|
|
|
|
Py_INCREF(v);
|
|
|
|
return v;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compare by descriptor address; if the descriptors are the same,
|
|
|
|
compare by the objects they're bound to */
|
|
|
|
a_descr = ((wrapperobject *)a)->descr;
|
|
|
|
b_descr = ((wrapperobject *)b)->descr;
|
|
|
|
if (a_descr == b_descr) {
|
|
|
|
a = ((wrapperobject *)a)->self;
|
|
|
|
b = ((wrapperobject *)b)->self;
|
|
|
|
return PyObject_RichCompare(a, b, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = a_descr - b_descr;
|
|
|
|
switch (op) {
|
|
|
|
case Py_EQ:
|
|
|
|
v = TEST_COND(result == 0);
|
|
|
|
break;
|
|
|
|
case Py_NE:
|
|
|
|
v = TEST_COND(result != 0);
|
|
|
|
break;
|
|
|
|
case Py_LE:
|
|
|
|
v = TEST_COND(result <= 0);
|
|
|
|
break;
|
|
|
|
case Py_GE:
|
|
|
|
v = TEST_COND(result >= 0);
|
|
|
|
break;
|
|
|
|
case Py_LT:
|
|
|
|
v = TEST_COND(result < 0);
|
|
|
|
break;
|
|
|
|
case Py_GT:
|
|
|
|
v = TEST_COND(result > 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
PyErr_BadArgument();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
Py_INCREF(v);
|
|
|
|
return v;
|
2005-11-07 08:38:00 +00:00
|
|
|
}
|
|
|
|
|
2010-10-17 20:54:53 +00:00
|
|
|
static Py_hash_t
|
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 15:35:45 +00:00
|
|
|
wrapper_hash(wrapperobject *wp)
|
|
|
|
{
|
2010-10-17 20:54:53 +00:00
|
|
|
Py_hash_t x, y;
|
2010-05-09 15:52:27 +00:00
|
|
|
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;
|
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 15:35:45 +00:00
|
|
|
}
|
|
|
|
|
2005-11-07 08:38:00 +00:00
|
|
|
static PyObject *
|
|
|
|
wrapper_repr(wrapperobject *wp)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
return PyUnicode_FromFormat("<method-wrapper '%s' of %s object at %p>",
|
|
|
|
wp->descr->d_base->name,
|
|
|
|
wp->self->ob_type->tp_name,
|
|
|
|
wp->self);
|
2005-11-07 08:38:00 +00:00
|
|
|
}
|
|
|
|
|
2013-11-23 17:59:12 +00:00
|
|
|
static PyObject *
|
|
|
|
wrapper_reduce(wrapperobject *wp)
|
|
|
|
{
|
|
|
|
PyObject *builtins;
|
|
|
|
PyObject *getattr;
|
|
|
|
_Py_IDENTIFIER(getattr);
|
|
|
|
|
|
|
|
builtins = PyEval_GetBuiltins();
|
|
|
|
getattr = _PyDict_GetItemId(builtins, &PyId_getattr);
|
|
|
|
return Py_BuildValue("O(OO)", getattr, wp->self, PyDescr_NAME(wp->descr));
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef wrapper_methods[] = {
|
|
|
|
{"__reduce__", (PyCFunction)wrapper_reduce, METH_NOARGS, NULL},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2005-11-07 08:38:00 +00:00
|
|
|
static PyMemberDef wrapper_members[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"__self__", T_OBJECT, offsetof(wrapperobject, self), READONLY},
|
|
|
|
{0}
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
2005-11-07 08:38:00 +00:00
|
|
|
static PyObject *
|
|
|
|
wrapper_objclass(wrapperobject *wp)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject *c = (PyObject *)PyDescr_TYPE(wp->descr);
|
2005-11-07 08:38:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_INCREF(c);
|
|
|
|
return c;
|
2005-11-07 08:38:00 +00:00
|
|
|
}
|
|
|
|
|
2001-08-02 04:15:00 +00:00
|
|
|
static PyObject *
|
|
|
|
wrapper_name(wrapperobject *wp)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
const char *s = wp->descr->d_base->name;
|
2001-08-02 04:15:00 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
return PyUnicode_FromString(s);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2014-01-24 14:17:25 +00:00
|
|
|
wrapper_doc(wrapperobject *wp, void *closure)
|
2001-08-02 04:15:00 +00:00
|
|
|
{
|
2014-02-09 06:15:29 +00:00
|
|
|
return _PyType_GetDocFromInternalDoc(wp->descr->d_base->name, wp->descr->d_base->doc);
|
2014-01-24 14:17:25 +00:00
|
|
|
}
|
2010-05-09 15:52:27 +00:00
|
|
|
|
2014-01-24 14:17:25 +00:00
|
|
|
static PyObject *
|
|
|
|
wrapper_text_signature(wrapperobject *wp, void *closure)
|
|
|
|
{
|
2014-02-09 06:15:29 +00:00
|
|
|
return _PyType_GetTextSignatureFromInternalDoc(wp->descr->d_base->name, wp->descr->d_base->doc);
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
|
|
|
|
2011-12-12 12:47:25 +00:00
|
|
|
static PyObject *
|
|
|
|
wrapper_qualname(wrapperobject *wp)
|
|
|
|
{
|
|
|
|
return descr_get_qualname((PyDescrObject *)wp->descr);
|
|
|
|
}
|
|
|
|
|
2001-09-20 21:45:26 +00:00
|
|
|
static PyGetSetDef wrapper_getsets[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"__objclass__", (getter)wrapper_objclass},
|
|
|
|
{"__name__", (getter)wrapper_name},
|
2011-12-12 12:47:25 +00:00
|
|
|
{"__qualname__", (getter)wrapper_qualname},
|
2010-05-09 15:52:27 +00:00
|
|
|
{"__doc__", (getter)wrapper_doc},
|
2014-01-24 14:17:25 +00:00
|
|
|
{"__text_signature__", (getter)wrapper_text_signature},
|
2010-05-09 15:52:27 +00:00
|
|
|
{0}
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
wrapper_call(wrapperobject *wp, PyObject *args, PyObject *kwds)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
wrapperfunc wrapper = wp->descr->d_base->wrapper;
|
|
|
|
PyObject *self = wp->self;
|
|
|
|
|
|
|
|
if (wp->descr->d_base->flags & PyWrapperFlag_KEYWORDS) {
|
|
|
|
wrapperfunc_kwds wk = (wrapperfunc_kwds)wrapper;
|
|
|
|
return (*wk)(self, args, wp->descr->d_wrapped, kwds);
|
|
|
|
}
|
|
|
|
|
2016-12-16 14:18:57 +00:00
|
|
|
if (kwds != NULL && (!PyDict_Check(kwds) || PyDict_GET_SIZE(kwds) != 0)) {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyErr_Format(PyExc_TypeError,
|
2017-06-06 15:45:22 +00:00
|
|
|
"wrapper %s() takes no keyword arguments",
|
2010-05-09 15:52:27 +00:00
|
|
|
wp->descr->d_base->name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return (*wrapper)(self, args, wp->descr->d_wrapped);
|
2001-08-02 04:15:00 +00: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 21:24:57 +00:00
|
|
|
static int
|
|
|
|
wrapper_traverse(PyObject *self, visitproc visit, void *arg)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
wrapperobject *wp = (wrapperobject *)self;
|
|
|
|
Py_VISIT(wp->descr);
|
|
|
|
Py_VISIT(wp->self);
|
|
|
|
return 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 21:24:57 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 20:32:31 +00:00
|
|
|
PyTypeObject _PyMethodWrapper_Type = {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"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 */
|
|
|
|
0, /* tp_reserved */
|
|
|
|
(reprfunc)wrapper_repr, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
(hashfunc)wrapper_hash, /* tp_hash */
|
|
|
|
(ternaryfunc)wrapper_call, /* tp_call */
|
|
|
|
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 */
|
|
|
|
wrapper_traverse, /* tp_traverse */
|
|
|
|
0, /* tp_clear */
|
|
|
|
wrapper_richcompare, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
2013-11-23 17:59:12 +00:00
|
|
|
wrapper_methods, /* tp_methods */
|
2010-05-09 15:52:27 +00:00
|
|
|
wrapper_members, /* tp_members */
|
|
|
|
wrapper_getsets, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
2001-08-02 04:15:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyWrapper_New(PyObject *d, PyObject *self)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
wrapperobject *wp;
|
|
|
|
PyWrapperDescrObject *descr;
|
|
|
|
|
|
|
|
assert(PyObject_TypeCheck(d, &PyWrapperDescr_Type));
|
|
|
|
descr = (PyWrapperDescrObject *)d;
|
2011-05-01 21:19:15 +00:00
|
|
|
assert(_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
|
2011-05-01 21:31:36 +00:00
|
|
|
(PyObject *)PyDescr_TYPE(descr)));
|
2010-05-09 15:52:27 +00:00
|
|
|
|
2011-09-01 20:32:31 +00:00
|
|
|
wp = PyObject_GC_New(wrapperobject, &_PyMethodWrapper_Type);
|
2010-05-09 15:52:27 +00:00
|
|
|
if (wp != NULL) {
|
|
|
|
Py_INCREF(descr);
|
|
|
|
wp->descr = descr;
|
|
|
|
Py_INCREF(self);
|
|
|
|
wp->self = self;
|
|
|
|
_PyObject_GC_TRACK(wp);
|
|
|
|
}
|
|
|
|
return (PyObject *)wp;
|
2001-08-02 04:15:00 +00:00
|
|
|
}
|
2001-08-23 21:40:38 +00:00
|
|
|
|
|
|
|
|
2001-09-06 21:56:42 +00:00
|
|
|
/* A built-in 'property' type */
|
2001-08-23 21:40:38 +00:00
|
|
|
|
|
|
|
/*
|
2015-06-10 21:06:39 +00:00
|
|
|
class property(object):
|
2001-08-23 21:40:38 +00:00
|
|
|
|
2010-05-09 15:52:27 +00:00
|
|
|
def __init__(self, fget=None, fset=None, fdel=None, doc=None):
|
|
|
|
if doc is None and fget is not None and hasattr(fget, "__doc__"):
|
2015-06-10 21:06:39 +00:00
|
|
|
doc = fget.__doc__
|
2010-05-09 15:52:27 +00:00
|
|
|
self.__get = fget
|
|
|
|
self.__set = fset
|
|
|
|
self.__del = fdel
|
|
|
|
self.__doc__ = doc
|
|
|
|
|
|
|
|
def __get__(self, inst, type=None):
|
|
|
|
if inst is None:
|
2015-06-10 21:06:39 +00:00
|
|
|
return self
|
2010-05-09 15:52:27 +00:00
|
|
|
if self.__get is None:
|
2015-06-10 21:06:39 +00:00
|
|
|
raise AttributeError, "unreadable attribute"
|
2010-05-09 15:52:27 +00:00
|
|
|
return self.__get(inst)
|
|
|
|
|
|
|
|
def __set__(self, inst, value):
|
|
|
|
if self.__set is None:
|
2015-06-10 21:06:39 +00:00
|
|
|
raise AttributeError, "can't set attribute"
|
2010-05-09 15:52:27 +00:00
|
|
|
return self.__set(inst, value)
|
|
|
|
|
|
|
|
def __delete__(self, inst):
|
|
|
|
if self.__del is None:
|
2015-06-10 21:06:39 +00:00
|
|
|
raise AttributeError, "can't delete attribute"
|
2010-05-09 15:52:27 +00:00
|
|
|
return self.__del(inst)
|
2001-12-10 18:03:34 +00:00
|
|
|
|
2001-08-23 21:40:38 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyObject_HEAD
|
|
|
|
PyObject *prop_get;
|
|
|
|
PyObject *prop_set;
|
|
|
|
PyObject *prop_del;
|
|
|
|
PyObject *prop_doc;
|
|
|
|
int getter_doc;
|
2001-09-06 21:56:42 +00:00
|
|
|
} propertyobject;
|
2001-08-23 21:40:38 +00:00
|
|
|
|
Merged revisions 59488-59511 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59489 | christian.heimes | 2007-12-14 03:33:57 +0100 (Fri, 14 Dec 2007) | 1 line
Silence a warning about an unsed variable in debug builds
........
r59490 | christian.heimes | 2007-12-14 03:35:23 +0100 (Fri, 14 Dec 2007) | 2 lines
Fixed bug #1620: New @spam.getter property syntax modifies the property in place.
I added also the feature that a @prop.getter decorator does not overwrite the doc string of the property if it was given as an argument to property().
........
r59491 | raymond.hettinger | 2007-12-14 03:49:47 +0100 (Fri, 14 Dec 2007) | 1 line
Cleaner method naming convention
........
r59492 | christian.heimes | 2007-12-14 04:02:34 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments.
........
r59493 | christian.heimes | 2007-12-14 05:38:13 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed warning in ssl module
........
r59500 | raymond.hettinger | 2007-12-14 19:08:20 +0100 (Fri, 14 Dec 2007) | 1 line
Add line spacing for readability
........
r59501 | raymond.hettinger | 2007-12-14 19:12:21 +0100 (Fri, 14 Dec 2007) | 3 lines
Update method names for named tuples.
........
r59503 | georg.brandl | 2007-12-14 20:03:36 +0100 (Fri, 14 Dec 2007) | 3 lines
Add a section about nested listcomps to the tutorial.
Thanks to Ian Bruntlett and Robert Lehmann.
........
r59504 | raymond.hettinger | 2007-12-14 20:19:59 +0100 (Fri, 14 Dec 2007) | 1 line
Faster and simpler _replace() method
........
r59505 | raymond.hettinger | 2007-12-14 22:51:50 +0100 (Fri, 14 Dec 2007) | 1 line
Add usage note
........
r59507 | andrew.kuchling | 2007-12-14 23:41:18 +0100 (Fri, 14 Dec 2007) | 1 line
Remove warning about URL
........
r59510 | andrew.kuchling | 2007-12-14 23:52:36 +0100 (Fri, 14 Dec 2007) | 1 line
Bump the version number, and make a few small edits
........
r59511 | christian.heimes | 2007-12-15 00:42:36 +0100 (Sat, 15 Dec 2007) | 2 lines
Fixed bug #1628
The detection now works on Unix with Makefile, Makefile with VPATH and on Windows.
........
2007-12-15 01:27:15 +00:00
|
|
|
static PyObject * property_copy(PyObject *, PyObject *, PyObject *,
|
2010-06-28 03:07:10 +00:00
|
|
|
PyObject *);
|
Merged revisions 59488-59511 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59489 | christian.heimes | 2007-12-14 03:33:57 +0100 (Fri, 14 Dec 2007) | 1 line
Silence a warning about an unsed variable in debug builds
........
r59490 | christian.heimes | 2007-12-14 03:35:23 +0100 (Fri, 14 Dec 2007) | 2 lines
Fixed bug #1620: New @spam.getter property syntax modifies the property in place.
I added also the feature that a @prop.getter decorator does not overwrite the doc string of the property if it was given as an argument to property().
........
r59491 | raymond.hettinger | 2007-12-14 03:49:47 +0100 (Fri, 14 Dec 2007) | 1 line
Cleaner method naming convention
........
r59492 | christian.heimes | 2007-12-14 04:02:34 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments.
........
r59493 | christian.heimes | 2007-12-14 05:38:13 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed warning in ssl module
........
r59500 | raymond.hettinger | 2007-12-14 19:08:20 +0100 (Fri, 14 Dec 2007) | 1 line
Add line spacing for readability
........
r59501 | raymond.hettinger | 2007-12-14 19:12:21 +0100 (Fri, 14 Dec 2007) | 3 lines
Update method names for named tuples.
........
r59503 | georg.brandl | 2007-12-14 20:03:36 +0100 (Fri, 14 Dec 2007) | 3 lines
Add a section about nested listcomps to the tutorial.
Thanks to Ian Bruntlett and Robert Lehmann.
........
r59504 | raymond.hettinger | 2007-12-14 20:19:59 +0100 (Fri, 14 Dec 2007) | 1 line
Faster and simpler _replace() method
........
r59505 | raymond.hettinger | 2007-12-14 22:51:50 +0100 (Fri, 14 Dec 2007) | 1 line
Add usage note
........
r59507 | andrew.kuchling | 2007-12-14 23:41:18 +0100 (Fri, 14 Dec 2007) | 1 line
Remove warning about URL
........
r59510 | andrew.kuchling | 2007-12-14 23:52:36 +0100 (Fri, 14 Dec 2007) | 1 line
Bump the version number, and make a few small edits
........
r59511 | christian.heimes | 2007-12-15 00:42:36 +0100 (Sat, 15 Dec 2007) | 2 lines
Fixed bug #1628
The detection now works on Unix with Makefile, Makefile with VPATH and on Windows.
........
2007-12-15 01:27:15 +00:00
|
|
|
|
2001-09-24 21:17:50 +00:00
|
|
|
static PyMemberDef property_members[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"fget", T_OBJECT, offsetof(propertyobject, prop_get), READONLY},
|
|
|
|
{"fset", T_OBJECT, offsetof(propertyobject, prop_set), READONLY},
|
|
|
|
{"fdel", T_OBJECT, offsetof(propertyobject, prop_del), READONLY},
|
2015-05-13 08:09:59 +00:00
|
|
|
{"__doc__", T_OBJECT, offsetof(propertyobject, prop_doc), 0},
|
2010-05-09 15:52:27 +00:00
|
|
|
{0}
|
2001-09-24 21:17:50 +00:00
|
|
|
};
|
|
|
|
|
Merged revisions 59488-59511 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59489 | christian.heimes | 2007-12-14 03:33:57 +0100 (Fri, 14 Dec 2007) | 1 line
Silence a warning about an unsed variable in debug builds
........
r59490 | christian.heimes | 2007-12-14 03:35:23 +0100 (Fri, 14 Dec 2007) | 2 lines
Fixed bug #1620: New @spam.getter property syntax modifies the property in place.
I added also the feature that a @prop.getter decorator does not overwrite the doc string of the property if it was given as an argument to property().
........
r59491 | raymond.hettinger | 2007-12-14 03:49:47 +0100 (Fri, 14 Dec 2007) | 1 line
Cleaner method naming convention
........
r59492 | christian.heimes | 2007-12-14 04:02:34 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments.
........
r59493 | christian.heimes | 2007-12-14 05:38:13 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed warning in ssl module
........
r59500 | raymond.hettinger | 2007-12-14 19:08:20 +0100 (Fri, 14 Dec 2007) | 1 line
Add line spacing for readability
........
r59501 | raymond.hettinger | 2007-12-14 19:12:21 +0100 (Fri, 14 Dec 2007) | 3 lines
Update method names for named tuples.
........
r59503 | georg.brandl | 2007-12-14 20:03:36 +0100 (Fri, 14 Dec 2007) | 3 lines
Add a section about nested listcomps to the tutorial.
Thanks to Ian Bruntlett and Robert Lehmann.
........
r59504 | raymond.hettinger | 2007-12-14 20:19:59 +0100 (Fri, 14 Dec 2007) | 1 line
Faster and simpler _replace() method
........
r59505 | raymond.hettinger | 2007-12-14 22:51:50 +0100 (Fri, 14 Dec 2007) | 1 line
Add usage note
........
r59507 | andrew.kuchling | 2007-12-14 23:41:18 +0100 (Fri, 14 Dec 2007) | 1 line
Remove warning about URL
........
r59510 | andrew.kuchling | 2007-12-14 23:52:36 +0100 (Fri, 14 Dec 2007) | 1 line
Bump the version number, and make a few small edits
........
r59511 | christian.heimes | 2007-12-15 00:42:36 +0100 (Sat, 15 Dec 2007) | 2 lines
Fixed bug #1628
The detection now works on Unix with Makefile, Makefile with VPATH and on Windows.
........
2007-12-15 01:27:15 +00:00
|
|
|
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
PyDoc_STRVAR(getter_doc,
|
2010-05-09 15:52:27 +00:00
|
|
|
"Descriptor to change the getter on a property.");
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
|
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62055-62058,62060-62066,62068-62074,62076-62079,62081-62083,62086-62089,62092-62094,62098,62101,62104,62106-62109,62115-62122,62124-62125,62128,62130,62132,62134-62135,62137,62139-62140,62144,62146,62151,62155,62157,62162-62166,62171-62172,62175-62176,62178,62181-62186,62188-62192,62196,62200-62203,62206,62211-62213,62215-62218,62222,62224-62226,62228,62232,62236,62240-62245,62248,62250-62254,62256-62258,62262,62264-62265,62267-62270,62272-62276,62280-62288,62291-62292,62299-62301,62307,62312,62316-62318,62322-62331,62333-62337,62339-62344,62346-62348 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62323 | brett.cannon | 2008-04-13 10:09:43 -0700 (Sun, 13 Apr 2008) | 3 lines
Add an explicit check for output in a test to try to diagnose a failure on
Windows.
........
r62324 | brett.cannon | 2008-04-13 10:41:31 -0700 (Sun, 13 Apr 2008) | 3 lines
Fix spliting on colons on Windows machines with a file path by limiting the
number of splits.
........
r62329 | benjamin.peterson | 2008-04-13 13:35:56 -0700 (Sun, 13 Apr 2008) | 2 lines
#2627 Let it be known what pgen generates
........
r62330 | benjamin.peterson | 2008-04-13 13:40:03 -0700 (Sun, 13 Apr 2008) | 2 lines
Added an ignore file for Bazaar #2510
........
r62331 | georg.brandl | 2008-04-13 13:50:29 -0700 (Sun, 13 Apr 2008) | 2 lines
Improve -X error message.
........
r62334 | andrew.kuchling | 2008-04-13 15:39:12 -0700 (Sun, 13 Apr 2008) | 1 line
Add example
........
r62340 | amaury.forgeotdarc | 2008-04-14 12:55:40 -0700 (Mon, 14 Apr 2008) | 2 lines
Update project files for all Windows supported compilers
........
r62341 | amaury.forgeotdarc | 2008-04-14 13:07:48 -0700 (Mon, 14 Apr 2008) | 6 lines
Correct a refleak found by "regrtest.py -R:: test_structmembers"
Some other minor updates in _warnings.c:
- make a function static
- rename a shadowing local variable
........
r62347 | andrew.kuchling | 2008-04-14 19:24:15 -0700 (Mon, 14 Apr 2008) | 1 line
Various items; begin writing the SSL section
........
r62348 | neal.norwitz | 2008-04-14 20:46:21 -0700 (Mon, 14 Apr 2008) | 1 line
Prevent namespace pollution, add static for internal functions
........
2008-04-15 06:43:13 +00:00
|
|
|
static PyObject *
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
property_getter(PyObject *self, PyObject *getter)
|
|
|
|
{
|
2010-06-28 03:07:10 +00:00
|
|
|
return property_copy(self, getter, NULL, NULL);
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
}
|
|
|
|
|
Merged revisions 59488-59511 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59489 | christian.heimes | 2007-12-14 03:33:57 +0100 (Fri, 14 Dec 2007) | 1 line
Silence a warning about an unsed variable in debug builds
........
r59490 | christian.heimes | 2007-12-14 03:35:23 +0100 (Fri, 14 Dec 2007) | 2 lines
Fixed bug #1620: New @spam.getter property syntax modifies the property in place.
I added also the feature that a @prop.getter decorator does not overwrite the doc string of the property if it was given as an argument to property().
........
r59491 | raymond.hettinger | 2007-12-14 03:49:47 +0100 (Fri, 14 Dec 2007) | 1 line
Cleaner method naming convention
........
r59492 | christian.heimes | 2007-12-14 04:02:34 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments.
........
r59493 | christian.heimes | 2007-12-14 05:38:13 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed warning in ssl module
........
r59500 | raymond.hettinger | 2007-12-14 19:08:20 +0100 (Fri, 14 Dec 2007) | 1 line
Add line spacing for readability
........
r59501 | raymond.hettinger | 2007-12-14 19:12:21 +0100 (Fri, 14 Dec 2007) | 3 lines
Update method names for named tuples.
........
r59503 | georg.brandl | 2007-12-14 20:03:36 +0100 (Fri, 14 Dec 2007) | 3 lines
Add a section about nested listcomps to the tutorial.
Thanks to Ian Bruntlett and Robert Lehmann.
........
r59504 | raymond.hettinger | 2007-12-14 20:19:59 +0100 (Fri, 14 Dec 2007) | 1 line
Faster and simpler _replace() method
........
r59505 | raymond.hettinger | 2007-12-14 22:51:50 +0100 (Fri, 14 Dec 2007) | 1 line
Add usage note
........
r59507 | andrew.kuchling | 2007-12-14 23:41:18 +0100 (Fri, 14 Dec 2007) | 1 line
Remove warning about URL
........
r59510 | andrew.kuchling | 2007-12-14 23:52:36 +0100 (Fri, 14 Dec 2007) | 1 line
Bump the version number, and make a few small edits
........
r59511 | christian.heimes | 2007-12-15 00:42:36 +0100 (Sat, 15 Dec 2007) | 2 lines
Fixed bug #1628
The detection now works on Unix with Makefile, Makefile with VPATH and on Windows.
........
2007-12-15 01:27:15 +00:00
|
|
|
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
PyDoc_STRVAR(setter_doc,
|
2010-05-09 15:52:27 +00:00
|
|
|
"Descriptor to change the setter on a property.");
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
|
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62055-62058,62060-62066,62068-62074,62076-62079,62081-62083,62086-62089,62092-62094,62098,62101,62104,62106-62109,62115-62122,62124-62125,62128,62130,62132,62134-62135,62137,62139-62140,62144,62146,62151,62155,62157,62162-62166,62171-62172,62175-62176,62178,62181-62186,62188-62192,62196,62200-62203,62206,62211-62213,62215-62218,62222,62224-62226,62228,62232,62236,62240-62245,62248,62250-62254,62256-62258,62262,62264-62265,62267-62270,62272-62276,62280-62288,62291-62292,62299-62301,62307,62312,62316-62318,62322-62331,62333-62337,62339-62344,62346-62348 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62323 | brett.cannon | 2008-04-13 10:09:43 -0700 (Sun, 13 Apr 2008) | 3 lines
Add an explicit check for output in a test to try to diagnose a failure on
Windows.
........
r62324 | brett.cannon | 2008-04-13 10:41:31 -0700 (Sun, 13 Apr 2008) | 3 lines
Fix spliting on colons on Windows machines with a file path by limiting the
number of splits.
........
r62329 | benjamin.peterson | 2008-04-13 13:35:56 -0700 (Sun, 13 Apr 2008) | 2 lines
#2627 Let it be known what pgen generates
........
r62330 | benjamin.peterson | 2008-04-13 13:40:03 -0700 (Sun, 13 Apr 2008) | 2 lines
Added an ignore file for Bazaar #2510
........
r62331 | georg.brandl | 2008-04-13 13:50:29 -0700 (Sun, 13 Apr 2008) | 2 lines
Improve -X error message.
........
r62334 | andrew.kuchling | 2008-04-13 15:39:12 -0700 (Sun, 13 Apr 2008) | 1 line
Add example
........
r62340 | amaury.forgeotdarc | 2008-04-14 12:55:40 -0700 (Mon, 14 Apr 2008) | 2 lines
Update project files for all Windows supported compilers
........
r62341 | amaury.forgeotdarc | 2008-04-14 13:07:48 -0700 (Mon, 14 Apr 2008) | 6 lines
Correct a refleak found by "regrtest.py -R:: test_structmembers"
Some other minor updates in _warnings.c:
- make a function static
- rename a shadowing local variable
........
r62347 | andrew.kuchling | 2008-04-14 19:24:15 -0700 (Mon, 14 Apr 2008) | 1 line
Various items; begin writing the SSL section
........
r62348 | neal.norwitz | 2008-04-14 20:46:21 -0700 (Mon, 14 Apr 2008) | 1 line
Prevent namespace pollution, add static for internal functions
........
2008-04-15 06:43:13 +00:00
|
|
|
static PyObject *
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
property_setter(PyObject *self, PyObject *setter)
|
|
|
|
{
|
2010-06-28 03:07:10 +00:00
|
|
|
return property_copy(self, NULL, setter, NULL);
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
}
|
|
|
|
|
Merged revisions 59488-59511 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59489 | christian.heimes | 2007-12-14 03:33:57 +0100 (Fri, 14 Dec 2007) | 1 line
Silence a warning about an unsed variable in debug builds
........
r59490 | christian.heimes | 2007-12-14 03:35:23 +0100 (Fri, 14 Dec 2007) | 2 lines
Fixed bug #1620: New @spam.getter property syntax modifies the property in place.
I added also the feature that a @prop.getter decorator does not overwrite the doc string of the property if it was given as an argument to property().
........
r59491 | raymond.hettinger | 2007-12-14 03:49:47 +0100 (Fri, 14 Dec 2007) | 1 line
Cleaner method naming convention
........
r59492 | christian.heimes | 2007-12-14 04:02:34 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments.
........
r59493 | christian.heimes | 2007-12-14 05:38:13 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed warning in ssl module
........
r59500 | raymond.hettinger | 2007-12-14 19:08:20 +0100 (Fri, 14 Dec 2007) | 1 line
Add line spacing for readability
........
r59501 | raymond.hettinger | 2007-12-14 19:12:21 +0100 (Fri, 14 Dec 2007) | 3 lines
Update method names for named tuples.
........
r59503 | georg.brandl | 2007-12-14 20:03:36 +0100 (Fri, 14 Dec 2007) | 3 lines
Add a section about nested listcomps to the tutorial.
Thanks to Ian Bruntlett and Robert Lehmann.
........
r59504 | raymond.hettinger | 2007-12-14 20:19:59 +0100 (Fri, 14 Dec 2007) | 1 line
Faster and simpler _replace() method
........
r59505 | raymond.hettinger | 2007-12-14 22:51:50 +0100 (Fri, 14 Dec 2007) | 1 line
Add usage note
........
r59507 | andrew.kuchling | 2007-12-14 23:41:18 +0100 (Fri, 14 Dec 2007) | 1 line
Remove warning about URL
........
r59510 | andrew.kuchling | 2007-12-14 23:52:36 +0100 (Fri, 14 Dec 2007) | 1 line
Bump the version number, and make a few small edits
........
r59511 | christian.heimes | 2007-12-15 00:42:36 +0100 (Sat, 15 Dec 2007) | 2 lines
Fixed bug #1628
The detection now works on Unix with Makefile, Makefile with VPATH and on Windows.
........
2007-12-15 01:27:15 +00:00
|
|
|
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
PyDoc_STRVAR(deleter_doc,
|
2010-05-09 15:52:27 +00:00
|
|
|
"Descriptor to change the deleter on a property.");
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
|
Merged revisions 61440-61441,61443,61445-61448,61451-61452,61455-61457,61459-61464,61466-61467,61469-61470,61476-61477,61479,61481-61482,61485,61487,61490,61493-61494,61497,61499-61502,61505-61506,61508,61511-61514,61519,61521-61522,61530-61531,61533-61537,61541-61555,61557-61558,61561-61562,61566-61569,61572-61574,61578-61579,61583-61584,61588-61589,61592,61594,61598-61601,61603-61604,61607-61612,61617,61619-61620,61624,61626,61628-61630,61635-61638,61640-61643,61645,61648,61653-61655,61659-61662,61664,61666,61668-61671,61673,61675,61679-61680,61682,61685-61686,61689-61695,61697-61699,61701-61703,61706,61710,61713,61717,61723,61726-61730,61736,61738,61740,61742,61745-61752,61754-61760,61762-61764,61768,61770-61772,61774-61775,61784-61787,61789-61792,61794-61795,61797-61806,61808-61809,61811-61812,61814-61819,61824,61826-61833,61835-61840,61843-61845,61848,61850,61854-61862,61865-61866,61868,61872-61873,61876-61877,61883-61888,61890-61891,61893-61899,61901-61903,61905-61912,61914,61917,61920-61921,61927,61930,61932-61934,61939,61941-61942,61944-61951,61955,61960-61963,61980,61982-61983,61991,61994-61996,62001-62003,62008-62010,62016-62017,62022,62024,62027,62031-62034,62041,62045-62046,62055-62058,62060-62066,62068-62074,62076-62079,62081-62083,62086-62089,62092-62094,62098,62101,62104,62106-62109,62115-62122,62124-62125,62128,62130,62132,62134-62135,62137,62139-62140,62144,62146,62151,62155,62157,62162-62166,62171-62172,62175-62176,62178,62181-62186,62188-62192,62196,62200-62203,62206,62211-62213,62215-62218,62222,62224-62226,62228,62232,62236,62240-62245,62248,62250-62254,62256-62258,62262,62264-62265,62267-62270,62272-62276,62280-62288,62291-62292,62299-62301,62307,62312,62316-62318,62322-62331,62333-62337,62339-62344,62346-62348 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r62323 | brett.cannon | 2008-04-13 10:09:43 -0700 (Sun, 13 Apr 2008) | 3 lines
Add an explicit check for output in a test to try to diagnose a failure on
Windows.
........
r62324 | brett.cannon | 2008-04-13 10:41:31 -0700 (Sun, 13 Apr 2008) | 3 lines
Fix spliting on colons on Windows machines with a file path by limiting the
number of splits.
........
r62329 | benjamin.peterson | 2008-04-13 13:35:56 -0700 (Sun, 13 Apr 2008) | 2 lines
#2627 Let it be known what pgen generates
........
r62330 | benjamin.peterson | 2008-04-13 13:40:03 -0700 (Sun, 13 Apr 2008) | 2 lines
Added an ignore file for Bazaar #2510
........
r62331 | georg.brandl | 2008-04-13 13:50:29 -0700 (Sun, 13 Apr 2008) | 2 lines
Improve -X error message.
........
r62334 | andrew.kuchling | 2008-04-13 15:39:12 -0700 (Sun, 13 Apr 2008) | 1 line
Add example
........
r62340 | amaury.forgeotdarc | 2008-04-14 12:55:40 -0700 (Mon, 14 Apr 2008) | 2 lines
Update project files for all Windows supported compilers
........
r62341 | amaury.forgeotdarc | 2008-04-14 13:07:48 -0700 (Mon, 14 Apr 2008) | 6 lines
Correct a refleak found by "regrtest.py -R:: test_structmembers"
Some other minor updates in _warnings.c:
- make a function static
- rename a shadowing local variable
........
r62347 | andrew.kuchling | 2008-04-14 19:24:15 -0700 (Mon, 14 Apr 2008) | 1 line
Various items; begin writing the SSL section
........
r62348 | neal.norwitz | 2008-04-14 20:46:21 -0700 (Mon, 14 Apr 2008) | 1 line
Prevent namespace pollution, add static for internal functions
........
2008-04-15 06:43:13 +00:00
|
|
|
static PyObject *
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
property_deleter(PyObject *self, PyObject *deleter)
|
|
|
|
{
|
2010-06-28 03:07:10 +00:00
|
|
|
return property_copy(self, NULL, NULL, deleter);
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static PyMethodDef property_methods[] = {
|
2010-05-09 15:52:27 +00:00
|
|
|
{"getter", property_getter, METH_O, getter_doc},
|
|
|
|
{"setter", property_setter, METH_O, setter_doc},
|
|
|
|
{"deleter", property_deleter, METH_O, deleter_doc},
|
|
|
|
{0}
|
Merged revisions 58886-58929 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r58892 | guido.van.rossum | 2007-11-06 15:32:56 -0800 (Tue, 06 Nov 2007) | 2 lines
Add missing "return NULL" in overflow check in PyObject_Repr().
........
r58893 | raymond.hettinger | 2007-11-06 17:13:09 -0800 (Tue, 06 Nov 2007) | 1 line
Fix marshal's incorrect handling of subclasses of builtin types (backport candidate).
........
r58895 | raymond.hettinger | 2007-11-06 18:26:17 -0800 (Tue, 06 Nov 2007) | 1 line
Optimize dict.fromkeys() with dict inputs. Useful for resetting bag/muliset counts for example.
........
r58896 | raymond.hettinger | 2007-11-06 18:45:46 -0800 (Tue, 06 Nov 2007) | 1 line
Add build option for faster loop execution.
........
r58900 | nick.coghlan | 2007-11-07 03:57:51 -0800 (Wed, 07 Nov 2007) | 1 line
Add missing NEWS entry
........
r58905 | christian.heimes | 2007-11-07 09:50:54 -0800 (Wed, 07 Nov 2007) | 1 line
Backported fix for bug #1392 from py3k branch r58903.
........
r58906 | christian.heimes | 2007-11-07 10:30:22 -0800 (Wed, 07 Nov 2007) | 1 line
Backport of Guido's review of my patch.
........
r58908 | raymond.hettinger | 2007-11-07 18:52:43 -0800 (Wed, 07 Nov 2007) | 1 line
Add set.isdisjoint()
........
r58915 | raymond.hettinger | 2007-11-08 10:47:51 -0800 (Thu, 08 Nov 2007) | 1 line
Reposition the decref (spotted by eagle-eye norwitz).
........
r58920 | georg.brandl | 2007-11-09 04:31:43 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix seealso link to sets docs. Do not merge to Py3k.
........
r58921 | georg.brandl | 2007-11-09 05:08:48 -0800 (Fri, 09 Nov 2007) | 2 lines
Fix misleading example.
........
r58923 | georg.brandl | 2007-11-09 09:33:23 -0800 (Fri, 09 Nov 2007) | 3 lines
Correct a comment about testing methods - nowadays most
tests don't run directly on import.
........
r58924 | martin.v.loewis | 2007-11-09 14:56:30 -0800 (Fri, 09 Nov 2007) | 2 lines
Add Amaury Forgeot d'Arc.
........
r58925 | raymond.hettinger | 2007-11-09 15:14:44 -0800 (Fri, 09 Nov 2007) | 1 line
Optimize common case for dict.fromkeys().
........
r58927 | raymond.hettinger | 2007-11-09 17:54:03 -0800 (Fri, 09 Nov 2007) | 1 line
Use a freelist to speed-up block allocation and deallocation in collections.deque().
........
r58929 | guido.van.rossum | 2007-11-10 14:12:24 -0800 (Sat, 10 Nov 2007) | 3 lines
Issue 1416. Add getter, setter, deleter methods to properties that can be
used as decorators to create fully-populated properties.
........
2007-11-10 23:39:45 +00:00
|
|
|
};
|
|
|
|
|
2001-09-24 21:17:50 +00:00
|
|
|
|
2001-08-23 21:40:38 +00:00
|
|
|
static void
|
2001-09-06 21:56:42 +00:00
|
|
|
property_dealloc(PyObject *self)
|
2001-08-23 21:40:38 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
propertyobject *gs = (propertyobject *)self;
|
|
|
|
|
|
|
|
_PyObject_GC_UNTRACK(self);
|
|
|
|
Py_XDECREF(gs->prop_get);
|
|
|
|
Py_XDECREF(gs->prop_set);
|
|
|
|
Py_XDECREF(gs->prop_del);
|
|
|
|
Py_XDECREF(gs->prop_doc);
|
|
|
|
self->ob_type->tp_free(self);
|
2001-08-23 21:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2001-09-06 21:56:42 +00:00
|
|
|
property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
2001-08-23 21:40:38 +00:00
|
|
|
{
|
2015-05-24 18:38:06 +00:00
|
|
|
static PyObject * volatile cached_args = NULL;
|
|
|
|
PyObject *args;
|
2015-04-30 15:08:13 +00:00
|
|
|
PyObject *ret;
|
2010-05-09 15:52:27 +00:00
|
|
|
propertyobject *gs = (propertyobject *)self;
|
|
|
|
|
|
|
|
if (obj == NULL || obj == Py_None) {
|
|
|
|
Py_INCREF(self);
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
if (gs->prop_get == NULL) {
|
|
|
|
PyErr_SetString(PyExc_AttributeError, "unreadable attribute");
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-05-24 18:38:06 +00:00
|
|
|
args = cached_args;
|
2016-05-04 18:42:05 +00:00
|
|
|
cached_args = NULL;
|
|
|
|
if (!args) {
|
|
|
|
args = PyTuple_New(1);
|
|
|
|
if (!args)
|
2015-05-24 18:38:06 +00:00
|
|
|
return NULL;
|
2016-05-04 18:42:05 +00:00
|
|
|
_PyObject_GC_UNTRACK(args);
|
2015-04-30 15:08:13 +00:00
|
|
|
}
|
2015-05-24 18:38:06 +00:00
|
|
|
Py_INCREF(obj);
|
2015-04-30 15:08:13 +00:00
|
|
|
PyTuple_SET_ITEM(args, 0, obj);
|
|
|
|
ret = PyObject_Call(gs->prop_get, args, NULL);
|
2016-05-04 18:42:05 +00:00
|
|
|
if (cached_args == NULL && Py_REFCNT(args) == 1) {
|
2017-03-21 06:53:25 +00:00
|
|
|
assert(PyTuple_GET_SIZE(args) == 1);
|
2016-05-04 18:42:05 +00:00
|
|
|
assert(PyTuple_GET_ITEM(args, 0) == obj);
|
|
|
|
cached_args = args;
|
|
|
|
Py_DECREF(obj);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
assert(Py_REFCNT(args) >= 1);
|
|
|
|
_PyObject_GC_TRACK(args);
|
|
|
|
Py_DECREF(args);
|
2015-05-24 18:38:06 +00:00
|
|
|
}
|
2015-04-30 15:08:13 +00:00
|
|
|
return ret;
|
2001-08-23 21:40:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-09-06 21:56:42 +00:00
|
|
|
property_descr_set(PyObject *self, PyObject *obj, PyObject *value)
|
2001-08-23 21:40:38 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
propertyobject *gs = (propertyobject *)self;
|
|
|
|
PyObject *func, *res;
|
|
|
|
|
|
|
|
if (value == NULL)
|
|
|
|
func = gs->prop_del;
|
|
|
|
else
|
|
|
|
func = gs->prop_set;
|
|
|
|
if (func == NULL) {
|
|
|
|
PyErr_SetString(PyExc_AttributeError,
|
|
|
|
value == NULL ?
|
|
|
|
"can't delete attribute" :
|
|
|
|
"can't set attribute");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (value == NULL)
|
2016-12-04 21:59:09 +00:00
|
|
|
res = PyObject_CallFunctionObjArgs(func, obj, NULL);
|
2010-05-09 15:52:27 +00:00
|
|
|
else
|
2010-12-07 04:04:02 +00:00
|
|
|
res = PyObject_CallFunctionObjArgs(func, obj, value, NULL);
|
2010-05-09 15:52:27 +00:00
|
|
|
if (res == NULL)
|
|
|
|
return -1;
|
|
|
|
Py_DECREF(res);
|
|
|
|
return 0;
|
2001-08-23 21:40:38 +00:00
|
|
|
}
|
|
|
|
|
Merged revisions 59488-59511 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59489 | christian.heimes | 2007-12-14 03:33:57 +0100 (Fri, 14 Dec 2007) | 1 line
Silence a warning about an unsed variable in debug builds
........
r59490 | christian.heimes | 2007-12-14 03:35:23 +0100 (Fri, 14 Dec 2007) | 2 lines
Fixed bug #1620: New @spam.getter property syntax modifies the property in place.
I added also the feature that a @prop.getter decorator does not overwrite the doc string of the property if it was given as an argument to property().
........
r59491 | raymond.hettinger | 2007-12-14 03:49:47 +0100 (Fri, 14 Dec 2007) | 1 line
Cleaner method naming convention
........
r59492 | christian.heimes | 2007-12-14 04:02:34 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments.
........
r59493 | christian.heimes | 2007-12-14 05:38:13 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed warning in ssl module
........
r59500 | raymond.hettinger | 2007-12-14 19:08:20 +0100 (Fri, 14 Dec 2007) | 1 line
Add line spacing for readability
........
r59501 | raymond.hettinger | 2007-12-14 19:12:21 +0100 (Fri, 14 Dec 2007) | 3 lines
Update method names for named tuples.
........
r59503 | georg.brandl | 2007-12-14 20:03:36 +0100 (Fri, 14 Dec 2007) | 3 lines
Add a section about nested listcomps to the tutorial.
Thanks to Ian Bruntlett and Robert Lehmann.
........
r59504 | raymond.hettinger | 2007-12-14 20:19:59 +0100 (Fri, 14 Dec 2007) | 1 line
Faster and simpler _replace() method
........
r59505 | raymond.hettinger | 2007-12-14 22:51:50 +0100 (Fri, 14 Dec 2007) | 1 line
Add usage note
........
r59507 | andrew.kuchling | 2007-12-14 23:41:18 +0100 (Fri, 14 Dec 2007) | 1 line
Remove warning about URL
........
r59510 | andrew.kuchling | 2007-12-14 23:52:36 +0100 (Fri, 14 Dec 2007) | 1 line
Bump the version number, and make a few small edits
........
r59511 | christian.heimes | 2007-12-15 00:42:36 +0100 (Sat, 15 Dec 2007) | 2 lines
Fixed bug #1628
The detection now works on Unix with Makefile, Makefile with VPATH and on Windows.
........
2007-12-15 01:27:15 +00:00
|
|
|
static PyObject *
|
2010-06-28 03:07:10 +00:00
|
|
|
property_copy(PyObject *old, PyObject *get, PyObject *set, PyObject *del)
|
Merged revisions 59488-59511 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59489 | christian.heimes | 2007-12-14 03:33:57 +0100 (Fri, 14 Dec 2007) | 1 line
Silence a warning about an unsed variable in debug builds
........
r59490 | christian.heimes | 2007-12-14 03:35:23 +0100 (Fri, 14 Dec 2007) | 2 lines
Fixed bug #1620: New @spam.getter property syntax modifies the property in place.
I added also the feature that a @prop.getter decorator does not overwrite the doc string of the property if it was given as an argument to property().
........
r59491 | raymond.hettinger | 2007-12-14 03:49:47 +0100 (Fri, 14 Dec 2007) | 1 line
Cleaner method naming convention
........
r59492 | christian.heimes | 2007-12-14 04:02:34 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments.
........
r59493 | christian.heimes | 2007-12-14 05:38:13 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed warning in ssl module
........
r59500 | raymond.hettinger | 2007-12-14 19:08:20 +0100 (Fri, 14 Dec 2007) | 1 line
Add line spacing for readability
........
r59501 | raymond.hettinger | 2007-12-14 19:12:21 +0100 (Fri, 14 Dec 2007) | 3 lines
Update method names for named tuples.
........
r59503 | georg.brandl | 2007-12-14 20:03:36 +0100 (Fri, 14 Dec 2007) | 3 lines
Add a section about nested listcomps to the tutorial.
Thanks to Ian Bruntlett and Robert Lehmann.
........
r59504 | raymond.hettinger | 2007-12-14 20:19:59 +0100 (Fri, 14 Dec 2007) | 1 line
Faster and simpler _replace() method
........
r59505 | raymond.hettinger | 2007-12-14 22:51:50 +0100 (Fri, 14 Dec 2007) | 1 line
Add usage note
........
r59507 | andrew.kuchling | 2007-12-14 23:41:18 +0100 (Fri, 14 Dec 2007) | 1 line
Remove warning about URL
........
r59510 | andrew.kuchling | 2007-12-14 23:52:36 +0100 (Fri, 14 Dec 2007) | 1 line
Bump the version number, and make a few small edits
........
r59511 | christian.heimes | 2007-12-15 00:42:36 +0100 (Sat, 15 Dec 2007) | 2 lines
Fixed bug #1628
The detection now works on Unix with Makefile, Makefile with VPATH and on Windows.
........
2007-12-15 01:27:15 +00:00
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
propertyobject *pold = (propertyobject *)old;
|
2010-06-28 03:07:10 +00:00
|
|
|
PyObject *new, *type, *doc;
|
2010-05-09 15:52:27 +00:00
|
|
|
|
|
|
|
type = PyObject_Type(old);
|
|
|
|
if (type == NULL)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (get == NULL || get == Py_None) {
|
|
|
|
Py_XDECREF(get);
|
|
|
|
get = pold->prop_get ? pold->prop_get : Py_None;
|
|
|
|
}
|
|
|
|
if (set == NULL || set == Py_None) {
|
|
|
|
Py_XDECREF(set);
|
|
|
|
set = pold->prop_set ? pold->prop_set : Py_None;
|
|
|
|
}
|
|
|
|
if (del == NULL || del == Py_None) {
|
|
|
|
Py_XDECREF(del);
|
|
|
|
del = pold->prop_del ? pold->prop_del : Py_None;
|
|
|
|
}
|
2010-06-28 03:07:10 +00:00
|
|
|
if (pold->getter_doc && get != Py_None) {
|
|
|
|
/* make _init use __doc__ from getter */
|
|
|
|
doc = Py_None;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
doc = pold->prop_doc ? pold->prop_doc : Py_None;
|
2010-05-09 15:52:27 +00:00
|
|
|
}
|
|
|
|
|
2016-12-09 15:22:32 +00:00
|
|
|
new = PyObject_CallFunctionObjArgs(type, get, set, del, doc, NULL);
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_DECREF(type);
|
|
|
|
if (new == NULL)
|
|
|
|
return NULL;
|
|
|
|
return new;
|
Merged revisions 59488-59511 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r59489 | christian.heimes | 2007-12-14 03:33:57 +0100 (Fri, 14 Dec 2007) | 1 line
Silence a warning about an unsed variable in debug builds
........
r59490 | christian.heimes | 2007-12-14 03:35:23 +0100 (Fri, 14 Dec 2007) | 2 lines
Fixed bug #1620: New @spam.getter property syntax modifies the property in place.
I added also the feature that a @prop.getter decorator does not overwrite the doc string of the property if it was given as an argument to property().
........
r59491 | raymond.hettinger | 2007-12-14 03:49:47 +0100 (Fri, 14 Dec 2007) | 1 line
Cleaner method naming convention
........
r59492 | christian.heimes | 2007-12-14 04:02:34 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed a warning in _codecs_iso2022.c and some non C89 conform // comments.
........
r59493 | christian.heimes | 2007-12-14 05:38:13 +0100 (Fri, 14 Dec 2007) | 1 line
Fixed warning in ssl module
........
r59500 | raymond.hettinger | 2007-12-14 19:08:20 +0100 (Fri, 14 Dec 2007) | 1 line
Add line spacing for readability
........
r59501 | raymond.hettinger | 2007-12-14 19:12:21 +0100 (Fri, 14 Dec 2007) | 3 lines
Update method names for named tuples.
........
r59503 | georg.brandl | 2007-12-14 20:03:36 +0100 (Fri, 14 Dec 2007) | 3 lines
Add a section about nested listcomps to the tutorial.
Thanks to Ian Bruntlett and Robert Lehmann.
........
r59504 | raymond.hettinger | 2007-12-14 20:19:59 +0100 (Fri, 14 Dec 2007) | 1 line
Faster and simpler _replace() method
........
r59505 | raymond.hettinger | 2007-12-14 22:51:50 +0100 (Fri, 14 Dec 2007) | 1 line
Add usage note
........
r59507 | andrew.kuchling | 2007-12-14 23:41:18 +0100 (Fri, 14 Dec 2007) | 1 line
Remove warning about URL
........
r59510 | andrew.kuchling | 2007-12-14 23:52:36 +0100 (Fri, 14 Dec 2007) | 1 line
Bump the version number, and make a few small edits
........
r59511 | christian.heimes | 2007-12-15 00:42:36 +0100 (Sat, 15 Dec 2007) | 2 lines
Fixed bug #1628
The detection now works on Unix with Makefile, Makefile with VPATH and on Windows.
........
2007-12-15 01:27:15 +00:00
|
|
|
}
|
|
|
|
|
2017-03-19 06:51:07 +00:00
|
|
|
/*[clinic input]
|
|
|
|
property.__init__ as property_init
|
2010-05-09 15:52:27 +00:00
|
|
|
|
2017-03-19 06:51:07 +00:00
|
|
|
fget: object(c_default="NULL") = None
|
|
|
|
function to be used for getting an attribute value
|
|
|
|
fset: object(c_default="NULL") = None
|
|
|
|
function to be used for setting an attribute value
|
|
|
|
fdel: object(c_default="NULL") = None
|
|
|
|
function to be used for del'ing an attribute
|
|
|
|
doc: object(c_default="NULL") = None
|
|
|
|
docstring
|
|
|
|
|
|
|
|
Property attribute.
|
|
|
|
|
|
|
|
Typical use is to define a managed attribute x:
|
2010-05-09 15:52:27 +00:00
|
|
|
|
2017-03-19 06:51:07 +00:00
|
|
|
class C(object):
|
|
|
|
def getx(self): return self._x
|
|
|
|
def setx(self, value): self._x = value
|
|
|
|
def delx(self): del self._x
|
|
|
|
x = property(getx, setx, delx, "I'm the 'x' property.")
|
2010-05-09 15:52:27 +00:00
|
|
|
|
2017-03-19 06:51:07 +00:00
|
|
|
Decorators make defining new properties or modifying existing ones easy:
|
|
|
|
|
|
|
|
class C(object):
|
|
|
|
@property
|
|
|
|
def x(self):
|
|
|
|
"I am the 'x' property."
|
|
|
|
return self._x
|
|
|
|
@x.setter
|
|
|
|
def x(self, value):
|
|
|
|
self._x = value
|
|
|
|
@x.deleter
|
|
|
|
def x(self):
|
|
|
|
del self._x
|
|
|
|
[clinic start generated code]*/
|
|
|
|
|
|
|
|
static int
|
|
|
|
property_init_impl(propertyobject *self, PyObject *fget, PyObject *fset,
|
|
|
|
PyObject *fdel, PyObject *doc)
|
|
|
|
/*[clinic end generated code: output=01a960742b692b57 input=dfb5dbbffc6932d5]*/
|
|
|
|
{
|
|
|
|
if (fget == Py_None)
|
|
|
|
fget = NULL;
|
|
|
|
if (fset == Py_None)
|
|
|
|
fset = NULL;
|
|
|
|
if (fdel == Py_None)
|
|
|
|
fdel = NULL;
|
|
|
|
|
|
|
|
Py_XINCREF(fget);
|
|
|
|
Py_XINCREF(fset);
|
|
|
|
Py_XINCREF(fdel);
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_XINCREF(doc);
|
|
|
|
|
2017-03-19 06:51:07 +00:00
|
|
|
self->prop_get = fget;
|
|
|
|
self->prop_set = fset;
|
|
|
|
self->prop_del = fdel;
|
|
|
|
self->prop_doc = doc;
|
|
|
|
self->getter_doc = 0;
|
2010-05-09 15:52:27 +00:00
|
|
|
|
|
|
|
/* if no docstring given and the getter has one, use that one */
|
2017-03-19 06:51:07 +00:00
|
|
|
if ((doc == NULL || doc == Py_None) && fget != NULL) {
|
2011-10-14 08:20:37 +00:00
|
|
|
_Py_IDENTIFIER(__doc__);
|
2017-03-19 06:51:07 +00:00
|
|
|
PyObject *get_doc = _PyObject_GetAttrId(fget, &PyId___doc__);
|
2010-05-09 15:52:27 +00:00
|
|
|
if (get_doc) {
|
|
|
|
if (Py_TYPE(self) == &PyProperty_Type) {
|
2017-03-19 06:51:07 +00:00
|
|
|
Py_XSETREF(self->prop_doc, get_doc);
|
2010-05-09 15:52:27 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* If this is a property subclass, put __doc__
|
|
|
|
in dict of the subclass instance instead,
|
|
|
|
otherwise it gets shadowed by __doc__ in the
|
|
|
|
class's dict. */
|
2017-03-19 06:51:07 +00:00
|
|
|
int err = _PyObject_SetAttrId((PyObject *)self, &PyId___doc__, get_doc);
|
2010-05-09 15:52:27 +00:00
|
|
|
Py_DECREF(get_doc);
|
|
|
|
if (err < 0)
|
|
|
|
return -1;
|
|
|
|
}
|
2017-03-19 06:51:07 +00:00
|
|
|
self->getter_doc = 1;
|
2010-05-09 15:52:27 +00:00
|
|
|
}
|
|
|
|
else if (PyErr_ExceptionMatches(PyExc_Exception)) {
|
|
|
|
PyErr_Clear();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2001-08-23 21:40:38 +00:00
|
|
|
}
|
|
|
|
|
2011-12-15 20:34:02 +00:00
|
|
|
static PyObject *
|
|
|
|
property_get___isabstractmethod__(propertyobject *prop, void *closure)
|
|
|
|
{
|
|
|
|
int res = _PyObject_IsAbstract(prop->prop_get);
|
|
|
|
if (res == -1) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else if (res) {
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = _PyObject_IsAbstract(prop->prop_set);
|
|
|
|
if (res == -1) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else if (res) {
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
res = _PyObject_IsAbstract(prop->prop_del);
|
|
|
|
if (res == -1) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
else if (res) {
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
}
|
|
|
|
Py_RETURN_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyGetSetDef property_getsetlist[] = {
|
|
|
|
{"__isabstractmethod__",
|
|
|
|
(getter)property_get___isabstractmethod__, NULL,
|
|
|
|
NULL,
|
|
|
|
NULL},
|
|
|
|
{NULL} /* Sentinel */
|
|
|
|
};
|
|
|
|
|
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 21:24:57 +00:00
|
|
|
static int
|
|
|
|
property_traverse(PyObject *self, visitproc visit, void *arg)
|
|
|
|
{
|
2010-05-09 15:52:27 +00:00
|
|
|
propertyobject *pp = (propertyobject *)self;
|
|
|
|
Py_VISIT(pp->prop_get);
|
|
|
|
Py_VISIT(pp->prop_set);
|
|
|
|
Py_VISIT(pp->prop_del);
|
|
|
|
Py_VISIT(pp->prop_doc);
|
|
|
|
return 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 21:24:57 +00:00
|
|
|
}
|
|
|
|
|
2015-05-13 18:12:33 +00:00
|
|
|
static int
|
|
|
|
property_clear(PyObject *self)
|
|
|
|
{
|
|
|
|
propertyobject *pp = (propertyobject *)self;
|
|
|
|
Py_CLEAR(pp->prop_doc);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-19 06:51:07 +00:00
|
|
|
#include "clinic/descrobject.c.h"
|
|
|
|
|
|
|
|
PyTypeObject PyDictProxy_Type = {
|
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"mappingproxy", /* tp_name */
|
|
|
|
sizeof(mappingproxyobject), /* tp_basicsize */
|
|
|
|
0, /* tp_itemsize */
|
|
|
|
/* methods */
|
|
|
|
(destructor)mappingproxy_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_reserved */
|
|
|
|
(reprfunc)mappingproxy_repr, /* tp_repr */
|
|
|
|
0, /* tp_as_number */
|
|
|
|
&mappingproxy_as_sequence, /* tp_as_sequence */
|
|
|
|
&mappingproxy_as_mapping, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
|
|
|
0, /* tp_call */
|
|
|
|
(reprfunc)mappingproxy_str, /* 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 */
|
|
|
|
mappingproxy_traverse, /* tp_traverse */
|
|
|
|
0, /* tp_clear */
|
|
|
|
(richcmpfunc)mappingproxy_richcompare, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
(getiterfunc)mappingproxy_getiter, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
mappingproxy_methods, /* tp_methods */
|
|
|
|
0, /* tp_members */
|
|
|
|
0, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
0, /* tp_descr_get */
|
|
|
|
0, /* tp_descr_set */
|
|
|
|
0, /* tp_dictoffset */
|
|
|
|
0, /* tp_init */
|
|
|
|
0, /* tp_alloc */
|
|
|
|
mappingproxy_new, /* tp_new */
|
|
|
|
};
|
|
|
|
|
2001-09-06 21:56:42 +00:00
|
|
|
PyTypeObject PyProperty_Type = {
|
2010-05-09 15:52:27 +00:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"property", /* tp_name */
|
|
|
|
sizeof(propertyobject), /* tp_basicsize */
|
|
|
|
0, /* tp_itemsize */
|
|
|
|
/* methods */
|
|
|
|
property_dealloc, /* tp_dealloc */
|
|
|
|
0, /* tp_print */
|
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
|
|
|
0, /* tp_reserved */
|
|
|
|
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 */
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
|
|
|
Py_TPFLAGS_BASETYPE, /* tp_flags */
|
2017-03-19 06:51:07 +00:00
|
|
|
property_init__doc__, /* tp_doc */
|
2010-05-09 15:52:27 +00:00
|
|
|
property_traverse, /* tp_traverse */
|
2015-05-13 18:12:33 +00:00
|
|
|
(inquiry)property_clear, /* tp_clear */
|
2010-05-09 15:52:27 +00:00
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
property_methods, /* tp_methods */
|
|
|
|
property_members, /* tp_members */
|
2011-12-15 20:34:02 +00:00
|
|
|
property_getsetlist, /* tp_getset */
|
2010-05-09 15:52:27 +00:00
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
|
|
|
property_descr_get, /* tp_descr_get */
|
|
|
|
property_descr_set, /* tp_descr_set */
|
|
|
|
0, /* tp_dictoffset */
|
|
|
|
property_init, /* tp_init */
|
|
|
|
PyType_GenericAlloc, /* tp_alloc */
|
|
|
|
PyType_GenericNew, /* tp_new */
|
|
|
|
PyObject_GC_Del, /* tp_free */
|
2001-08-23 21:40:38 +00:00
|
|
|
};
|