[Jython-checkins] jython: Eventually consistent hack for looking up __getattribute__ from the object

darjus.loktevic jython-checkins at python.org
Tue Aug 16 20:23:18 EDT 2016


https://hg.python.org/jython/rev/f3458ef83e08
changeset:   7926:f3458ef83e08
user:        Darjus Loktevic <darjus at gmail.com>
date:        Wed Aug 17 10:23:00 2016 +1000
summary:
  Eventually consistent hack for looking up __getattribute__ from the object cache. Related to #2487

files:
  src/org/python/core/Deriveds.java |  14 +++++++++++---
  1 files changed, 11 insertions(+), 3 deletions(-)


diff --git a/src/org/python/core/Deriveds.java b/src/org/python/core/Deriveds.java
--- a/src/org/python/core/Deriveds.java
+++ b/src/org/python/core/Deriveds.java
@@ -46,12 +46,20 @@
                 // pass through to __getattr__
             } else {
                 PyObject getattribute = type.lookup("__getattribute__");
+                // This is a horrible hack for eventual consistency of the cache. We hope that the cached version
+                // becomes available, but don't wait forever.
+                for (int i = 0; i < 100000; i++) {
+                    if (getattribute != null) {
+                        break;
+                    }
+                    getattribute = type.lookup("__getattribute__");
+                }
                 if (getattribute == null) {
                     // This shouldn't happen
-                    throw Py.SystemError(String.format("__getattribute__ not found on type %s",
-                                                       type.getName()));
+                    throw Py.SystemError(String.format(
+                            "__getattribute__ not found on type %s. See http://bugs.jython.org/issue2487 for details.",
+                            type.getName()));
                 }
-
                 if (getattribute == objectGetattribute) {
                     type.setUsesObjectGetattribute(true);
                 }

-- 
Repository URL: https://hg.python.org/jython


More information about the Jython-checkins mailing list