mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
- super() no longer ignores data descriptors, except __class__. See
the thread started at http://mail.python.org/pipermail/python-dev/2003-April/034338.html
This commit is contained in:
parent
954bcf5fe0
commit
76ba09fd81
2 changed files with 14 additions and 4 deletions
|
|
@ -12,6 +12,10 @@ What's New in Python 2.3 beta 1?
|
||||||
Core and builtins
|
Core and builtins
|
||||||
-----------------
|
-----------------
|
||||||
|
|
||||||
|
- super() no longer ignores data descriptors, except __class__. See
|
||||||
|
the thread started at
|
||||||
|
http://mail.python.org/pipermail/python-dev/2003-April/034338.html
|
||||||
|
|
||||||
- list.insert(i, x) now interprets negative i as it would be
|
- list.insert(i, x) now interprets negative i as it would be
|
||||||
interpreted by slicing, so negative values count from the end of the
|
interpreted by slicing, so negative values count from the end of the
|
||||||
list. This was the only place where such an interpretation was not
|
list. This was the only place where such an interpretation was not
|
||||||
|
|
|
||||||
|
|
@ -5359,8 +5359,17 @@ static PyObject *
|
||||||
super_getattro(PyObject *self, PyObject *name)
|
super_getattro(PyObject *self, PyObject *name)
|
||||||
{
|
{
|
||||||
superobject *su = (superobject *)self;
|
superobject *su = (superobject *)self;
|
||||||
|
int skip = su->obj_type == NULL;
|
||||||
|
|
||||||
if (su->obj_type != NULL) {
|
if (!skip) {
|
||||||
|
/* We want __class__ to return the class of the super object
|
||||||
|
(i.e. super, or a subclass), not the class of su->obj. */
|
||||||
|
skip = (PyString_Check(name) &&
|
||||||
|
PyString_GET_SIZE(name) == 9 &&
|
||||||
|
strcmp(PyString_AS_STRING(name), "__class__") == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!skip) {
|
||||||
PyObject *mro, *res, *tmp, *dict;
|
PyObject *mro, *res, *tmp, *dict;
|
||||||
PyTypeObject *starttype;
|
PyTypeObject *starttype;
|
||||||
descrgetfunc f;
|
descrgetfunc f;
|
||||||
|
|
@ -5390,9 +5399,6 @@ super_getattro(PyObject *self, PyObject *name)
|
||||||
else
|
else
|
||||||
continue;
|
continue;
|
||||||
res = PyDict_GetItem(dict, name);
|
res = PyDict_GetItem(dict, name);
|
||||||
/* Skip data descriptors because when obj_type is a
|
|
||||||
metaclass, we don't want to return its __class__
|
|
||||||
descriptor. See supers() in test_descr.py. */
|
|
||||||
if (res != NULL && !PyDescr_IsData(res)) {
|
if (res != NULL && !PyDescr_IsData(res)) {
|
||||||
Py_INCREF(res);
|
Py_INCREF(res);
|
||||||
f = res->ob_type->tp_descr_get;
|
f = res->ob_type->tp_descr_get;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue