[issue18047] Descriptors get invoked in old-style objects and classes

2013-05-29 Thread Raymond Hettinger

Raymond Hettinger added the comment:

We document what we're willing to guarantee.  The exposure of descriptors in 
old-style classes was an incidental implementation detail.

Sorry, I'm going to close this one.   Besides, it's time to start forgetting 
Python 2 and move along :-)

--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18047
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18047] Descriptors get invoked in old-style objects and classes

2013-05-28 Thread Arnaud Porterie

Arnaud Porterie added the comment:

Sorry if I am missing something, but it seems that the documentation doesn't 
match the behavior: the doc says that descriptors are invoked only for new 
styles objects and classes, while the attached code seems to prove the contrary.

If my understanding is correct, either the doc or the code should be changed 
accordingly.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18047
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18047] Descriptors get invoked in old-style objects and classes

2013-05-27 Thread Raymond Hettinger

Raymond Hettinger added the comment:

IMO nothing should change here (either the docs or the implementation).

The OP has observed an implementation detail of old-style classes (which were 
reimplemented in Python 2.2 using descriptor logic instead of their former 
hard-wired behaviors).

--
nosy: +rhettinger

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18047
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18047] Descriptors get invoked in old-style objects and classes

2013-05-26 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti
stage:  - needs patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18047
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18047] Descriptors get invoked in old-style objects and classes

2013-05-25 Thread Phil Connell

Changes by Phil Connell pconn...@gmail.com:


--
nosy: +pconnell

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18047
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18047] Descriptors get invoked in old-style objects and classes

2013-05-25 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18047
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue18047] Descriptors get invoked in old-style objects and classes

2013-05-23 Thread Arnaud Porterie

New submission from Arnaud Porterie:

In the Data Model section of the documentation regarding descriptors 
invokations 
(http://docs.python.org/2/reference/datamodel.html#invoking-descriptors), it is 
said:

Note that descriptors are only invoked for new style objects or classes 
(ones that subclass object() or type()).

However, it seems this restriction isn't enforced in practice:

Python 2.7.4 (default, May 16 2013, 13:28:03)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.60))] on 
darwin
Type help, copyright, credits or license for more information.
 class Desc(object):
... def __get__(self, obj, cls):
... return 'test'
...
 class A:  # Not inheriting object here
... desc = Desc()
...
 A().desc
'test'

I dived into CPython's code and saw no trace of a test for new-style classes in 
the descriptor invokation code path (down in classobject.c / instance_getattr2).

Unfortunately, fixing this behavior doesn't seem trivial as class methods 
appear to be implemented as descriptor themselves. In other words, and from my 
understanding, restricting descriptor invokation to new-style objects and 
classes would prevent method calls on old-style classes.

--
components: Interpreter Core
files: desc.py
messages: 189896
nosy: icecrime
priority: normal
severity: normal
status: open
title: Descriptors get invoked in old-style objects and classes
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file30356/desc.py

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue18047
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com