Document a possible attribute cache issue with the proposed changes to PyObject_GenericGetAttr

This commit is contained in:
Ronald Oussoren 2013-07-15 17:10:15 +02:00
parent 95e6879313
commit bfec474381
1 changed files with 12 additions and 1 deletions

View File

@ -7,7 +7,7 @@ Status: Draft
Type: Standards Track
Content-Type: text/x-rst
Created: 12-Jun-2013
Post-History: 2-Jul-2013, ?
Post-History: 2-Jul-2013, 15-Jul-2013
Abstract
@ -137,6 +137,17 @@ Open Issues
slightly faster because it doesn't have to overhead of setting up exception state, but
makes it impossible to use that value as an attribute on a class.
* The proposed change to `PyObject_GenericGetAttr`_ will probably cause problems with the
attribute lookup cache (MCACHE):
1. That code stores borrowed references, which won't work when the hook is present. That
is mostly fixable, but at the cost of possibly keeping garbage alive.
2. Caching isn't an option when a hook might execute arbitrary code (and there hence is
no reason to assume that the hooks return value won't change later on).
The only workaround I could find for this is to make the hook a fallback (that is,
more like ``__getattr__`` than ``__getattribute__``).
References
==========