Ali Gholami Rudi  committed 7c2d7a0

Making every change force all pymodules to forget concluded data

  • Participants
  • Parent commits 12d8d27
  • Branches trunk

Comments (0)

Files changed (5)

File docs/dev/issues.txt

 The current approach fails in all of these.
+Why weakref cannot be used in ConcludedData?
+  Concluded data can hold anything.  It can hold a `PyObject` whose
+  type might be invalidated.  But since that pyobject is not
+  referenced it is considered garbage.
 How `_ConcludedData` Is Used
 The former is already handled.  But the other problem exists mainly
 because of SOI.
+The other problem happens when data in our objectdb is retrieved.  No
+dependency is added to pycore for such things.
+So the easiest approach would be to forget all concluded data with
+every change.
 Adding `PyModule.register_invalidation_observer()`
 If other approaches fails I have to use this.  We have to handle
-loops, by the way.
+loops, by the way.  In the end, it does not solve all of the problems!
 Better Concluded Data

File docs/dev/stories.txt

 * Renaming and moving normal files/folders
+* Sorting methods
 * Lambdas as functions; consider their parameters

File docs/dev/workingon.txt

 Small Stories
-- Adding `PyModule.is_valid()`
+- Every change makes all pymodules forget all concluded data
 * Using weakref to prevent unnecessary invalidation?
 * Moving `PyCore.create_module()` and `PyCore.create_package()`?

File rope/base/

     def _invalidate_resource(self, resource):
         if resource in self.module_map:
-            self.forget_data(resource)
+            # XXX: Forgetting all data due to invalidation problems
+            # TODO: Very inefficient
+            #self.forget_data(resource)
+            self.forget_all_data()
             del self.module_map[resource]
             del self.dependents[resource]

File ropetest/

         p_type = f_scope.get_name('p').get_object().get_type()
         self.assertEquals(c_class, p_type)
+    def test_validation_problems_for_objectdb_retrievals(self):
+        mod1 = self.pycore.create_module(self.project.root, 'mod1')
+        mod2 = self.pycore.create_module(self.project.root, 'mod2')
+        mod1.write('l = []\nvar = l.pop()\n')
+        mod2.write('import mod1\n\nclass C(object):\n    pass\n'
+                   'mod1.l.append(C())\n')
+        self.pycore.analyze_module(mod2)
+        pymod2 = self.pycore.resource_to_pyobject(mod2)
+        c_class = pymod2.get_attribute('C').get_object()
+        pymod1 = self.pycore.resource_to_pyobject(mod1)
+        var_pyname = pymod1.get_attribute('var')
+        self.assertEquals(c_class, var_pyname.get_object().get_type())
+        mod2.write('import mod1\n\nmod1.l.append("")\n')
+        # Either `pymod1` should be invalid or should not reference to `pymod2`
+        if pymod1.is_valid():
+            self.assertNotEquals(c_class, var_pyname.get_object().get_type(),
+                                 'Class `C` no more exists')
 def suite():
     result = unittest.TestSuite()