STINNER Victor added the comment:

The issue is that the Meta class has a reference to the class Foo in its mro() 
method, but Foo is not aware of Meta. So when Foo is modified, the Foo cache is 
invalidated, but not Meta cache.

issue28866.diff always invalidates the cache, so it works. But it is 
suboptimal, IMO it defeats the whole purpose of a cache.

I never defined a mro() method. I'm not sure that it's possible to have a type 
cache and a mro() method?

Options:

* Disable completely the cache on classes defining mro()
* Modify "Meta" (the C code implementing the type, not the Python code) to 
track the version tag of each class referenced by mro(). Problem: mro() is 
dynamic!?
* Somehow, notify Foo that Meta has a reference to its cache, so Foo is able to 
invalidate Meta cache

----------
title: Unexpected behavior resulting from mro() and __setattr__ in interactive 
mode -> Type cache is not correctly invalidated on a class defining mro()

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue28866>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to