Commits

Anonymous committed 8d8068c

builtins: getting per name data after type change for dicts

  • Participants
  • Parent commits dea3c1a

Comments (0)

Files changed (2)

File rope/base/builtins.py

         if self.keys is not None:
             return get_tuple(self.keys, self.values)
         item = context.get_per_name()
-        if item is None:
+        if item is None or not isinstance(item.get_type(), Tuple):
             return get_tuple(self.keys, self.values)
         return item
 

File ropetest/advanced_oi_test.py

         self.assertNotEquals(c_class, var_pyname.get_object().get_type(),
                              'Class `C` no more exists')
 
+    def test_validation_problems_for_changing_builtin_types(self):
+        mod1 = testutils.create_module(self.project, 'mod1')
+        mod1.write('l = []\nl.append("")\n')
+        self.pycore.analyze_module(mod1)
+
+        mod1.write('l = {}\nv = l["key"]\n')
+        pymod1 = self.pycore.resource_to_pyobject(mod1)
+        var = pymod1['v'].get_object()
+
     def test_always_returning_containing_class_for_selfs(self):
         code = 'class A(object):\n    def f(p):\n        return p\n' \
                'class B(object):\n    pass\nb = B()\nb.f()\n'