2001-08-02 01:15:00 -03:00
|
|
|
/* Descriptors -- a new, flexible way to describe attributes */
|
|
|
|
|
|
|
|
#include "Python.h"
|
2023-06-26 10:38:41 -03:00
|
|
|
#include "pycore_abstract.h" // _PyObject_RealIsSubclass()
|
2023-06-27 20:34:37 -03:00
|
|
|
#include "pycore_call.h" // _PyStack_AsDict()
|
2022-05-04 08:30:23 -03:00
|
|
|
#include "pycore_ceval.h" // _Py_EnterRecursiveCallTstate()
|
2023-09-15 19:04:21 -03:00
|
|
|
#include "pycore_emscripten_trampoline.h" // descr_set_trampoline_call(), descr_get_trampoline_call()
|
2023-07-22 17:57:59 -03:00
|
|
|
#include "pycore_descrobject.h" // _PyMethodWrapper_Type
|
2023-10-17 09:30:31 -03:00
|
|
|
#include "pycore_modsupport.h" // _PyArg_UnpackStack()
|
2020-06-22 12:27:35 -03:00
|
|
|
#include "pycore_object.h" // _PyObject_GC_UNTRACK()
|
|
|
|
#include "pycore_pystate.h" // _PyThreadState_GET()
|
|
|
|
#include "pycore_tuple.h" // _PyTuple_ITEMS()
|
2023-07-25 10:28:30 -03:00
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2017-03-19 03:51:07 -03: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 01:15:00 -03:00
|
|
|
static void
|
2024-01-02 10:03:39 -04:00
|
|
|
descr_dealloc(PyObject *self)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyDescrObject *descr = (PyDescrObject *)self;
|
2010-05-09 12:52:27 -03:00
|
|
|
_PyObject_GC_UNTRACK(descr);
|
|
|
|
Py_XDECREF(descr->d_type);
|
|
|
|
Py_XDECREF(descr->d_name);
|
2011-12-12 08:47:25 -04:00
|
|
|
Py_XDECREF(descr->d_qualname);
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject_GC_Del(descr);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2007-06-11 13:36:59 -03:00
|
|
|
static PyObject *
|
2001-08-02 01:15:00 -03:00
|
|
|
descr_name(PyDescrObject *descr)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (descr->d_name != NULL && PyUnicode_Check(descr->d_name))
|
|
|
|
return descr->d_name;
|
|
|
|
return NULL;
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2015-12-25 14:01:53 -04:00
|
|
|
descr_repr(PyDescrObject *descr, const char *format)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *name = NULL;
|
|
|
|
if (descr->d_name != NULL && PyUnicode_Check(descr->d_name))
|
|
|
|
name = descr->d_name;
|
2007-06-11 13:36:59 -03:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
return PyUnicode_FromFormat(format, name, "?", descr->d_type->tp_name);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
method_repr(PyObject *descr)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
return descr_repr((PyDescrObject *)descr,
|
|
|
|
"<method '%V' of '%s' objects>");
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
member_repr(PyObject *descr)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
return descr_repr((PyDescrObject *)descr,
|
|
|
|
"<member '%V' of '%s' objects>");
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
getset_repr(PyObject *descr)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
return descr_repr((PyDescrObject *)descr,
|
|
|
|
"<attribute '%V' of '%s' objects>");
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperdescr_repr(PyObject *descr)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
return descr_repr((PyDescrObject *)descr,
|
|
|
|
"<slot wrapper '%V' of '%s' objects>");
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2021-10-06 21:51:56 -03:00
|
|
|
descr_check(PyDescrObject *descr, PyObject *obj)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (!PyObject_TypeCheck(obj, descr->d_type)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
2019-04-01 05:56:11 -03:00
|
|
|
"descriptor '%V' for '%.100s' objects "
|
|
|
|
"doesn't apply to a '%.100s' object",
|
2010-05-09 12:52:27 -03:00
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
descr->d_type->tp_name,
|
2020-02-06 22:04:21 -04:00
|
|
|
Py_TYPE(obj)->tp_name);
|
2021-10-06 21:51:56 -03:00
|
|
|
return -1;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
return 0;
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2002-12-09 18:56:13 -04:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
classmethod_get(PyObject *self, PyObject *obj, PyObject *type)
|
2002-12-09 18:56:13 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyMethodDescrObject *descr = (PyMethodDescrObject *)self;
|
2010-05-09 12:52:27 -03:00
|
|
|
/* Ensure a valid type. Class methods ignore obj. */
|
|
|
|
if (type == NULL) {
|
|
|
|
if (obj != NULL)
|
2020-02-06 22:04:21 -04:00
|
|
|
type = (PyObject *)Py_TYPE(obj);
|
2010-05-09 12:52:27 -03:00
|
|
|
else {
|
|
|
|
/* Wot - no type?! */
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
2019-04-01 05:56:11 -03:00
|
|
|
"descriptor '%V' for type '%.100s' "
|
2010-05-09 12:52:27 -03:00
|
|
|
"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,
|
2019-04-01 05:56:11 -03:00
|
|
|
"descriptor '%V' for type '%.100s' "
|
|
|
|
"needs a type, not a '%.100s' as arg 2",
|
2010-05-09 12:52:27 -03:00
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name,
|
2020-02-06 22:04:21 -04:00
|
|
|
Py_TYPE(type)->tp_name);
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (!PyType_IsSubtype((PyTypeObject *)type, PyDescr_TYPE(descr))) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
2019-04-01 05:56:11 -03:00
|
|
|
"descriptor '%V' requires a subtype of '%.100s' "
|
|
|
|
"but received '%.100s'",
|
2010-05-09 12:52:27 -03:00
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name,
|
|
|
|
((PyTypeObject *)type)->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
2020-05-07 10:39:59 -03:00
|
|
|
PyTypeObject *cls = NULL;
|
|
|
|
if (descr->d_method->ml_flags & METH_METHOD) {
|
|
|
|
cls = descr->d_common.d_type;
|
|
|
|
}
|
|
|
|
return PyCMethod_New(descr->d_method, type, NULL, cls);
|
2002-12-09 18:56:13 -04:00
|
|
|
}
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
method_get(PyObject *self, PyObject *obj, PyObject *type)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyMethodDescrObject *descr = (PyMethodDescrObject *)self;
|
2021-10-06 21:51:56 -03:00
|
|
|
if (obj == NULL) {
|
|
|
|
return Py_NewRef(descr);
|
|
|
|
}
|
|
|
|
if (descr_check((PyDescrObject *)descr, obj) < 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2020-05-07 10:39:59 -03:00
|
|
|
if (descr->d_method->ml_flags & METH_METHOD) {
|
|
|
|
if (PyType_Check(type)) {
|
|
|
|
return PyCMethod_New(descr->d_method, obj, NULL, descr->d_common.d_type);
|
|
|
|
} else {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' needs a type, not '%s', as arg 2",
|
|
|
|
descr_name((PyDescrObject *)descr),
|
|
|
|
Py_TYPE(type)->tp_name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return PyCFunction_NewEx(descr->d_method, obj, NULL);
|
|
|
|
}
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
member_get(PyObject *self, PyObject *obj, PyObject *type)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyMemberDescrObject *descr = (PyMemberDescrObject *)self;
|
2021-10-06 21:51:56 -03:00
|
|
|
if (obj == NULL) {
|
|
|
|
return Py_NewRef(descr);
|
|
|
|
}
|
|
|
|
if (descr_check((PyDescrObject *)descr, obj) < 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-05-23 12:45:22 -03:00
|
|
|
|
2023-07-25 10:28:30 -03:00
|
|
|
if (descr->d_member->flags & Py_AUDIT_READ) {
|
2019-05-23 12:45:22 -03:00
|
|
|
if (PySys_Audit("object.__getattr__", "Os",
|
|
|
|
obj ? obj : Py_None, descr->d_member->name) < 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
return PyMember_GetOne((char *)obj, descr->d_member);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
getset_get(PyObject *self, PyObject *obj, PyObject *type)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyGetSetDescrObject *descr = (PyGetSetDescrObject *)self;
|
2021-10-06 21:51:56 -03:00
|
|
|
if (obj == NULL) {
|
|
|
|
return Py_NewRef(descr);
|
|
|
|
}
|
|
|
|
if (descr_check((PyDescrObject *)descr, obj) < 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
if (descr->d_getset->get != NULL)
|
2022-03-30 16:28:33 -03:00
|
|
|
return descr_get_trampoline_call(
|
|
|
|
descr->d_getset->get, obj, descr->d_getset->closure);
|
2010-05-09 12:52:27 -03:00
|
|
|
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 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperdescr_get(PyObject *self, PyObject *obj, PyObject *type)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyWrapperDescrObject *descr = (PyWrapperDescrObject *)self;
|
2021-10-06 21:51:56 -03:00
|
|
|
if (obj == NULL) {
|
|
|
|
return Py_NewRef(descr);
|
|
|
|
}
|
|
|
|
if (descr_check((PyDescrObject *)descr, obj) < 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
return PyWrapper_New((PyObject *)descr, obj);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2021-10-06 21:51:56 -03:00
|
|
|
descr_setcheck(PyDescrObject *descr, PyObject *obj, PyObject *value)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
assert(obj != NULL);
|
|
|
|
if (!PyObject_TypeCheck(obj, descr->d_type)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' for '%.100s' objects "
|
2019-04-01 05:56:11 -03:00
|
|
|
"doesn't apply to a '%.100s' object",
|
2010-05-09 12:52:27 -03:00
|
|
|
descr_name(descr), "?",
|
|
|
|
descr->d_type->tp_name,
|
2020-02-06 22:04:21 -04:00
|
|
|
Py_TYPE(obj)->tp_name);
|
2021-10-06 21:51:56 -03:00
|
|
|
return -1;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
return 0;
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2024-01-02 10:03:39 -04:00
|
|
|
member_set(PyObject *self, PyObject *obj, PyObject *value)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyMemberDescrObject *descr = (PyMemberDescrObject *)self;
|
2021-10-06 21:51:56 -03:00
|
|
|
if (descr_setcheck((PyDescrObject *)descr, obj, value) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
return PyMember_SetOne((char *)obj, descr->d_member, value);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2024-01-02 10:03:39 -04:00
|
|
|
getset_set(PyObject *self, PyObject *obj, PyObject *value)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyGetSetDescrObject *descr = (PyGetSetDescrObject *)self;
|
2021-10-06 21:51:56 -03:00
|
|
|
if (descr_setcheck((PyDescrObject *)descr, obj, value) < 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (descr->d_getset->set != NULL) {
|
2022-03-30 16:28:33 -03:00
|
|
|
return descr_set_trampoline_call(
|
|
|
|
descr->d_getset->set, obj, value,
|
|
|
|
descr->d_getset->closure);
|
2021-10-06 21:51:56 -03:00
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
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 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2019-07-05 09:48:24 -03:00
|
|
|
/* Vectorcall functions for each of the PyMethodDescr calling conventions.
|
|
|
|
*
|
|
|
|
* First, common helpers
|
|
|
|
*/
|
|
|
|
static inline int
|
|
|
|
method_check_args(PyObject *func, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)
|
|
|
|
{
|
|
|
|
assert(!PyErr_Occurred());
|
2017-01-18 05:38:09 -04:00
|
|
|
if (nargs < 1) {
|
2019-11-05 11:48:04 -04:00
|
|
|
PyObject *funcstr = _PyObject_FunctionStr(func);
|
|
|
|
if (funcstr != NULL) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"unbound method %U needs an argument", funcstr);
|
|
|
|
Py_DECREF(funcstr);
|
|
|
|
}
|
2019-07-05 09:48:24 -03:00
|
|
|
return -1;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
2019-07-05 09:48:24 -03:00
|
|
|
PyObject *self = args[0];
|
2021-10-06 21:51:56 -03:00
|
|
|
if (descr_check((PyDescrObject *)func, self) < 0) {
|
2019-07-05 09:48:24 -03:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
if (kwnames && PyTuple_GET_SIZE(kwnames)) {
|
2019-11-05 11:48:04 -04:00
|
|
|
PyObject *funcstr = _PyObject_FunctionStr(func);
|
|
|
|
if (funcstr != NULL) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"%U takes no keyword arguments", funcstr);
|
|
|
|
Py_DECREF(funcstr);
|
|
|
|
}
|
2019-07-05 09:48:24 -03:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2019-11-05 11:48:04 -04:00
|
|
|
typedef void (*funcptr)(void);
|
|
|
|
|
2019-07-05 09:48:24 -03:00
|
|
|
static inline funcptr
|
2019-11-04 19:51:22 -04:00
|
|
|
method_enter_call(PyThreadState *tstate, PyObject *func)
|
2019-07-05 09:48:24 -03:00
|
|
|
{
|
2022-05-04 08:30:23 -03:00
|
|
|
if (_Py_EnterRecursiveCallTstate(tstate, " while calling a Python object")) {
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-07-05 09:48:24 -03:00
|
|
|
return (funcptr)((PyMethodDescrObject *)func)->d_method->ml_meth;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2019-07-05 09:48:24 -03:00
|
|
|
/* Now the actual vectorcall functions */
|
|
|
|
static PyObject *
|
|
|
|
method_vectorcall_VARARGS(
|
|
|
|
PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
|
|
|
{
|
2019-11-04 19:51:22 -04:00
|
|
|
PyThreadState *tstate = _PyThreadState_GET();
|
2019-07-05 09:48:24 -03:00
|
|
|
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
|
|
|
if (method_check_args(func, args, nargs, kwnames)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
PyObject *argstuple = _PyTuple_FromArray(args+1, nargs-1);
|
|
|
|
if (argstuple == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2019-11-04 19:51:22 -04:00
|
|
|
PyCFunction meth = (PyCFunction)method_enter_call(tstate, func);
|
2019-07-05 09:48:24 -03:00
|
|
|
if (meth == NULL) {
|
|
|
|
Py_DECREF(argstuple);
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-03-30 16:28:33 -03:00
|
|
|
PyObject *result = _PyCFunction_TrampolineCall(
|
|
|
|
meth, args[0], argstuple);
|
2019-07-05 09:48:24 -03:00
|
|
|
Py_DECREF(argstuple);
|
2022-05-04 08:30:23 -03:00
|
|
|
_Py_LeaveRecursiveCallTstate(tstate);
|
2010-05-09 12:52:27 -03:00
|
|
|
return result;
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2019-07-05 09:48:24 -03:00
|
|
|
static PyObject *
|
|
|
|
method_vectorcall_VARARGS_KEYWORDS(
|
|
|
|
PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
2017-02-02 18:43:03 -04:00
|
|
|
{
|
2019-11-04 19:51:22 -04:00
|
|
|
PyThreadState *tstate = _PyThreadState_GET();
|
2019-07-05 09:48:24 -03:00
|
|
|
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
|
|
|
if (method_check_args(func, args, nargs, NULL)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
PyObject *argstuple = _PyTuple_FromArray(args+1, nargs-1);
|
|
|
|
if (argstuple == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
PyObject *result = NULL;
|
|
|
|
/* Create a temporary dict for keyword arguments */
|
|
|
|
PyObject *kwdict = NULL;
|
|
|
|
if (kwnames != NULL && PyTuple_GET_SIZE(kwnames) > 0) {
|
|
|
|
kwdict = _PyStack_AsDict(args + nargs, kwnames);
|
|
|
|
if (kwdict == NULL) {
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PyCFunctionWithKeywords meth = (PyCFunctionWithKeywords)
|
2019-11-04 19:51:22 -04:00
|
|
|
method_enter_call(tstate, func);
|
2019-07-05 09:48:24 -03:00
|
|
|
if (meth == NULL) {
|
|
|
|
goto exit;
|
|
|
|
}
|
2022-03-30 16:28:33 -03:00
|
|
|
result = _PyCFunctionWithKeywords_TrampolineCall(
|
|
|
|
meth, args[0], argstuple, kwdict);
|
2022-05-04 08:30:23 -03:00
|
|
|
_Py_LeaveRecursiveCallTstate(tstate);
|
2019-07-05 09:48:24 -03:00
|
|
|
exit:
|
|
|
|
Py_DECREF(argstuple);
|
|
|
|
Py_XDECREF(kwdict);
|
|
|
|
return result;
|
|
|
|
}
|
2017-02-02 18:43:03 -04:00
|
|
|
|
2020-05-07 10:39:59 -03:00
|
|
|
static PyObject *
|
|
|
|
method_vectorcall_FASTCALL_KEYWORDS_METHOD(
|
|
|
|
PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
|
|
|
{
|
|
|
|
PyThreadState *tstate = _PyThreadState_GET();
|
|
|
|
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
|
|
|
if (method_check_args(func, args, nargs, NULL)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
PyCMethod meth = (PyCMethod) method_enter_call(tstate, func);
|
|
|
|
if (meth == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
PyObject *result = meth(args[0],
|
|
|
|
((PyMethodDescrObject *)func)->d_common.d_type,
|
|
|
|
args+1, nargs-1, kwnames);
|
2022-05-04 08:30:23 -03:00
|
|
|
_Py_LeaveRecursiveCall();
|
2020-05-07 10:39:59 -03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-07-05 09:48:24 -03:00
|
|
|
static PyObject *
|
|
|
|
method_vectorcall_FASTCALL(
|
|
|
|
PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
|
|
|
{
|
2019-11-04 19:51:22 -04:00
|
|
|
PyThreadState *tstate = _PyThreadState_GET();
|
2019-05-29 15:31:52 -03:00
|
|
|
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
2019-07-05 09:48:24 -03:00
|
|
|
if (method_check_args(func, args, nargs, kwnames)) {
|
2017-02-02 18:43:03 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-07-05 09:48:24 -03:00
|
|
|
_PyCFunctionFast meth = (_PyCFunctionFast)
|
2019-11-04 19:51:22 -04:00
|
|
|
method_enter_call(tstate, func);
|
2019-07-05 09:48:24 -03:00
|
|
|
if (meth == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
PyObject *result = meth(args[0], args+1, nargs-1);
|
2022-05-04 08:30:23 -03:00
|
|
|
_Py_LeaveRecursiveCallTstate(tstate);
|
2019-07-05 09:48:24 -03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
method_vectorcall_FASTCALL_KEYWORDS(
|
|
|
|
PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
|
|
|
{
|
2019-11-04 19:51:22 -04:00
|
|
|
PyThreadState *tstate = _PyThreadState_GET();
|
2019-07-05 09:48:24 -03:00
|
|
|
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
|
|
|
if (method_check_args(func, args, nargs, NULL)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
_PyCFunctionFastWithKeywords meth = (_PyCFunctionFastWithKeywords)
|
2019-11-04 19:51:22 -04:00
|
|
|
method_enter_call(tstate, func);
|
2019-07-05 09:48:24 -03:00
|
|
|
if (meth == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
PyObject *result = meth(args[0], args+1, nargs-1, kwnames);
|
2022-05-04 08:30:23 -03:00
|
|
|
_Py_LeaveRecursiveCallTstate(tstate);
|
2019-07-05 09:48:24 -03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
method_vectorcall_NOARGS(
|
|
|
|
PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
|
|
|
{
|
2019-11-04 19:51:22 -04:00
|
|
|
PyThreadState *tstate = _PyThreadState_GET();
|
2019-07-05 09:48:24 -03:00
|
|
|
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
|
|
|
if (method_check_args(func, args, nargs, kwnames)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (nargs != 1) {
|
2019-11-05 11:48:04 -04:00
|
|
|
PyObject *funcstr = _PyObject_FunctionStr(func);
|
|
|
|
if (funcstr != NULL) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"%U takes no arguments (%zd given)", funcstr, nargs-1);
|
|
|
|
Py_DECREF(funcstr);
|
|
|
|
}
|
2017-02-02 18:43:03 -04:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-11-04 19:51:22 -04:00
|
|
|
PyCFunction meth = (PyCFunction)method_enter_call(tstate, func);
|
2019-07-05 09:48:24 -03:00
|
|
|
if (meth == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-03-30 16:28:33 -03:00
|
|
|
PyObject *result = _PyCFunction_TrampolineCall(meth, args[0], NULL);
|
2022-05-04 08:30:23 -03:00
|
|
|
_Py_LeaveRecursiveCallTstate(tstate);
|
2019-07-05 09:48:24 -03:00
|
|
|
return result;
|
|
|
|
}
|
2017-02-02 18:43:03 -04:00
|
|
|
|
2019-07-05 09:48:24 -03:00
|
|
|
static PyObject *
|
|
|
|
method_vectorcall_O(
|
|
|
|
PyObject *func, PyObject *const *args, size_t nargsf, PyObject *kwnames)
|
|
|
|
{
|
2019-11-04 19:51:22 -04:00
|
|
|
PyThreadState *tstate = _PyThreadState_GET();
|
2019-07-05 09:48:24 -03:00
|
|
|
Py_ssize_t nargs = PyVectorcall_NARGS(nargsf);
|
|
|
|
if (method_check_args(func, args, nargs, kwnames)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (nargs != 2) {
|
2019-11-05 11:48:04 -04:00
|
|
|
PyObject *funcstr = _PyObject_FunctionStr(func);
|
|
|
|
if (funcstr != NULL) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"%U takes exactly one argument (%zd given)",
|
|
|
|
funcstr, nargs-1);
|
|
|
|
Py_DECREF(funcstr);
|
|
|
|
}
|
2019-07-05 09:48:24 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
2019-11-04 19:51:22 -04:00
|
|
|
PyCFunction meth = (PyCFunction)method_enter_call(tstate, func);
|
2019-07-05 09:48:24 -03:00
|
|
|
if (meth == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2022-03-30 16:28:33 -03:00
|
|
|
PyObject *result = _PyCFunction_TrampolineCall(meth, args[0], args[1]);
|
2022-05-04 08:30:23 -03:00
|
|
|
_Py_LeaveRecursiveCallTstate(tstate);
|
2017-02-02 18:43:03 -04:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2019-07-05 09:48:24 -03:00
|
|
|
|
2019-06-07 07:20:24 -03:00
|
|
|
/* Instances of classmethod_descriptor are unlikely to be called directly.
|
|
|
|
For one, the analogous class "classmethod" (for Python classes) is not
|
|
|
|
callable. Second, users are not likely to access a classmethod_descriptor
|
|
|
|
directly, since it means pulling it from the class __dict__.
|
|
|
|
|
|
|
|
This is just an excuse to say that this doesn't need to be optimized:
|
|
|
|
we implement this simply by calling __get__ and then calling the result.
|
|
|
|
*/
|
2002-12-09 18:56:13 -04:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
classmethoddescr_call(PyObject *_descr, PyObject *args,
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject *kwds)
|
2002-12-09 18:56:13 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyMethodDescrObject *descr = (PyMethodDescrObject *)_descr;
|
2019-06-07 07:20:24 -03:00
|
|
|
Py_ssize_t argc = PyTuple_GET_SIZE(args);
|
2012-05-01 10:51:09 -03:00
|
|
|
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 12:52:27 -03:00
|
|
|
return NULL;
|
2012-05-01 10:51:09 -03:00
|
|
|
}
|
2019-06-07 07:20:24 -03:00
|
|
|
PyObject *self = PyTuple_GET_ITEM(args, 0);
|
2024-01-02 10:03:39 -04:00
|
|
|
PyObject *bound = classmethod_get((PyObject *)descr, NULL, self);
|
2019-06-07 07:20:24 -03:00
|
|
|
if (bound == NULL) {
|
2012-05-01 10:51:09 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
2020-02-11 12:46:57 -04:00
|
|
|
PyObject *res = PyObject_VectorcallDict(bound, _PyTuple_ITEMS(args)+1,
|
2019-06-07 07:20:24 -03:00
|
|
|
argc-1, kwds);
|
|
|
|
Py_DECREF(bound);
|
|
|
|
return res;
|
2002-12-09 18:56:13 -04:00
|
|
|
}
|
|
|
|
|
2017-09-21 08:25:36 -03:00
|
|
|
Py_LOCAL_INLINE(PyObject *)
|
|
|
|
wrapperdescr_raw_call(PyWrapperDescrObject *descr, PyObject *self,
|
|
|
|
PyObject *args, PyObject *kwds)
|
|
|
|
{
|
|
|
|
wrapperfunc wrapper = descr->d_base->wrapper;
|
|
|
|
|
|
|
|
if (descr->d_base->flags & PyWrapperFlag_KEYWORDS) {
|
2018-11-27 15:34:27 -04:00
|
|
|
wrapperfunc_kwds wk = (wrapperfunc_kwds)(void(*)(void))wrapper;
|
2017-09-21 08:25:36 -03:00
|
|
|
return (*wk)(self, args, descr->d_wrapped, kwds);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (kwds != NULL && (!PyDict_Check(kwds) || PyDict_GET_SIZE(kwds) != 0)) {
|
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"wrapper %s() takes no keyword arguments",
|
|
|
|
descr->d_base->name);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return (*wrapper)(self, args, descr->d_wrapped);
|
|
|
|
}
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperdescr_call(PyObject *_descr, PyObject *args, PyObject *kwds)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyWrapperDescrObject *descr = (PyWrapperDescrObject *)_descr;
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_ssize_t argc;
|
2017-09-21 08:25:36 -03:00
|
|
|
PyObject *self, *result;
|
2010-05-09 12:52:27 -03: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 18:19:15 -03:00
|
|
|
if (!_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
|
2011-05-01 18:31:36 -03:00
|
|
|
(PyObject *)PyDescr_TYPE(descr))) {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyErr_Format(PyExc_TypeError,
|
|
|
|
"descriptor '%V' "
|
|
|
|
"requires a '%.100s' object "
|
|
|
|
"but received a '%.100s'",
|
|
|
|
descr_name((PyDescrObject *)descr), "?",
|
|
|
|
PyDescr_TYPE(descr)->tp_name,
|
2020-02-06 22:04:21 -04:00
|
|
|
Py_TYPE(self)->tp_name);
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2017-09-21 08:25:36 -03:00
|
|
|
args = PyTuple_GetSlice(args, 1, argc);
|
|
|
|
if (args == NULL) {
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2017-09-21 08:25:36 -03:00
|
|
|
}
|
|
|
|
result = wrapperdescr_raw_call(descr, self, args, kwds);
|
|
|
|
Py_DECREF(args);
|
2010-05-09 12:52:27 -03:00
|
|
|
return result;
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2017-09-21 08:25:36 -03:00
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
method_get_doc(PyObject *_descr, void *closure)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyMethodDescrObject *descr = (PyMethodDescrObject *)_descr;
|
2014-02-09 02:15:29 -04:00
|
|
|
return _PyType_GetDocFromInternalDoc(descr->d_method->ml_name, descr->d_method->ml_doc);
|
2014-01-24 10:17:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
method_get_text_signature(PyObject *_descr, void *closure)
|
2014-01-24 10:17:25 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyMethodDescrObject *descr = (PyMethodDescrObject *)_descr;
|
2023-08-11 12:08:38 -03:00
|
|
|
return _PyType_GetTextSignatureFromInternalDoc(descr->d_method->ml_name,
|
|
|
|
descr->d_method->ml_doc,
|
|
|
|
descr->d_method->ml_flags);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2011-12-12 08:47:25 -04:00
|
|
|
static PyObject *
|
|
|
|
calculate_qualname(PyDescrObject *descr)
|
|
|
|
{
|
|
|
|
PyObject *type_qualname, *res;
|
|
|
|
|
|
|
|
if (descr->d_name == NULL || !PyUnicode_Check(descr->d_name)) {
|
|
|
|
PyErr_SetString(PyExc_TypeError,
|
|
|
|
"<descriptor>.__name__ is not a unicode object");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2022-02-08 16:39:07 -04:00
|
|
|
type_qualname = PyObject_GetAttr(
|
|
|
|
(PyObject *)descr->d_type, &_Py_ID(__qualname__));
|
2011-12-12 08:47:25 -04:00
|
|
|
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 *
|
2024-01-02 10:03:39 -04:00
|
|
|
descr_get_qualname(PyObject *self, void *Py_UNUSED(ignored))
|
2011-12-12 08:47:25 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyDescrObject *descr = (PyDescrObject *)self;
|
2011-12-12 08:47:25 -04:00
|
|
|
if (descr->d_qualname == NULL)
|
|
|
|
descr->d_qualname = calculate_qualname(descr);
|
2022-11-10 11:27:32 -04:00
|
|
|
return Py_XNewRef(descr->d_qualname);
|
2011-12-12 08:47:25 -04:00
|
|
|
}
|
|
|
|
|
2013-11-23 13:59:12 -04:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
descr_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2013-11-23 13:59:12 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyDescrObject *descr = (PyDescrObject *)self;
|
2022-02-08 16:39:07 -04:00
|
|
|
return Py_BuildValue("N(OO)", _PyEval_GetBuiltin(&_Py_ID(getattr)),
|
2018-12-11 02:28:18 -04:00
|
|
|
PyDescr_TYPE(descr), PyDescr_NAME(descr));
|
2013-11-23 13:59:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef descr_methods[] = {
|
2024-01-02 10:03:39 -04:00
|
|
|
{"__reduce__", descr_reduce, METH_NOARGS, NULL},
|
2013-11-23 13:59:12 -04:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2001-09-20 17:46:19 -03:00
|
|
|
static PyMemberDef descr_members[] = {
|
2023-07-25 10:28:30 -03:00
|
|
|
{"__objclass__", _Py_T_OBJECT, offsetof(PyDescrObject, d_type), Py_READONLY},
|
|
|
|
{"__name__", _Py_T_OBJECT, offsetof(PyDescrObject, d_name), Py_READONLY},
|
2010-05-09 12:52:27 -03:00
|
|
|
{0}
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
2001-09-20 18:45:26 -03:00
|
|
|
static PyGetSetDef method_getset[] = {
|
2024-01-02 10:03:39 -04:00
|
|
|
{"__doc__", method_get_doc},
|
|
|
|
{"__qualname__", descr_get_qualname},
|
|
|
|
{"__text_signature__", method_get_text_signature},
|
2010-05-09 12:52:27 -03:00
|
|
|
{0}
|
2001-09-20 17:46:19 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
member_get_doc(PyObject *_descr, void *closure)
|
2001-09-20 17:46:19 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyMemberDescrObject *descr = (PyMemberDescrObject *)_descr;
|
2010-05-09 12:52:27 -03:00
|
|
|
if (descr->d_member->doc == NULL) {
|
2017-01-23 03:47:21 -04:00
|
|
|
Py_RETURN_NONE;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
return PyUnicode_FromString(descr->d_member->doc);
|
2001-09-20 17:46:19 -03:00
|
|
|
}
|
|
|
|
|
2001-09-20 18:45:26 -03:00
|
|
|
static PyGetSetDef member_getset[] = {
|
2024-01-02 10:03:39 -04:00
|
|
|
{"__doc__", member_get_doc},
|
|
|
|
{"__qualname__", descr_get_qualname},
|
2010-05-09 12:52:27 -03:00
|
|
|
{0}
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
2001-09-20 18:45:26 -03:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
getset_get_doc(PyObject *self, void *closure)
|
2001-09-20 18:45:26 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyGetSetDescrObject *descr = (PyGetSetDescrObject *)self;
|
2010-05-09 12:52:27 -03:00
|
|
|
if (descr->d_getset->doc == NULL) {
|
2017-01-23 03:47:21 -04:00
|
|
|
Py_RETURN_NONE;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
return PyUnicode_FromString(descr->d_getset->doc);
|
2001-09-20 18:45:26 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyGetSetDef getset_getset[] = {
|
2024-01-02 10:03:39 -04:00
|
|
|
{"__doc__", getset_get_doc},
|
|
|
|
{"__qualname__", descr_get_qualname},
|
2010-05-09 12:52:27 -03:00
|
|
|
{0}
|
2001-09-20 18:45:26 -03:00
|
|
|
};
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperdescr_get_doc(PyObject *self, void *closure)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyWrapperDescrObject *descr = (PyWrapperDescrObject *)self;
|
2014-02-09 02:15:29 -04:00
|
|
|
return _PyType_GetDocFromInternalDoc(descr->d_base->name, descr->d_base->doc);
|
2014-01-24 10:17:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperdescr_get_text_signature(PyObject *self, void *closure)
|
2014-01-24 10:17:25 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyWrapperDescrObject *descr = (PyWrapperDescrObject *)self;
|
2023-08-11 12:08:38 -03:00
|
|
|
return _PyType_GetTextSignatureFromInternalDoc(descr->d_base->name,
|
|
|
|
descr->d_base->doc, 0);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2005-11-07 04:38:00 -04:00
|
|
|
static PyGetSetDef wrapperdescr_getset[] = {
|
2024-01-02 10:03:39 -04:00
|
|
|
{"__doc__", wrapperdescr_get_doc},
|
|
|
|
{"__qualname__", descr_get_qualname},
|
|
|
|
{"__text_signature__", wrapperdescr_get_text_signature},
|
2010-05-09 12:52:27 -03:00
|
|
|
{0}
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
static int
|
|
|
|
descr_traverse(PyObject *self, visitproc visit, void *arg)
|
|
|
|
{
|
2010-05-09 12:52:27 -03: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 18:24:57 -03:00
|
|
|
}
|
|
|
|
|
2007-11-29 18:35:39 -04:00
|
|
|
PyTypeObject PyMethodDescr_Type = {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"method_descriptor",
|
|
|
|
sizeof(PyMethodDescrObject),
|
|
|
|
0,
|
2024-01-02 10:03:39 -04:00
|
|
|
descr_dealloc, /* tp_dealloc */
|
2019-05-29 15:31:52 -03:00
|
|
|
offsetof(PyMethodDescrObject, vectorcall), /* tp_vectorcall_offset */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_as_async */
|
2024-01-02 10:03:39 -04:00
|
|
|
method_repr, /* tp_repr */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
2019-07-05 09:48:24 -03:00
|
|
|
PyVectorcall_Call, /* tp_call */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
2019-05-28 09:42:53 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
2020-02-11 12:46:57 -04:00
|
|
|
Py_TPFLAGS_HAVE_VECTORCALL |
|
2019-05-28 09:42:53 -03:00
|
|
|
Py_TPFLAGS_METHOD_DESCRIPTOR, /* tp_flags */
|
2010-05-09 12:52:27 -03:00
|
|
|
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 13:59:12 -04:00
|
|
|
descr_methods, /* tp_methods */
|
2010-05-09 12:52:27 -03:00
|
|
|
descr_members, /* tp_members */
|
|
|
|
method_getset, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
2024-01-02 10:03:39 -04:00
|
|
|
method_get, /* tp_descr_get */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_descr_set */
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
2003-02-11 14:44:42 -04:00
|
|
|
/* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */
|
2007-11-29 18:35:39 -04:00
|
|
|
PyTypeObject PyClassMethodDescr_Type = {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"classmethod_descriptor",
|
|
|
|
sizeof(PyMethodDescrObject),
|
|
|
|
0,
|
2024-01-02 10:03:39 -04:00
|
|
|
descr_dealloc, /* tp_dealloc */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_vectorcall_offset */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_as_async */
|
2024-01-02 10:03:39 -04:00
|
|
|
method_repr, /* tp_repr */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
2024-01-02 10:03:39 -04:00
|
|
|
classmethoddescr_call, /* tp_call */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
|
|
|
0, /* tp_doc */
|
|
|
|
descr_traverse, /* tp_traverse */
|
|
|
|
0, /* tp_clear */
|
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
2022-10-05 08:21:16 -03:00
|
|
|
0, /* tp_methods */
|
2010-05-09 12:52:27 -03:00
|
|
|
descr_members, /* tp_members */
|
|
|
|
method_getset, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
2024-01-02 10:03:39 -04:00
|
|
|
classmethod_get, /* tp_descr_get */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_descr_set */
|
2002-12-09 18:56:13 -04:00
|
|
|
};
|
|
|
|
|
2007-11-29 18:35:39 -04:00
|
|
|
PyTypeObject PyMemberDescr_Type = {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"member_descriptor",
|
|
|
|
sizeof(PyMemberDescrObject),
|
|
|
|
0,
|
2024-01-02 10:03:39 -04:00
|
|
|
descr_dealloc, /* tp_dealloc */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_vectorcall_offset */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_as_async */
|
2024-01-02 10:03:39 -04:00
|
|
|
member_repr, /* tp_repr */
|
2010-05-09 12:52:27 -03:00
|
|
|
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 13:59:12 -04:00
|
|
|
descr_methods, /* tp_methods */
|
2010-05-09 12:52:27 -03:00
|
|
|
descr_members, /* tp_members */
|
|
|
|
member_getset, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
2024-01-02 10:03:39 -04:00
|
|
|
member_get, /* tp_descr_get */
|
|
|
|
member_set, /* tp_descr_set */
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
2007-11-29 18:35:39 -04:00
|
|
|
PyTypeObject PyGetSetDescr_Type = {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"getset_descriptor",
|
|
|
|
sizeof(PyGetSetDescrObject),
|
|
|
|
0,
|
2024-01-02 10:03:39 -04:00
|
|
|
descr_dealloc, /* tp_dealloc */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_vectorcall_offset */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_as_async */
|
2024-01-02 10:03:39 -04:00
|
|
|
getset_repr, /* tp_repr */
|
2010-05-09 12:52:27 -03:00
|
|
|
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 */
|
2024-01-02 10:03:39 -04:00
|
|
|
getset_get, /* tp_descr_get */
|
|
|
|
getset_set, /* tp_descr_set */
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
2001-10-03 09:09:30 -03:00
|
|
|
PyTypeObject PyWrapperDescr_Type = {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"wrapper_descriptor",
|
|
|
|
sizeof(PyWrapperDescrObject),
|
|
|
|
0,
|
2024-01-02 10:03:39 -04:00
|
|
|
descr_dealloc, /* tp_dealloc */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_vectorcall_offset */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_as_async */
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperdescr_repr, /* tp_repr */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
|
|
|
0, /* tp_hash */
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperdescr_call, /* tp_call */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
2019-05-28 09:42:53 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
|
|
|
Py_TPFLAGS_METHOD_DESCRIPTOR, /* tp_flags */
|
2010-05-09 12:52:27 -03:00
|
|
|
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 13:59:12 -04:00
|
|
|
descr_methods, /* tp_methods */
|
2010-05-09 12:52:27 -03:00
|
|
|
descr_members, /* tp_members */
|
|
|
|
wrapperdescr_getset, /* tp_getset */
|
|
|
|
0, /* tp_base */
|
|
|
|
0, /* tp_dict */
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperdescr_get, /* tp_descr_get */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_descr_set */
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyDescrObject *
|
2005-12-10 14:50:16 -04:00
|
|
|
descr_new(PyTypeObject *descrtype, PyTypeObject *type, const char *name)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyDescrObject *descr;
|
|
|
|
|
|
|
|
descr = (PyDescrObject *)PyType_GenericAlloc(descrtype, 0);
|
|
|
|
if (descr != NULL) {
|
2022-11-10 11:27:32 -04:00
|
|
|
descr->d_type = (PyTypeObject*)Py_XNewRef(type);
|
2010-05-09 12:52:27 -03:00
|
|
|
descr->d_name = PyUnicode_InternFromString(name);
|
|
|
|
if (descr->d_name == NULL) {
|
2022-11-23 09:57:50 -04:00
|
|
|
Py_SETREF(descr, NULL);
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
2011-12-17 09:02:20 -04:00
|
|
|
else {
|
|
|
|
descr->d_qualname = NULL;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
return descr;
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyDescr_NewMethod(PyTypeObject *type, PyMethodDef *method)
|
|
|
|
{
|
2019-07-05 09:48:24 -03:00
|
|
|
/* Figure out correct vectorcall function to use */
|
|
|
|
vectorcallfunc vectorcall;
|
2020-05-07 10:39:59 -03:00
|
|
|
switch (method->ml_flags & (METH_VARARGS | METH_FASTCALL | METH_NOARGS |
|
|
|
|
METH_O | METH_KEYWORDS | METH_METHOD))
|
2019-07-05 09:48:24 -03:00
|
|
|
{
|
|
|
|
case METH_VARARGS:
|
|
|
|
vectorcall = method_vectorcall_VARARGS;
|
|
|
|
break;
|
|
|
|
case METH_VARARGS | METH_KEYWORDS:
|
|
|
|
vectorcall = method_vectorcall_VARARGS_KEYWORDS;
|
|
|
|
break;
|
|
|
|
case METH_FASTCALL:
|
|
|
|
vectorcall = method_vectorcall_FASTCALL;
|
|
|
|
break;
|
|
|
|
case METH_FASTCALL | METH_KEYWORDS:
|
|
|
|
vectorcall = method_vectorcall_FASTCALL_KEYWORDS;
|
|
|
|
break;
|
|
|
|
case METH_NOARGS:
|
|
|
|
vectorcall = method_vectorcall_NOARGS;
|
|
|
|
break;
|
|
|
|
case METH_O:
|
|
|
|
vectorcall = method_vectorcall_O;
|
|
|
|
break;
|
2020-05-07 10:39:59 -03:00
|
|
|
case METH_METHOD | METH_FASTCALL | METH_KEYWORDS:
|
|
|
|
vectorcall = method_vectorcall_FASTCALL_KEYWORDS_METHOD;
|
|
|
|
break;
|
2019-07-05 09:48:24 -03:00
|
|
|
default:
|
2020-03-12 04:38:11 -03:00
|
|
|
PyErr_Format(PyExc_SystemError,
|
|
|
|
"%s() method: bad call flags", method->ml_name);
|
2019-07-05 09:48:24 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
PyMethodDescrObject *descr;
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
descr = (PyMethodDescrObject *)descr_new(&PyMethodDescr_Type,
|
|
|
|
type, method->ml_name);
|
2019-05-29 15:31:52 -03:00
|
|
|
if (descr != NULL) {
|
2010-05-09 12:52:27 -03:00
|
|
|
descr->d_method = method;
|
2019-07-05 09:48:24 -03:00
|
|
|
descr->vectorcall = vectorcall;
|
2019-05-29 15:31:52 -03:00
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
return (PyObject *)descr;
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2002-12-09 18:56:13 -04:00
|
|
|
PyObject *
|
|
|
|
PyDescr_NewClassMethod(PyTypeObject *type, PyMethodDef *method)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyMethodDescrObject *descr;
|
2002-12-09 18:56:13 -04:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
descr = (PyMethodDescrObject *)descr_new(&PyClassMethodDescr_Type,
|
|
|
|
type, method->ml_name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_method = method;
|
|
|
|
return (PyObject *)descr;
|
2002-12-09 18:56:13 -04:00
|
|
|
}
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
PyObject *
|
2001-09-20 17:46:19 -03:00
|
|
|
PyDescr_NewMember(PyTypeObject *type, PyMemberDef *member)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyMemberDescrObject *descr;
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2023-05-04 04:56:53 -03:00
|
|
|
if (member->flags & Py_RELATIVE_OFFSET) {
|
|
|
|
PyErr_SetString(
|
|
|
|
PyExc_SystemError,
|
|
|
|
"PyDescr_NewMember used with Py_RELATIVE_OFFSET");
|
|
|
|
return NULL;
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
descr = (PyMemberDescrObject *)descr_new(&PyMemberDescr_Type,
|
|
|
|
type, member->name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_member = member;
|
|
|
|
return (PyObject *)descr;
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
2001-09-20 18:45:26 -03:00
|
|
|
PyDescr_NewGetSet(PyTypeObject *type, PyGetSetDef *getset)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
PyGetSetDescrObject *descr;
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
descr = (PyGetSetDescrObject *)descr_new(&PyGetSetDescr_Type,
|
|
|
|
type, getset->name);
|
|
|
|
if (descr != NULL)
|
|
|
|
descr->d_getset = getset;
|
|
|
|
return (PyObject *)descr;
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyDescr_NewWrapper(PyTypeObject *type, struct wrapperbase *base, void *wrapped)
|
|
|
|
{
|
2010-05-09 12:52:27 -03: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 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2021-02-16 03:50:00 -04:00
|
|
|
int
|
|
|
|
PyDescr_IsData(PyObject *ob)
|
|
|
|
{
|
|
|
|
return Py_TYPE(ob)->tp_descr_set != NULL;
|
|
|
|
}
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2012-04-15 19:16:30 -03:00
|
|
|
/* --- mappingproxy: read-only proxy for mappings --- */
|
2001-08-02 01:15:00 -03: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 12:52:27 -03:00
|
|
|
PyObject_HEAD
|
2012-04-15 19:16:30 -03:00
|
|
|
PyObject *mapping;
|
|
|
|
} mappingproxyobject;
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2006-02-15 13:27:45 -04:00
|
|
|
static Py_ssize_t
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_len(PyObject *self)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2012-04-15 19:16:30 -03:00
|
|
|
return PyObject_Size(pp->mapping);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_getitem(PyObject *self, PyObject *key)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2012-04-15 19:16:30 -03:00
|
|
|
return PyObject_GetItem(pp->mapping, key);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2012-04-15 19:16:30 -03:00
|
|
|
static PyMappingMethods mappingproxy_as_mapping = {
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_len, /* mp_length */
|
|
|
|
mappingproxy_getitem, /* mp_subscript */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* mp_ass_subscript */
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
2020-03-07 15:03:09 -04:00
|
|
|
static PyObject *
|
|
|
|
mappingproxy_or(PyObject *left, PyObject *right)
|
|
|
|
{
|
|
|
|
if (PyObject_TypeCheck(left, &PyDictProxy_Type)) {
|
|
|
|
left = ((mappingproxyobject*)left)->mapping;
|
|
|
|
}
|
|
|
|
if (PyObject_TypeCheck(right, &PyDictProxy_Type)) {
|
|
|
|
right = ((mappingproxyobject*)right)->mapping;
|
|
|
|
}
|
|
|
|
return PyNumber_Or(left, right);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
mappingproxy_ior(PyObject *self, PyObject *Py_UNUSED(other))
|
|
|
|
{
|
|
|
|
return PyErr_Format(PyExc_TypeError,
|
|
|
|
"'|=' is not supported by %s; use '|' instead", Py_TYPE(self)->tp_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
static PyNumberMethods mappingproxy_as_number = {
|
|
|
|
.nb_or = mappingproxy_or,
|
|
|
|
.nb_inplace_or = mappingproxy_ior,
|
|
|
|
};
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static int
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_contains(PyObject *self, PyObject *key)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2012-04-15 19:16:30 -03:00
|
|
|
if (PyDict_CheckExact(pp->mapping))
|
|
|
|
return PyDict_Contains(pp->mapping, key);
|
|
|
|
else
|
|
|
|
return PySequence_Contains(pp->mapping, key);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2012-04-15 19:16:30 -03:00
|
|
|
static PySequenceMethods mappingproxy_as_sequence = {
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* sq_length */
|
|
|
|
0, /* sq_concat */
|
|
|
|
0, /* sq_repeat */
|
|
|
|
0, /* sq_item */
|
|
|
|
0, /* sq_slice */
|
|
|
|
0, /* sq_ass_item */
|
|
|
|
0, /* sq_ass_slice */
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_contains, /* sq_contains */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* sq_inplace_concat */
|
|
|
|
0, /* sq_inplace_repeat */
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_get(PyObject *self, PyObject *const *args, Py_ssize_t nargs)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2019-06-28 06:49:00 -03:00
|
|
|
/* newargs: mapping, key, default=None */
|
|
|
|
PyObject *newargs[3];
|
|
|
|
newargs[0] = pp->mapping;
|
|
|
|
newargs[2] = Py_None;
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2019-06-28 06:49:00 -03:00
|
|
|
if (!_PyArg_UnpackStack(args, nargs, "get", 1, 2,
|
|
|
|
&newargs[1], &newargs[2]))
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
2019-06-28 06:49:00 -03:00
|
|
|
}
|
2023-06-26 03:08:12 -03:00
|
|
|
return PyObject_VectorcallMethod(&_Py_ID(get), newargs,
|
|
|
|
3 | PY_VECTORCALL_ARGUMENTS_OFFSET,
|
|
|
|
NULL);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_keys(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2022-02-08 16:39:07 -04:00
|
|
|
return PyObject_CallMethodNoArgs(pp->mapping, &_Py_ID(keys));
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_values(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2022-02-08 16:39:07 -04:00
|
|
|
return PyObject_CallMethodNoArgs(pp->mapping, &_Py_ID(values));
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_items(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2022-02-08 16:39:07 -04:00
|
|
|
return PyObject_CallMethodNoArgs(pp->mapping, &_Py_ID(items));
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_copy(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2022-02-08 16:39:07 -04:00
|
|
|
return PyObject_CallMethodNoArgs(pp->mapping, &_Py_ID(copy));
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2020-05-08 02:25:50 -03:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_reversed(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2020-05-08 02:25:50 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2022-02-08 16:39:07 -04:00
|
|
|
return PyObject_CallMethodNoArgs(pp->mapping, &_Py_ID(__reversed__));
|
2020-05-08 02:25:50 -03:00
|
|
|
}
|
|
|
|
|
2012-04-15 19:16:30 -03:00
|
|
|
/* WARNING: mappingproxy methods must not give access
|
|
|
|
to the underlying mapping */
|
|
|
|
|
|
|
|
static PyMethodDef mappingproxy_methods[] = {
|
2022-05-03 16:42:14 -03:00
|
|
|
{"get", _PyCFunction_CAST(mappingproxy_get), METH_FASTCALL,
|
2010-05-09 12:52:27 -03:00
|
|
|
PyDoc_STR("D.get(k[,d]) -> D[k] if k in D, else d."
|
2012-04-15 19:16:30 -03:00
|
|
|
" d defaults to None.")},
|
2024-01-02 10:03:39 -04:00
|
|
|
{"keys", mappingproxy_keys, METH_NOARGS,
|
2022-01-19 17:20:43 -04:00
|
|
|
PyDoc_STR("D.keys() -> a set-like object providing a view on D's keys")},
|
2024-01-02 10:03:39 -04:00
|
|
|
{"values", mappingproxy_values, METH_NOARGS,
|
2022-01-19 17:20:43 -04:00
|
|
|
PyDoc_STR("D.values() -> an object providing a view on D's values")},
|
2024-01-02 10:03:39 -04:00
|
|
|
{"items", mappingproxy_items, METH_NOARGS,
|
2022-01-19 17:20:43 -04:00
|
|
|
PyDoc_STR("D.items() -> a set-like object providing a view on D's items")},
|
2024-01-02 10:03:39 -04:00
|
|
|
{"copy", mappingproxy_copy, METH_NOARGS,
|
2010-05-09 12:52:27 -03:00
|
|
|
PyDoc_STR("D.copy() -> a shallow copy of D")},
|
2021-09-19 12:05:30 -03:00
|
|
|
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS,
|
2020-04-07 13:50:06 -03:00
|
|
|
PyDoc_STR("See PEP 585")},
|
2024-01-02 10:03:39 -04:00
|
|
|
{"__reversed__", mappingproxy_reversed, METH_NOARGS,
|
2020-05-08 02:25:50 -03:00
|
|
|
PyDoc_STR("D.__reversed__() -> reverse iterator")},
|
2010-05-09 12:52:27 -03:00
|
|
|
{0}
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
static void
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_dealloc(PyObject *self)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2010-05-09 12:52:27 -03:00
|
|
|
_PyObject_GC_UNTRACK(pp);
|
2012-04-15 19:16:30 -03:00
|
|
|
Py_DECREF(pp->mapping);
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject_GC_Del(pp);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_getiter(PyObject *self)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2012-04-15 19:16:30 -03:00
|
|
|
return PyObject_GetIter(pp->mapping);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2022-06-28 06:54:58 -03:00
|
|
|
static Py_hash_t
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_hash(PyObject *self)
|
2022-06-28 06:54:58 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2022-06-28 06:54:58 -03:00
|
|
|
return PyObject_Hash(pp->mapping);
|
|
|
|
}
|
|
|
|
|
2001-10-21 19:26:43 -03:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_str(PyObject *self)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2012-04-15 19:16:30 -03:00
|
|
|
return PyObject_Str(pp->mapping);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2010-12-18 10:59:43 -04:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_repr(PyObject *self)
|
2010-12-18 10:59:43 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
2012-04-15 19:16:30 -03:00
|
|
|
return PyUnicode_FromFormat("mappingproxy(%R)", pp->mapping);
|
2010-12-18 10:59:43 -04:00
|
|
|
}
|
|
|
|
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
static int
|
2012-04-15 19:16:30 -03: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 18:24:57 -03:00
|
|
|
{
|
2012-04-15 19:16:30 -03:00
|
|
|
mappingproxyobject *pp = (mappingproxyobject *)self;
|
|
|
|
Py_VISIT(pp->mapping);
|
2010-05-09 12:52:27 -03: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 18:24:57 -03:00
|
|
|
}
|
|
|
|
|
2002-08-31 12:51:04 -03:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_richcompare(PyObject *self, PyObject *w, int op)
|
2012-04-15 19:16:30 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxyobject *v = (mappingproxyobject *)self;
|
2012-04-15 19:16:30 -03:00
|
|
|
return PyObject_RichCompare(v->mapping, w, op);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mappingproxy_check_mapping(PyObject *mapping)
|
2002-08-31 12:51:04 -03:00
|
|
|
{
|
2012-04-15 19:16:30 -03: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 03:51:07 -03: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 19:16:30 -03:00
|
|
|
{
|
|
|
|
mappingproxyobject *mappingproxy;
|
|
|
|
|
|
|
|
if (mappingproxy_check_mapping(mapping) == -1)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
mappingproxy = PyObject_GC_New(mappingproxyobject, &PyDictProxy_Type);
|
|
|
|
if (mappingproxy == NULL)
|
|
|
|
return NULL;
|
2022-11-10 11:27:32 -04:00
|
|
|
mappingproxy->mapping = Py_NewRef(mapping);
|
2012-04-15 19:16:30 -03:00
|
|
|
_PyObject_GC_TRACK(mappingproxy);
|
|
|
|
return (PyObject *)mappingproxy;
|
2002-08-31 12:51:04 -03:00
|
|
|
}
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
PyObject *
|
2012-04-15 19:16:30 -03:00
|
|
|
PyDictProxy_New(PyObject *mapping)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2012-04-15 19:16:30 -03:00
|
|
|
mappingproxyobject *pp;
|
|
|
|
|
|
|
|
if (mappingproxy_check_mapping(mapping) == -1)
|
|
|
|
return NULL;
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2012-04-15 19:16:30 -03:00
|
|
|
pp = PyObject_GC_New(mappingproxyobject, &PyDictProxy_Type);
|
2010-05-09 12:52:27 -03:00
|
|
|
if (pp != NULL) {
|
2022-11-10 11:27:32 -04:00
|
|
|
pp->mapping = Py_NewRef(mapping);
|
2010-05-09 12:52:27 -03:00
|
|
|
_PyObject_GC_TRACK(pp);
|
|
|
|
}
|
|
|
|
return (PyObject *)pp;
|
2001-08-02 01:15:00 -03: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 12:52:27 -03:00
|
|
|
PyObject_HEAD
|
|
|
|
PyWrapperDescrObject *descr;
|
|
|
|
PyObject *self;
|
2001-08-02 01:15:00 -03:00
|
|
|
} wrapperobject;
|
|
|
|
|
2020-03-04 09:15:20 -04:00
|
|
|
#define Wrapper_Check(v) Py_IS_TYPE(v, &_PyMethodWrapper_Type)
|
2009-02-01 06:28:51 -04:00
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static void
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_dealloc(PyObject *self)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperobject *wp = (wrapperobject *)self;
|
2010-05-09 12:52:27 -03:00
|
|
|
PyObject_GC_UnTrack(wp);
|
2019-05-10 14:21:11 -03:00
|
|
|
Py_TRASHCAN_BEGIN(wp, wrapper_dealloc)
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_XDECREF(wp->descr);
|
|
|
|
Py_XDECREF(wp->self);
|
|
|
|
PyObject_GC_Del(wp);
|
2019-05-10 14:21:11 -03:00
|
|
|
Py_TRASHCAN_END
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2009-02-01 06:28:51 -04:00
|
|
|
static PyObject *
|
|
|
|
wrapper_richcompare(PyObject *a, PyObject *b, int op)
|
2005-11-07 04:38:00 -04:00
|
|
|
{
|
2018-07-31 03:18:24 -03:00
|
|
|
wrapperobject *wa, *wb;
|
|
|
|
int eq;
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
assert(a != NULL && b != NULL);
|
|
|
|
|
|
|
|
/* both arguments should be wrapperobjects */
|
2018-07-31 03:18:24 -03:00
|
|
|
if ((op != Py_EQ && op != Py_NE)
|
|
|
|
|| !Wrapper_Check(a) || !Wrapper_Check(b))
|
|
|
|
{
|
2017-11-02 07:32:54 -03:00
|
|
|
Py_RETURN_NOTIMPLEMENTED;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
|
2018-07-31 03:18:24 -03:00
|
|
|
wa = (wrapperobject *)a;
|
|
|
|
wb = (wrapperobject *)b;
|
|
|
|
eq = (wa->descr == wb->descr && wa->self == wb->self);
|
|
|
|
if (eq == (op == Py_EQ)) {
|
|
|
|
Py_RETURN_TRUE;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Py_RETURN_FALSE;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
2005-11-07 04:38:00 -04:00
|
|
|
}
|
|
|
|
|
2010-10-17 17:54:53 -03:00
|
|
|
static Py_hash_t
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_hash(PyObject *self)
|
Merge the rest of the trunk.
Merged revisions 46490-46494,46496,46498,46500,46506,46521,46538,46558,46563-46567,46570-46571,46583,46593,46595-46598,46604,46606,46609-46753 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r46610 | martin.v.loewis | 2006-06-03 09:42:26 +0200 (Sat, 03 Jun 2006) | 2 lines
Updated version (win32-icons2.zip) from #1490384.
........
r46612 | andrew.kuchling | 2006-06-03 20:09:41 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1472084] Fix description of do_tag
........
r46614 | andrew.kuchling | 2006-06-03 20:33:35 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1475554] Strengthen text to say 'must' instead of 'should'
........
r46616 | andrew.kuchling | 2006-06-03 20:41:28 +0200 (Sat, 03 Jun 2006) | 1 line
[Bug #1441864] Clarify description of 'data' argument
........
r46617 | andrew.kuchling | 2006-06-03 20:43:24 +0200 (Sat, 03 Jun 2006) | 1 line
Minor rewording
........
r46619 | andrew.kuchling | 2006-06-03 21:02:35 +0200 (Sat, 03 Jun 2006) | 9 lines
[Bug #1497414] _self is a reserved word in the WATCOM 10.6 C compiler.
Fix by renaming the variable.
In a different module, Neal fixed it by renaming _self to self. There's
already a variable named 'self' here, so I used selfptr.
(I'm committing this on a Mac without Tk, but it's a simple search-and-replace.
<crosses fingers>, so I'll watch the buildbots and see what happens.)
........
r46621 | fredrik.lundh | 2006-06-03 23:56:05 +0200 (Sat, 03 Jun 2006) | 5 lines
"_self" is a said to be a reserved word in Watcom C 10.6. I'm
not sure that's really standard compliant behaviour, but I guess
we have to fix that anyway...
........
r46622 | andrew.kuchling | 2006-06-04 00:44:42 +0200 (Sun, 04 Jun 2006) | 1 line
Update readme
........
r46623 | andrew.kuchling | 2006-06-04 00:59:23 +0200 (Sun, 04 Jun 2006) | 1 line
Drop 0 parameter
........
r46624 | andrew.kuchling | 2006-06-04 00:59:59 +0200 (Sun, 04 Jun 2006) | 1 line
Some code tidying; use curses.wrapper
........
r46625 | andrew.kuchling | 2006-06-04 01:02:15 +0200 (Sun, 04 Jun 2006) | 1 line
Use True; value returned from main is unused
........
r46626 | andrew.kuchling | 2006-06-04 01:07:21 +0200 (Sun, 04 Jun 2006) | 1 line
Use true division, and the True value
........
r46627 | andrew.kuchling | 2006-06-04 01:09:58 +0200 (Sun, 04 Jun 2006) | 1 line
Docstring fix; use True
........
r46628 | andrew.kuchling | 2006-06-04 01:15:56 +0200 (Sun, 04 Jun 2006) | 1 line
Put code in a main() function; loosen up the spacing to match current code style
........
r46629 | andrew.kuchling | 2006-06-04 01:39:07 +0200 (Sun, 04 Jun 2006) | 1 line
Use functions; modernize code
........
r46630 | andrew.kuchling | 2006-06-04 01:43:22 +0200 (Sun, 04 Jun 2006) | 1 line
This demo requires Medusa (not just asyncore); remove it
........
r46631 | andrew.kuchling | 2006-06-04 01:46:36 +0200 (Sun, 04 Jun 2006) | 2 lines
Remove xmlrpc demo -- it duplicates the SimpleXMLRPCServer module.
........
r46632 | andrew.kuchling | 2006-06-04 01:47:22 +0200 (Sun, 04 Jun 2006) | 1 line
Remove xmlrpc/ directory
........
r46633 | andrew.kuchling | 2006-06-04 01:51:21 +0200 (Sun, 04 Jun 2006) | 1 line
Remove dangling reference
........
r46634 | andrew.kuchling | 2006-06-04 01:59:36 +0200 (Sun, 04 Jun 2006) | 1 line
Add more whitespace; use a better socket name
........
r46635 | tim.peters | 2006-06-04 03:22:53 +0200 (Sun, 04 Jun 2006) | 2 lines
Whitespace normalization.
........
r46637 | tim.peters | 2006-06-04 05:26:02 +0200 (Sun, 04 Jun 2006) | 16 lines
In a PYMALLOC_DEBUG build obmalloc adds extra debugging info
to each allocated block. This was using 4 bytes for each such
piece of info regardless of platform. This didn't really matter
before (proof: no bug reports, and the debug-build obmalloc would
have assert-failed if it was ever asked for a chunk of memory
>= 2**32 bytes), since container indices were plain ints. But after
the Py_ssize_t changes, it's at least theoretically possible to
allocate a list or string whose guts exceed 2**32 bytes, and the
PYMALLOC_DEBUG routines would fail then (having only 4 bytes
to record the originally requested size).
Now we use sizeof(size_t) bytes for each of a PYMALLOC_DEBUG
build's extra debugging fields. This won't make any difference
on 32-bit boxes, but will add 16 bytes to each allocation in
a debug build on a 64-bit box.
........
r46638 | tim.peters | 2006-06-04 05:38:04 +0200 (Sun, 04 Jun 2006) | 4 lines
_PyObject_DebugMalloc(): The return value should add
2*sizeof(size_t) now, not 8. This probably accounts for
current disasters on the 64-bit buildbot slaves.
........
r46639 | neal.norwitz | 2006-06-04 08:19:31 +0200 (Sun, 04 Jun 2006) | 1 line
SF #1499797, Fix for memory leak in WindowsError_str
........
r46640 | andrew.macintyre | 2006-06-04 14:31:09 +0200 (Sun, 04 Jun 2006) | 2 lines
Patch #1454481: Make thread stack size runtime tunable.
........
r46641 | andrew.macintyre | 2006-06-04 14:59:59 +0200 (Sun, 04 Jun 2006) | 2 lines
clean up function declarations to conform to PEP-7 style.
........
r46642 | martin.blais | 2006-06-04 15:49:49 +0200 (Sun, 04 Jun 2006) | 15 lines
Fixes in struct and socket from merge reviews.
- Following Guido's comments, renamed
* pack_to -> pack_into
* recv_buf -> recv_into
* recvfrom_buf -> recvfrom_into
- Made fixes to _struct.c according to Neal Norwitz comments on the checkins
list.
- Converted some ints into the appropriate -- I hope -- ssize_t and size_t.
........
r46643 | ronald.oussoren | 2006-06-04 16:05:28 +0200 (Sun, 04 Jun 2006) | 3 lines
"Import" LDFLAGS in Mac/OSX/Makefile.in to ensure pythonw gets build with
the right compiler flags.
........
r46644 | ronald.oussoren | 2006-06-04 16:24:59 +0200 (Sun, 04 Jun 2006) | 2 lines
Drop Mac wrappers for the WASTE library.
........
r46645 | tim.peters | 2006-06-04 17:49:07 +0200 (Sun, 04 Jun 2006) | 3 lines
s_methods[]: Stop compiler warnings by casting
s_unpack_from to PyCFunction.
........
r46646 | george.yoshida | 2006-06-04 19:04:12 +0200 (Sun, 04 Jun 2006) | 2 lines
Remove a redundant word
........
r46647 | george.yoshida | 2006-06-04 19:17:25 +0200 (Sun, 04 Jun 2006) | 2 lines
Markup fix
........
r46648 | martin.v.loewis | 2006-06-04 21:36:28 +0200 (Sun, 04 Jun 2006) | 2 lines
Patch #1359618: Speed-up charmap encoder.
........
r46649 | georg.brandl | 2006-06-04 23:46:16 +0200 (Sun, 04 Jun 2006) | 3 lines
Repair refleaks in unicodeobject.
........
r46650 | georg.brandl | 2006-06-04 23:56:52 +0200 (Sun, 04 Jun 2006) | 4 lines
Patch #1346214: correctly optimize away "if 0"-style stmts
(thanks to Neal for review)
........
r46651 | georg.brandl | 2006-06-05 00:15:37 +0200 (Mon, 05 Jun 2006) | 2 lines
Bug #1500293: fix memory leaks in _subprocess module.
........
r46654 | tim.peters | 2006-06-05 01:43:53 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46655 | tim.peters | 2006-06-05 01:52:47 +0200 (Mon, 05 Jun 2006) | 16 lines
Revert revisions:
46640 Patch #1454481: Make thread stack size runtime tunable.
46647 Markup fix
The first is causing many buildbots to fail test runs, and there
are multiple causes with seemingly no immediate prospects for
repairing them. See python-dev discussion.
Note that a branch can (and should) be created for resolving these
problems, like
svn copy svn+ssh://svn.python.org/python/trunk -r46640 svn+ssh://svn.python.org/python/branches/NEW_BRANCH
followed by merging rev 46647 to the new branch.
........
r46656 | andrew.kuchling | 2006-06-05 02:08:09 +0200 (Mon, 05 Jun 2006) | 1 line
Mention second encoding speedup
........
r46657 | gregory.p.smith | 2006-06-05 02:31:01 +0200 (Mon, 05 Jun 2006) | 7 lines
bugfix: when log_archive was called with the DB_ARCH_REMOVE flag present
in BerkeleyDB >= 4.2 it tried to construct a list out of an uninitialized
char **log_list.
feature: export the DB_ARCH_REMOVE flag by name in the module on BerkeleyDB >= 4.2.
........
r46658 | gregory.p.smith | 2006-06-05 02:33:35 +0200 (Mon, 05 Jun 2006) | 5 lines
fix a bug in the previous commit. don't leak empty list on error return and
fix the additional rare (out of memory only) bug that it was supposed to fix
of not freeing log_list when the python allocator failed.
........
r46660 | tim.peters | 2006-06-05 02:55:26 +0200 (Mon, 05 Jun 2006) | 9 lines
"Flat is better than nested."
Move the long-winded, multiply-nested -R support out
of runtest() and into some module-level helper functions.
This makes runtest() and the -R code easier to follow.
That in turn allowed seeing some opportunities for code
simplification, and made it obvious that reglog.txt
never got closed.
........
r46661 | hyeshik.chang | 2006-06-05 02:59:54 +0200 (Mon, 05 Jun 2006) | 3 lines
Fix a potentially invalid memory access of CJKCodecs' shift-jis
decoder. (found by Neal Norwitz)
........
r46663 | gregory.p.smith | 2006-06-05 03:39:52 +0200 (Mon, 05 Jun 2006) | 3 lines
* support DBEnv.log_stat() method on BerkeleyDB >= 4.0 [patch #1494885]
........
r46664 | tim.peters | 2006-06-05 03:43:03 +0200 (Mon, 05 Jun 2006) | 3 lines
Remove doctest.testmod's deprecated (in 2.4) `isprivate`
argument. A lot of hair went into supporting that!
........
r46665 | tim.peters | 2006-06-05 03:47:24 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46666 | tim.peters | 2006-06-05 03:48:21 +0200 (Mon, 05 Jun 2006) | 2 lines
Make doctest news more accurate.
........
r46667 | gregory.p.smith | 2006-06-05 03:56:15 +0200 (Mon, 05 Jun 2006) | 3 lines
* support DBEnv.lsn_reset() method on BerkeleyDB >= 4.4 [patch #1494902]
........
r46668 | gregory.p.smith | 2006-06-05 04:02:25 +0200 (Mon, 05 Jun 2006) | 3 lines
mention the just committed bsddb changes
........
r46671 | gregory.p.smith | 2006-06-05 19:38:04 +0200 (Mon, 05 Jun 2006) | 3 lines
* add support for DBSequence objects [patch #1466734]
........
r46672 | gregory.p.smith | 2006-06-05 20:20:07 +0200 (Mon, 05 Jun 2006) | 3 lines
forgot to add this file in previous commit
........
r46673 | tim.peters | 2006-06-05 20:36:12 +0200 (Mon, 05 Jun 2006) | 2 lines
Whitespace normalization.
........
r46674 | tim.peters | 2006-06-05 20:36:54 +0200 (Mon, 05 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46675 | gregory.p.smith | 2006-06-05 20:48:21 +0200 (Mon, 05 Jun 2006) | 4 lines
* fix DBCursor.pget() bug with keyword argument names when no data= is
supplied [SF pybsddb bug #1477863]
........
r46676 | andrew.kuchling | 2006-06-05 21:05:32 +0200 (Mon, 05 Jun 2006) | 1 line
Remove use of Trove name, which isn't very helpful to users
........
r46677 | andrew.kuchling | 2006-06-05 21:08:25 +0200 (Mon, 05 Jun 2006) | 1 line
[Bug #1470026] Include link to list of classifiers
........
r46679 | tim.peters | 2006-06-05 22:48:49 +0200 (Mon, 05 Jun 2006) | 10 lines
Access _struct attributes directly instead of mucking with getattr.
string_reverse(): Simplify.
assertRaises(): Raise TestFailed on failure.
test_unpack_from(), test_pack_into(), test_pack_into_fn(): never
use `assert` to test for an expected result (it doesn't test anything
when Python is run with -O).
........
r46680 | tim.peters | 2006-06-05 22:49:27 +0200 (Mon, 05 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46681 | gregory.p.smith | 2006-06-06 01:38:06 +0200 (Tue, 06 Jun 2006) | 3 lines
add depends = ['md5.h'] to the _md5 module extension for correctness sake.
........
r46682 | brett.cannon | 2006-06-06 01:51:55 +0200 (Tue, 06 Jun 2006) | 4 lines
Add 3 more bytes to a buffer to cover constants in string and null byte on top of 10 possible digits for an int.
Closes bug #1501223.
........
r46684 | gregory.p.smith | 2006-06-06 01:59:37 +0200 (Tue, 06 Jun 2006) | 5 lines
- bsddb: the __len__ method of a DB object has been fixed to return correct
results. It could previously incorrectly return 0 in some cases.
Fixes SF bug 1493322 (pybsddb bug 1184012).
........
r46686 | tim.peters | 2006-06-06 02:25:07 +0200 (Tue, 06 Jun 2006) | 7 lines
_PySys_Init(): It's rarely a good idea to size a buffer to the
exact maximum size someone guesses is needed. In this case, if
we're really worried about extreme integers, then "cp%d" can
actually need 14 bytes (2 for "cp" + 1 for \0 at the end +
11 for -(2**31-1)). So reserve 128 bytes instead -- nothing is
actually saved by making a stack-local buffer tiny.
........
r46687 | neal.norwitz | 2006-06-06 09:22:08 +0200 (Tue, 06 Jun 2006) | 1 line
Remove unused variable (and stop compiler warning)
........
r46688 | neal.norwitz | 2006-06-06 09:23:01 +0200 (Tue, 06 Jun 2006) | 1 line
Fix a bunch of parameter strings
........
r46689 | thomas.heller | 2006-06-06 13:34:33 +0200 (Tue, 06 Jun 2006) | 6 lines
Convert CFieldObject tp_members to tp_getset, since there is no
structmember typecode for Py_ssize_t fields. This should fix some of
the errors on the PPC64 debian machine (64-bit, big endian).
Assigning to readonly fields now raises AttributeError instead of
TypeError, so the testcase has to be changed as well.
........
r46690 | thomas.heller | 2006-06-06 13:54:32 +0200 (Tue, 06 Jun 2006) | 1 line
Damn - the sentinel was missing. And fix another silly mistake.
........
r46691 | martin.blais | 2006-06-06 14:46:55 +0200 (Tue, 06 Jun 2006) | 13 lines
Normalized a few cases of whitespace in function declarations.
Found them using::
find . -name '*.py' | while read i ; do grep 'def[^(]*( ' $i /dev/null ; done
find . -name '*.py' | while read i ; do grep ' ):' $i /dev/null ; done
(I was doing this all over my own code anyway, because I'd been using spaces in
all defs, so I thought I'd make a run on the Python code as well. If you need
to do such fixes in your own code, you can use xx-rename or parenregu.el within
emacs.)
........
r46693 | thomas.heller | 2006-06-06 17:34:18 +0200 (Tue, 06 Jun 2006) | 1 line
Specify argtypes for all test functions. Maybe that helps on strange ;-) architectures
........
r46694 | tim.peters | 2006-06-06 17:50:17 +0200 (Tue, 06 Jun 2006) | 5 lines
BSequence_set_range(): Rev 46688 ("Fix a bunch of
parameter strings") changed this function's signature
seemingly by mistake, which is causing buildbots to fail
test_bsddb3. Restored the pre-46688 signature.
........
r46695 | tim.peters | 2006-06-06 17:52:35 +0200 (Tue, 06 Jun 2006) | 4 lines
On python-dev Thomas Heller said these were committed
by mistake in rev 46693, so reverting this part of
rev 46693.
........
r46696 | andrew.kuchling | 2006-06-06 19:10:41 +0200 (Tue, 06 Jun 2006) | 1 line
Fix comment typo
........
r46697 | brett.cannon | 2006-06-06 20:08:16 +0200 (Tue, 06 Jun 2006) | 2 lines
Fix coding style guide bug.
........
r46698 | thomas.heller | 2006-06-06 20:50:46 +0200 (Tue, 06 Jun 2006) | 2 lines
Add a hack so that foreign functions returning float now do work on 64-bit
big endian platforms.
........
r46699 | thomas.heller | 2006-06-06 21:25:13 +0200 (Tue, 06 Jun 2006) | 3 lines
Use the same big-endian hack as in _ctypes/callproc.c for callback functions.
This fixes the callback function tests that return float.
........
r46700 | ronald.oussoren | 2006-06-06 21:50:24 +0200 (Tue, 06 Jun 2006) | 5 lines
* Ensure that "make altinstall" works when the tree was configured
with --enable-framework
* Also for --enable-framework: allow users to use --prefix to specify
the location of the compatibility symlinks (such as /usr/local/bin/python)
........
r46701 | ronald.oussoren | 2006-06-06 21:56:00 +0200 (Tue, 06 Jun 2006) | 3 lines
A quick hack to ensure the right key-bindings for IDLE on osx: install patched
configuration files during a framework install.
........
r46702 | tim.peters | 2006-06-07 03:04:59 +0200 (Wed, 07 Jun 2006) | 4 lines
dash_R_cleanup(): Clear filecmp._cache. This accounts for
different results across -R runs (at least on Windows) of
test_filecmp.
........
r46705 | tim.peters | 2006-06-07 08:57:51 +0200 (Wed, 07 Jun 2006) | 17 lines
SF patch 1501987: Remove randomness from test_exceptions,
from ?iga Seilnacht (sorry about the name, but Firefox
on my box can't display the first character of the name --
the SF "Unix name" is zseil).
This appears to cure the oddball intermittent leaks across
runs when running test_exceptions under -R. I'm not sure
why, but I'm too sleepy to care ;-)
The thrust of the SF patch was to remove randomness in the
pickle protocol used. I changed the patch to use
range(pickle.HIGHEST_PROTOCOL + 1), to try both pickle and
cPickle, and randomly mucked with other test lines to put
statements on their own lines.
Not a bugfix candidate (this is fiddling new-in-2.5 code).
........
r46706 | andrew.kuchling | 2006-06-07 15:55:33 +0200 (Wed, 07 Jun 2006) | 1 line
Add an SQLite introduction, taken from the 'What's New' text
........
r46708 | andrew.kuchling | 2006-06-07 19:02:52 +0200 (Wed, 07 Jun 2006) | 1 line
Mention other placeholders
........
r46709 | andrew.kuchling | 2006-06-07 19:03:46 +0200 (Wed, 07 Jun 2006) | 1 line
Add an item; also, escape %
........
r46710 | andrew.kuchling | 2006-06-07 19:04:01 +0200 (Wed, 07 Jun 2006) | 1 line
Mention other placeholders
........
r46716 | ronald.oussoren | 2006-06-07 20:57:44 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/Tools one level up
........
r46717 | ronald.oussoren | 2006-06-07 20:58:01 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/PythonLauncher one level up
........
r46718 | ronald.oussoren | 2006-06-07 20:58:42 +0200 (Wed, 07 Jun 2006) | 2 lines
mv Mac/OSX/BuildScript one level up
........
r46719 | ronald.oussoren | 2006-06-07 21:02:03 +0200 (Wed, 07 Jun 2006) | 2 lines
Move Mac/OSX/* one level up
........
r46720 | ronald.oussoren | 2006-06-07 21:06:01 +0200 (Wed, 07 Jun 2006) | 2 lines
And the last bit: move IDLE one level up and adjust makefiles
........
r46723 | ronald.oussoren | 2006-06-07 21:38:53 +0200 (Wed, 07 Jun 2006) | 4 lines
- Patch the correct version of python in the Info.plists at build time, instead
of relying on a maintainer to update them before releases.
- Remove the now empty Mac/OSX directory
........
r46727 | ronald.oussoren | 2006-06-07 22:18:44 +0200 (Wed, 07 Jun 2006) | 7 lines
* If BuildApplet.py is used as an applet it starts with a version of
sys.exutable that isn't usuable on an #!-line. That results in generated
applets that don't actually work. Work around this problem by resetting
sys.executable.
* argvemulator.py didn't work on intel macs. This patch fixes this
(bug #1491468)
........
r46728 | tim.peters | 2006-06-07 22:40:06 +0200 (Wed, 07 Jun 2006) | 2 lines
Whitespace normalization.
........
r46729 | tim.peters | 2006-06-07 22:40:54 +0200 (Wed, 07 Jun 2006) | 2 lines
Add missing svn:eol-style property to text files.
........
r46730 | thomas.heller | 2006-06-07 22:43:06 +0200 (Wed, 07 Jun 2006) | 7 lines
Fix for foreign functions returning small structures on 64-bit big
endian machines. Should fix the remaininf failure in the PPC64
Debian buildbot.
Thanks to Matthias Klose for providing access to a machine to debug
and test this.
........
r46731 | brett.cannon | 2006-06-07 23:48:17 +0200 (Wed, 07 Jun 2006) | 2 lines
Clarify documentation for bf_getcharbuffer.
........
r46735 | neal.norwitz | 2006-06-08 07:12:45 +0200 (Thu, 08 Jun 2006) | 1 line
Fix a refleak in recvfrom_into
........
r46736 | gregory.p.smith | 2006-06-08 07:17:08 +0200 (Thu, 08 Jun 2006) | 9 lines
- bsddb: the bsddb.dbtables Modify method now raises the proper error and
aborts the db transaction safely when a modifier callback fails.
Fixes SF python patch/bug #1408584.
Also cleans up the bsddb.dbtables docstrings since thats the only
documentation that exists for that unadvertised module. (people
really should really just use sqlite3)
........
r46737 | gregory.p.smith | 2006-06-08 07:38:11 +0200 (Thu, 08 Jun 2006) | 4 lines
* Turn the deadlock situation described in SF bug #775414 into a
DBDeadLockError exception.
* add the test case for my previous dbtables commit.
........
r46738 | gregory.p.smith | 2006-06-08 07:39:54 +0200 (Thu, 08 Jun 2006) | 2 lines
pasted set_lk_detect line in wrong spot in previous commit. fixed. passes tests this time.
........
r46739 | armin.rigo | 2006-06-08 12:56:24 +0200 (Thu, 08 Jun 2006) | 6 lines
(arre, arigo) SF bug #1350060
Give a consistent behavior for comparison and hashing of method objects
(both user- and built-in methods). Now compares the 'self' recursively.
The hash was already asking for the hash of 'self'.
........
r46740 | andrew.kuchling | 2006-06-08 13:56:44 +0200 (Thu, 08 Jun 2006) | 1 line
Typo fix
........
r46741 | georg.brandl | 2006-06-08 14:45:01 +0200 (Thu, 08 Jun 2006) | 2 lines
Bug #1502750: Fix getargs "i" format to use LONG_MIN and LONG_MAX for bounds checking.
........
r46743 | georg.brandl | 2006-06-08 14:54:13 +0200 (Thu, 08 Jun 2006) | 2 lines
Bug #1502728: Correctly link against librt library on HP-UX.
........
r46745 | georg.brandl | 2006-06-08 14:55:47 +0200 (Thu, 08 Jun 2006) | 3 lines
Add news for recent bugfix.
........
r46746 | georg.brandl | 2006-06-08 15:31:07 +0200 (Thu, 08 Jun 2006) | 4 lines
Argh. "integer" is a very confusing word ;)
Actually, checking for INT_MAX and INT_MIN is correct since
the format code explicitly handles a C "int".
........
r46748 | nick.coghlan | 2006-06-08 15:54:49 +0200 (Thu, 08 Jun 2006) | 1 line
Add functools.update_wrapper() and functools.wraps() as described in PEP 356
........
r46751 | georg.brandl | 2006-06-08 16:50:21 +0200 (Thu, 08 Jun 2006) | 4 lines
Bug #1502805: don't alias file.__exit__ to file.close since the
latter can return something that's true.
........
r46752 | georg.brandl | 2006-06-08 16:50:53 +0200 (Thu, 08 Jun 2006) | 3 lines
Convert test_file to unittest.
........
2006-06-08 12:35:45 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperobject *wp = (wrapperobject *)self;
|
2010-10-17 17:54:53 -03:00
|
|
|
Py_hash_t x, y;
|
2018-07-31 03:18:24 -03:00
|
|
|
x = _Py_HashPointer(wp->self);
|
|
|
|
y = _Py_HashPointer(wp->descr);
|
2010-05-09 12:52:27 -03:00
|
|
|
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 12:35:45 -03:00
|
|
|
}
|
|
|
|
|
2005-11-07 04:38:00 -04:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_repr(PyObject *self)
|
2005-11-07 04:38:00 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperobject *wp = (wrapperobject *)self;
|
2010-05-09 12:52:27 -03:00
|
|
|
return PyUnicode_FromFormat("<method-wrapper '%s' of %s object at %p>",
|
|
|
|
wp->descr->d_base->name,
|
2020-02-06 22:04:21 -04:00
|
|
|
Py_TYPE(wp->self)->tp_name,
|
2010-05-09 12:52:27 -03:00
|
|
|
wp->self);
|
2005-11-07 04:38:00 -04:00
|
|
|
}
|
|
|
|
|
2013-11-23 13:59:12 -04:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
|
2013-11-23 13:59:12 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperobject *wp = (wrapperobject *)self;
|
2022-02-08 16:39:07 -04:00
|
|
|
return Py_BuildValue("N(OO)", _PyEval_GetBuiltin(&_Py_ID(getattr)),
|
2018-12-11 02:28:18 -04:00
|
|
|
wp->self, PyDescr_NAME(wp->descr));
|
2013-11-23 13:59:12 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyMethodDef wrapper_methods[] = {
|
2024-01-02 10:03:39 -04:00
|
|
|
{"__reduce__", wrapper_reduce, METH_NOARGS, NULL},
|
2013-11-23 13:59:12 -04:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2005-11-07 04:38:00 -04:00
|
|
|
static PyMemberDef wrapper_members[] = {
|
2023-07-25 10:28:30 -03:00
|
|
|
{"__self__", _Py_T_OBJECT, offsetof(wrapperobject, self), Py_READONLY},
|
2010-05-09 12:52:27 -03:00
|
|
|
{0}
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
2005-11-07 04:38:00 -04:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_objclass(PyObject *wp, void *Py_UNUSED(ignored))
|
2005-11-07 04:38:00 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
PyObject *c = (PyObject *)PyDescr_TYPE(((wrapperobject *)wp)->descr);
|
2005-11-07 04:38:00 -04:00
|
|
|
|
2022-11-10 11:27:32 -04:00
|
|
|
return Py_NewRef(c);
|
2005-11-07 04:38:00 -04:00
|
|
|
}
|
|
|
|
|
2001-08-02 01:15:00 -03:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_name(PyObject *wp, void *Py_UNUSED(ignored))
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
const char *s = ((wrapperobject *)wp)->descr->d_base->name;
|
2001-08-02 01:15:00 -03:00
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
return PyUnicode_FromString(s);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_doc(PyObject *self, void *Py_UNUSED(ignored))
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperobject *wp = (wrapperobject *)self;
|
2014-02-09 02:15:29 -04:00
|
|
|
return _PyType_GetDocFromInternalDoc(wp->descr->d_base->name, wp->descr->d_base->doc);
|
2014-01-24 10:17:25 -04:00
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2014-01-24 10:17:25 -04:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_text_signature(PyObject *self, void *Py_UNUSED(ignored))
|
2014-01-24 10:17:25 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperobject *wp = (wrapperobject *)self;
|
2023-08-11 12:08:38 -03:00
|
|
|
return _PyType_GetTextSignatureFromInternalDoc(wp->descr->d_base->name,
|
|
|
|
wp->descr->d_base->doc, 0);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
2011-12-12 08:47:25 -04:00
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_qualname(PyObject *self, void *Py_UNUSED(ignored))
|
2011-12-12 08:47:25 -04:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperobject *wp = (wrapperobject *)self;
|
|
|
|
return descr_get_qualname((PyObject *)wp->descr, NULL);
|
2011-12-12 08:47:25 -04:00
|
|
|
}
|
|
|
|
|
2001-09-20 18:45:26 -03:00
|
|
|
static PyGetSetDef wrapper_getsets[] = {
|
2024-01-02 10:03:39 -04:00
|
|
|
{"__objclass__", wrapper_objclass},
|
|
|
|
{"__name__", wrapper_name},
|
|
|
|
{"__qualname__", wrapper_qualname},
|
|
|
|
{"__doc__", wrapper_doc},
|
|
|
|
{"__text_signature__", wrapper_text_signature},
|
2010-05-09 12:52:27 -03:00
|
|
|
{0}
|
2001-08-02 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
static PyObject *
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_call(PyObject *self, PyObject *args, PyObject *kwds)
|
2001-08-02 01:15:00 -03:00
|
|
|
{
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapperobject *wp = (wrapperobject *)self;
|
2017-09-21 08:25:36 -03:00
|
|
|
return wrapperdescr_raw_call(wp->descr, wp->self, args, kwds);
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
|
|
|
|
Add Garbage Collection support to new-style classes (not yet to their
instances).
Also added GC support to various auxiliary types: super, property,
descriptors, wrappers, dictproxy. (Only type objects have a tp_clear
field; the other types are.)
One change was necessary to the GC infrastructure. We have statically
allocated type objects that don't have a GC header (and can't easily
be given one) and heap-allocated type objects that do have a GC
header. Giving these different metatypes would be really ugly: I
tried, and I had to modify pickle.py, cPickle.c, copy.py, add a new
invent a new name for the new metatype and make it a built-in, change
affected tests... In short, a mess. So instead, we add a new type
slot tp_is_gc, which is a simple Boolean function that determines
whether a particular instance has GC headers or not. This slot is
only relevant for types that have the (new) GC flag bit set. If the
tp_is_gc slot is NULL (by far the most common case), all instances of
the type are deemed to have GC headers. This slot is called by the
PyObject_IS_GC() macro (which is only used twice, both times in
gcmodule.c).
I also changed the extern declarations for a bunch of GC-related
functions (_PyObject_GC_Del etc.): these always exist but objimpl.h
only declared them when WITH_CYCLE_GC was defined, but I needed to be
able to reference them without #ifdefs. (When WITH_CYCLE_GC is not
defined, they do the same as their non-GC counterparts anyway.)
2001-10-02 18:24:57 -03:00
|
|
|
static int
|
|
|
|
wrapper_traverse(PyObject *self, visitproc visit, void *arg)
|
|
|
|
{
|
2010-05-09 12:52:27 -03: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 18:24:57 -03:00
|
|
|
}
|
|
|
|
|
2011-09-01 17:32:31 -03:00
|
|
|
PyTypeObject _PyMethodWrapper_Type = {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"method-wrapper", /* tp_name */
|
|
|
|
sizeof(wrapperobject), /* tp_basicsize */
|
|
|
|
0, /* tp_itemsize */
|
|
|
|
/* methods */
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_dealloc, /* tp_dealloc */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_vectorcall_offset */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_as_async */
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_repr, /* tp_repr */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_as_number */
|
|
|
|
0, /* tp_as_sequence */
|
|
|
|
0, /* tp_as_mapping */
|
2024-01-02 10:03:39 -04:00
|
|
|
wrapper_hash, /* tp_hash */
|
|
|
|
wrapper_call, /* tp_call */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_str */
|
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */
|
|
|
|
0, /* tp_doc */
|
|
|
|
wrapper_traverse, /* tp_traverse */
|
|
|
|
0, /* tp_clear */
|
|
|
|
wrapper_richcompare, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
2013-11-23 13:59:12 -04:00
|
|
|
wrapper_methods, /* tp_methods */
|
2010-05-09 12:52:27 -03: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 01:15:00 -03:00
|
|
|
};
|
|
|
|
|
|
|
|
PyObject *
|
|
|
|
PyWrapper_New(PyObject *d, PyObject *self)
|
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
wrapperobject *wp;
|
|
|
|
PyWrapperDescrObject *descr;
|
|
|
|
|
|
|
|
assert(PyObject_TypeCheck(d, &PyWrapperDescr_Type));
|
|
|
|
descr = (PyWrapperDescrObject *)d;
|
2011-05-01 18:19:15 -03:00
|
|
|
assert(_PyObject_RealIsSubclass((PyObject *)Py_TYPE(self),
|
2011-05-01 18:31:36 -03:00
|
|
|
(PyObject *)PyDescr_TYPE(descr)));
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2011-09-01 17:32:31 -03:00
|
|
|
wp = PyObject_GC_New(wrapperobject, &_PyMethodWrapper_Type);
|
2010-05-09 12:52:27 -03:00
|
|
|
if (wp != NULL) {
|
2022-11-10 11:27:32 -04:00
|
|
|
wp->descr = (PyWrapperDescrObject*)Py_NewRef(descr);
|
|
|
|
wp->self = Py_NewRef(self);
|
2010-05-09 12:52:27 -03:00
|
|
|
_PyObject_GC_TRACK(wp);
|
|
|
|
}
|
|
|
|
return (PyObject *)wp;
|
2001-08-02 01:15:00 -03:00
|
|
|
}
|
2001-08-23 18:40:38 -03:00
|
|
|
|
|
|
|
|
2001-09-06 18:56:42 -03:00
|
|
|
/* A built-in 'property' type */
|
2001-08-23 18:40:38 -03:00
|
|
|
|
|
|
|
/*
|
2015-06-10 18:06:39 -03:00
|
|
|
class property(object):
|
2001-08-23 18:40:38 -03:00
|
|
|
|
2010-05-09 12:52:27 -03: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 18:06:39 -03:00
|
|
|
doc = fget.__doc__
|
2010-05-09 12:52:27 -03:00
|
|
|
self.__get = fget
|
|
|
|
self.__set = fset
|
|
|
|
self.__del = fdel
|
2023-06-05 00:18:15 -03:00
|
|
|
try:
|
|
|
|
self.__doc__ = doc
|
|
|
|
except AttributeError: # read-only or dict-less class
|
|
|
|
pass
|
2010-05-09 12:52:27 -03:00
|
|
|
|
|
|
|
def __get__(self, inst, type=None):
|
|
|
|
if inst is None:
|
2015-06-10 18:06:39 -03:00
|
|
|
return self
|
2010-05-09 12:52:27 -03:00
|
|
|
if self.__get is None:
|
2022-02-16 03:07:34 -04:00
|
|
|
raise AttributeError, "property has no getter"
|
2010-05-09 12:52:27 -03:00
|
|
|
return self.__get(inst)
|
|
|
|
|
|
|
|
def __set__(self, inst, value):
|
|
|
|
if self.__set is None:
|
2022-02-16 03:07:34 -04:00
|
|
|
raise AttributeError, "property has no setter"
|
2010-05-09 12:52:27 -03:00
|
|
|
return self.__set(inst, value)
|
|
|
|
|
|
|
|
def __delete__(self, inst):
|
|
|
|
if self.__del is None:
|
2022-02-16 03:07:34 -04:00
|
|
|
raise AttributeError, "property has no deleter"
|
2010-05-09 12:52:27 -03:00
|
|
|
return self.__del(inst)
|
2001-12-10 14:03:34 -04:00
|
|
|
|
2001-08-23 18:40:38 -03: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-14 21:27:15 -04:00
|
|
|
static PyObject * property_copy(PyObject *, PyObject *, PyObject *,
|
2010-06-28 00:07:10 -03: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-14 21:27:15 -04:00
|
|
|
|
2001-09-24 18:17:50 -03:00
|
|
|
static PyMemberDef property_members[] = {
|
2023-07-25 10:28:30 -03:00
|
|
|
{"fget", _Py_T_OBJECT, offsetof(propertyobject, prop_get), Py_READONLY},
|
|
|
|
{"fset", _Py_T_OBJECT, offsetof(propertyobject, prop_set), Py_READONLY},
|
|
|
|
{"fdel", _Py_T_OBJECT, offsetof(propertyobject, prop_del), Py_READONLY},
|
|
|
|
{"__doc__", _Py_T_OBJECT, offsetof(propertyobject, prop_doc), 0},
|
2010-05-09 12:52:27 -03:00
|
|
|
{0}
|
2001-09-24 18:17:50 -03: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-14 21:27:15 -04: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 19:39:45 -04:00
|
|
|
PyDoc_STRVAR(getter_doc,
|
2022-03-14 20:28:54 -03:00
|
|
|
"Descriptor to obtain a copy of the property with a different getter.");
|
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 19:39:45 -04: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 03:43:13 -03: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 19:39:45 -04:00
|
|
|
property_getter(PyObject *self, PyObject *getter)
|
|
|
|
{
|
2010-06-28 00:07:10 -03: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 19:39:45 -04: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-14 21:27:15 -04: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 19:39:45 -04:00
|
|
|
PyDoc_STRVAR(setter_doc,
|
2022-03-14 20:28:54 -03:00
|
|
|
"Descriptor to obtain a copy of the property with a different setter.");
|
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 19:39:45 -04: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 03:43:13 -03: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 19:39:45 -04:00
|
|
|
property_setter(PyObject *self, PyObject *setter)
|
|
|
|
{
|
2010-06-28 00:07:10 -03: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 19:39:45 -04: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-14 21:27:15 -04: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 19:39:45 -04:00
|
|
|
PyDoc_STRVAR(deleter_doc,
|
2022-03-14 20:28:54 -03:00
|
|
|
"Descriptor to obtain a copy of the property with a different 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 19:39:45 -04: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 03:43:13 -03: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 19:39:45 -04:00
|
|
|
property_deleter(PyObject *self, PyObject *deleter)
|
|
|
|
{
|
2010-06-28 00:07:10 -03: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 19:39:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2020-12-30 05:51:24 -04:00
|
|
|
PyDoc_STRVAR(set_name_doc,
|
2023-11-13 03:13:49 -04:00
|
|
|
"__set_name__($self, owner, name, /)\n"
|
|
|
|
"--\n"
|
|
|
|
"\n"
|
2020-12-30 05:51:24 -04:00
|
|
|
"Method to set name of a property.");
|
|
|
|
|
|
|
|
static PyObject *
|
|
|
|
property_set_name(PyObject *self, PyObject *args) {
|
|
|
|
if (PyTuple_GET_SIZE(args) != 2) {
|
|
|
|
PyErr_Format(
|
|
|
|
PyExc_TypeError,
|
|
|
|
"__set_name__() takes 2 positional arguments but %d were given",
|
|
|
|
PyTuple_GET_SIZE(args));
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
propertyobject *prop = (propertyobject *)self;
|
|
|
|
PyObject *name = PyTuple_GET_ITEM(args, 1);
|
|
|
|
|
2022-11-10 11:27:32 -04:00
|
|
|
Py_XSETREF(prop->prop_name, Py_XNewRef(name));
|
2020-12-30 05:51:24 -04:00
|
|
|
|
|
|
|
Py_RETURN_NONE;
|
|
|
|
}
|
|
|
|
|
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 19:39:45 -04:00
|
|
|
static PyMethodDef property_methods[] = {
|
2010-05-09 12:52:27 -03:00
|
|
|
{"getter", property_getter, METH_O, getter_doc},
|
|
|
|
{"setter", property_setter, METH_O, setter_doc},
|
|
|
|
{"deleter", property_deleter, METH_O, deleter_doc},
|
2020-12-30 05:51:24 -04:00
|
|
|
{"__set_name__", property_set_name, METH_VARARGS, set_name_doc},
|
2010-05-09 12:52:27 -03:00
|
|
|
{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 19:39:45 -04:00
|
|
|
};
|
|
|
|
|
2001-09-24 18:17:50 -03:00
|
|
|
|
2001-08-23 18:40:38 -03:00
|
|
|
static void
|
2001-09-06 18:56:42 -03:00
|
|
|
property_dealloc(PyObject *self)
|
2001-08-23 18:40:38 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03: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);
|
2020-12-30 05:51:24 -04:00
|
|
|
Py_XDECREF(gs->prop_name);
|
2020-02-06 22:04:21 -04:00
|
|
|
Py_TYPE(self)->tp_free(self);
|
2001-08-23 18:40:38 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static PyObject *
|
2001-09-06 18:56:42 -03:00
|
|
|
property_descr_get(PyObject *self, PyObject *obj, PyObject *type)
|
2001-08-23 18:40:38 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
if (obj == NULL || obj == Py_None) {
|
2022-11-10 11:27:32 -04:00
|
|
|
return Py_NewRef(self);
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
2018-10-01 07:03:22 -03:00
|
|
|
|
|
|
|
propertyobject *gs = (propertyobject *)self;
|
2010-05-09 12:52:27 -03:00
|
|
|
if (gs->prop_get == NULL) {
|
2022-02-17 15:27:42 -04:00
|
|
|
PyObject *qualname = PyType_GetQualName(Py_TYPE(obj));
|
|
|
|
if (gs->prop_name != NULL && qualname != NULL) {
|
2022-02-16 03:07:34 -04:00
|
|
|
PyErr_Format(PyExc_AttributeError,
|
|
|
|
"property %R of %R object has no getter",
|
|
|
|
gs->prop_name,
|
2022-02-17 15:27:42 -04:00
|
|
|
qualname);
|
2022-02-16 03:07:34 -04:00
|
|
|
}
|
2022-02-17 15:27:42 -04:00
|
|
|
else if (qualname != NULL) {
|
2022-02-16 03:07:34 -04:00
|
|
|
PyErr_Format(PyExc_AttributeError,
|
|
|
|
"property of %R object has no getter",
|
2022-02-17 15:27:42 -04:00
|
|
|
qualname);
|
|
|
|
} else {
|
|
|
|
PyErr_SetString(PyExc_AttributeError,
|
|
|
|
"property has no getter");
|
2020-12-30 05:51:24 -04:00
|
|
|
}
|
2022-02-17 15:27:42 -04:00
|
|
|
Py_XDECREF(qualname);
|
2010-05-09 12:52:27 -03:00
|
|
|
return NULL;
|
|
|
|
}
|
2018-10-01 07:03:22 -03:00
|
|
|
|
2020-02-11 12:46:57 -04:00
|
|
|
return PyObject_CallOneArg(gs->prop_get, obj);
|
2001-08-23 18:40:38 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2001-09-06 18:56:42 -03:00
|
|
|
property_descr_set(PyObject *self, PyObject *obj, PyObject *value)
|
2001-08-23 18:40:38 -03:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
propertyobject *gs = (propertyobject *)self;
|
|
|
|
PyObject *func, *res;
|
|
|
|
|
2021-07-19 07:13:27 -03:00
|
|
|
if (value == NULL) {
|
2010-05-09 12:52:27 -03:00
|
|
|
func = gs->prop_del;
|
2021-07-19 07:13:27 -03:00
|
|
|
}
|
|
|
|
else {
|
2010-05-09 12:52:27 -03:00
|
|
|
func = gs->prop_set;
|
2021-07-19 07:13:27 -03:00
|
|
|
}
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
if (func == NULL) {
|
2022-02-17 15:27:42 -04:00
|
|
|
PyObject *qualname = NULL;
|
|
|
|
if (obj != NULL) {
|
|
|
|
qualname = PyType_GetQualName(Py_TYPE(obj));
|
|
|
|
}
|
|
|
|
if (gs->prop_name != NULL && qualname != NULL) {
|
2020-12-30 05:51:24 -04:00
|
|
|
PyErr_Format(PyExc_AttributeError,
|
2010-05-09 12:52:27 -03:00
|
|
|
value == NULL ?
|
2022-02-16 03:07:34 -04:00
|
|
|
"property %R of %R object has no deleter" :
|
|
|
|
"property %R of %R object has no setter",
|
|
|
|
gs->prop_name,
|
2022-02-17 15:27:42 -04:00
|
|
|
qualname);
|
2022-02-16 03:07:34 -04:00
|
|
|
}
|
2022-02-17 15:27:42 -04:00
|
|
|
else if (qualname != NULL) {
|
2022-02-16 03:07:34 -04:00
|
|
|
PyErr_Format(PyExc_AttributeError,
|
|
|
|
value == NULL ?
|
|
|
|
"property of %R object has no deleter" :
|
|
|
|
"property of %R object has no setter",
|
2022-02-17 15:27:42 -04:00
|
|
|
qualname);
|
2021-07-19 07:13:27 -03:00
|
|
|
}
|
|
|
|
else {
|
2020-12-30 05:51:24 -04:00
|
|
|
PyErr_SetString(PyExc_AttributeError,
|
2022-02-16 03:07:34 -04:00
|
|
|
value == NULL ?
|
|
|
|
"property has no deleter" :
|
|
|
|
"property has no setter");
|
2020-12-30 05:51:24 -04:00
|
|
|
}
|
2022-02-17 15:27:42 -04:00
|
|
|
Py_XDECREF(qualname);
|
2010-05-09 12:52:27 -03:00
|
|
|
return -1;
|
|
|
|
}
|
2021-07-19 07:13:27 -03:00
|
|
|
|
|
|
|
if (value == NULL) {
|
2020-02-11 12:46:57 -04:00
|
|
|
res = PyObject_CallOneArg(func, obj);
|
2021-07-19 07:13:27 -03:00
|
|
|
}
|
|
|
|
else {
|
2022-05-27 12:31:41 -03:00
|
|
|
EVAL_CALL_STAT_INC_IF_FUNCTION(EVAL_CALL_API, func);
|
2021-07-19 07:13:27 -03:00
|
|
|
PyObject *args[] = { obj, value };
|
|
|
|
res = PyObject_Vectorcall(func, args, 2, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (res == NULL) {
|
2010-05-09 12:52:27 -03:00
|
|
|
return -1;
|
2021-07-19 07:13:27 -03:00
|
|
|
}
|
|
|
|
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_DECREF(res);
|
|
|
|
return 0;
|
2001-08-23 18:40:38 -03: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-14 21:27:15 -04:00
|
|
|
static PyObject *
|
2010-06-28 00:07:10 -03: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-14 21:27:15 -04:00
|
|
|
{
|
2010-05-09 12:52:27 -03:00
|
|
|
propertyobject *pold = (propertyobject *)old;
|
2010-06-28 00:07:10 -03:00
|
|
|
PyObject *new, *type, *doc;
|
2010-05-09 12:52:27 -03: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 00:07:10 -03: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 12:52:27 -03:00
|
|
|
}
|
|
|
|
|
2016-12-09 11:22:32 -04:00
|
|
|
new = PyObject_CallFunctionObjArgs(type, get, set, del, doc, NULL);
|
2010-05-09 12:52:27 -03:00
|
|
|
Py_DECREF(type);
|
|
|
|
if (new == NULL)
|
|
|
|
return NULL;
|
2020-12-30 05:51:24 -04:00
|
|
|
|
2023-01-12 18:13:56 -04:00
|
|
|
if (PyObject_TypeCheck((new), &PyProperty_Type)) {
|
|
|
|
Py_XSETREF(((propertyobject *) new)->prop_name, Py_XNewRef(pold->prop_name));
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
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-14 21:27:15 -04:00
|
|
|
}
|
|
|
|
|
2017-03-19 03:51:07 -03:00
|
|
|
/*[clinic input]
|
|
|
|
property.__init__ as property_init
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2017-03-19 03:51:07 -03: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 12:52:27 -03:00
|
|
|
|
2017-03-19 03:51:07 -03: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 12:52:27 -03:00
|
|
|
|
2017-03-19 03:51:07 -03: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;
|
|
|
|
|
2022-11-10 11:27:32 -04:00
|
|
|
Py_XSETREF(self->prop_get, Py_XNewRef(fget));
|
|
|
|
Py_XSETREF(self->prop_set, Py_XNewRef(fset));
|
|
|
|
Py_XSETREF(self->prop_del, Py_XNewRef(fdel));
|
2022-05-29 00:25:51 -03:00
|
|
|
Py_XSETREF(self->prop_doc, NULL);
|
2020-12-30 05:51:24 -04:00
|
|
|
Py_XSETREF(self->prop_name, NULL);
|
|
|
|
|
2017-03-19 03:51:07 -03:00
|
|
|
self->getter_doc = 0;
|
2022-05-29 00:25:51 -03:00
|
|
|
PyObject *prop_doc = NULL;
|
2010-05-09 12:52:27 -03:00
|
|
|
|
2022-05-29 00:25:51 -03:00
|
|
|
if (doc != NULL && doc != Py_None) {
|
2022-11-10 11:27:32 -04:00
|
|
|
prop_doc = Py_XNewRef(doc);
|
2022-05-29 00:25:51 -03:00
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
/* if no docstring given and the getter has one, use that one */
|
2022-05-29 00:25:51 -03:00
|
|
|
else if (fget != NULL) {
|
2023-07-12 02:57:10 -03:00
|
|
|
int rc = PyObject_GetOptionalAttr(fget, &_Py_ID(__doc__), &prop_doc);
|
2019-09-01 06:03:39 -03:00
|
|
|
if (rc <= 0) {
|
|
|
|
return rc;
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
2023-06-05 00:18:15 -03:00
|
|
|
if (!Py_IS_TYPE(self, &PyProperty_Type) &&
|
|
|
|
prop_doc != NULL && prop_doc != Py_None) {
|
|
|
|
// This oddity preserves the long existing behavior of surfacing
|
|
|
|
// an AttributeError when using a dict-less (__slots__) property
|
|
|
|
// subclass as a decorator on a getter method with a docstring.
|
|
|
|
// See PropertySubclassTest.test_slots_docstring_copy_exception.
|
|
|
|
int err = PyObject_SetAttr(
|
|
|
|
(PyObject *)self, &_Py_ID(__doc__), prop_doc);
|
|
|
|
if (err < 0) {
|
|
|
|
Py_DECREF(prop_doc); // release our new reference.
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2022-05-29 00:25:51 -03:00
|
|
|
if (prop_doc == Py_None) {
|
|
|
|
prop_doc = NULL;
|
|
|
|
Py_DECREF(Py_None);
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
2022-05-29 00:25:51 -03:00
|
|
|
if (prop_doc != NULL){
|
|
|
|
self->getter_doc = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* At this point `prop_doc` is either NULL or
|
|
|
|
a non-None object with incremented ref counter */
|
|
|
|
|
|
|
|
if (Py_IS_TYPE(self, &PyProperty_Type)) {
|
|
|
|
Py_XSETREF(self->prop_doc, prop_doc);
|
|
|
|
} else {
|
2023-06-05 00:18:15 -03:00
|
|
|
/* If this is a property subclass, put __doc__ in the dict
|
|
|
|
or designated slot of the subclass instance instead, otherwise
|
|
|
|
it gets shadowed by __doc__ in the class's dict. */
|
2022-05-29 00:25:51 -03:00
|
|
|
|
|
|
|
if (prop_doc == NULL) {
|
2022-11-10 11:27:32 -04:00
|
|
|
prop_doc = Py_NewRef(Py_None);
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
2022-05-29 00:25:51 -03:00
|
|
|
int err = PyObject_SetAttr(
|
|
|
|
(PyObject *)self, &_Py_ID(__doc__), prop_doc);
|
2023-06-05 00:18:15 -03:00
|
|
|
Py_DECREF(prop_doc);
|
|
|
|
if (err < 0) {
|
|
|
|
assert(PyErr_Occurred());
|
|
|
|
if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
|
|
|
|
PyErr_Clear();
|
|
|
|
// https://github.com/python/cpython/issues/98963#issuecomment-1574413319
|
|
|
|
// Python silently dropped this doc assignment through 3.11.
|
|
|
|
// We preserve that behavior for backwards compatibility.
|
|
|
|
//
|
|
|
|
// If we ever want to deprecate this behavior, only raise a
|
|
|
|
// warning or error when proc_doc is not None so that
|
|
|
|
// property without a specific doc= still works.
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
2010-05-09 12:52:27 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2001-08-23 18:40:38 -03:00
|
|
|
}
|
|
|
|
|
2011-12-15 16:34:02 -04: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 18:24:57 -03:00
|
|
|
static int
|
|
|
|
property_traverse(PyObject *self, visitproc visit, void *arg)
|
|
|
|
{
|
2010-05-09 12:52:27 -03: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);
|
2020-12-30 05:51:24 -04:00
|
|
|
Py_VISIT(pp->prop_name);
|
2010-05-09 12:52:27 -03: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 18:24:57 -03:00
|
|
|
}
|
|
|
|
|
2015-05-13 15:12:33 -03:00
|
|
|
static int
|
|
|
|
property_clear(PyObject *self)
|
|
|
|
{
|
|
|
|
propertyobject *pp = (propertyobject *)self;
|
|
|
|
Py_CLEAR(pp->prop_doc);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-03-19 03:51:07 -03: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 */
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_dealloc, /* tp_dealloc */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_vectorcall_offset */
|
2017-03-19 03:51:07 -03:00
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_as_async */
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_repr, /* tp_repr */
|
2020-03-07 15:03:09 -04:00
|
|
|
&mappingproxy_as_number, /* tp_as_number */
|
2017-03-19 03:51:07 -03:00
|
|
|
&mappingproxy_as_sequence, /* tp_as_sequence */
|
|
|
|
&mappingproxy_as_mapping, /* tp_as_mapping */
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_hash, /* tp_hash */
|
2017-03-19 03:51:07 -03:00
|
|
|
0, /* tp_call */
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_str, /* tp_str */
|
2017-03-19 03:51:07 -03:00
|
|
|
PyObject_GenericGetAttr, /* tp_getattro */
|
|
|
|
0, /* tp_setattro */
|
|
|
|
0, /* tp_as_buffer */
|
2021-04-30 05:50:28 -03:00
|
|
|
Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
|
|
|
|
Py_TPFLAGS_MAPPING, /* tp_flags */
|
2017-03-19 03:51:07 -03:00
|
|
|
0, /* tp_doc */
|
|
|
|
mappingproxy_traverse, /* tp_traverse */
|
|
|
|
0, /* tp_clear */
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_richcompare, /* tp_richcompare */
|
2017-03-19 03:51:07 -03:00
|
|
|
0, /* tp_weaklistoffset */
|
2024-01-02 10:03:39 -04:00
|
|
|
mappingproxy_getiter, /* tp_iter */
|
2017-03-19 03:51:07 -03:00
|
|
|
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 18:56:42 -03:00
|
|
|
PyTypeObject PyProperty_Type = {
|
2010-05-09 12:52:27 -03:00
|
|
|
PyVarObject_HEAD_INIT(&PyType_Type, 0)
|
|
|
|
"property", /* tp_name */
|
|
|
|
sizeof(propertyobject), /* tp_basicsize */
|
|
|
|
0, /* tp_itemsize */
|
|
|
|
/* methods */
|
|
|
|
property_dealloc, /* tp_dealloc */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_vectorcall_offset */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_getattr */
|
|
|
|
0, /* tp_setattr */
|
2019-05-30 23:13:39 -03:00
|
|
|
0, /* tp_as_async */
|
2010-05-09 12:52:27 -03:00
|
|
|
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 03:51:07 -03:00
|
|
|
property_init__doc__, /* tp_doc */
|
2010-05-09 12:52:27 -03:00
|
|
|
property_traverse, /* tp_traverse */
|
2024-01-02 10:03:39 -04:00
|
|
|
property_clear, /* tp_clear */
|
2010-05-09 12:52:27 -03:00
|
|
|
0, /* tp_richcompare */
|
|
|
|
0, /* tp_weaklistoffset */
|
|
|
|
0, /* tp_iter */
|
|
|
|
0, /* tp_iternext */
|
|
|
|
property_methods, /* tp_methods */
|
|
|
|
property_members, /* tp_members */
|
2011-12-15 16:34:02 -04:00
|
|
|
property_getsetlist, /* tp_getset */
|
2010-05-09 12:52:27 -03: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 18:40:38 -03:00
|
|
|
};
|