Commits

Lukas Diekmann  committed 52ee3ce

Fixed bug in W_TypeObject.get_module: we cannot directly read values from w_dict anymore

  • Participants
  • Parent commits 0d2f84a
  • Branches new-dict-proxy

Comments (0)

Files changed (2)

File pypy/objspace/std/test/test_methodcache.py

             setattr(a, "a%s" % i, i)
         cache_counter = __pypy__.method_cache_counter("x")
         assert cache_counter[0] == 0 # 0 hits, because all the attributes are new
+
+    def test_get_module_from_namedtuple(self):
+        # this used to crash
+        from collections import namedtuple
+        assert namedtuple("a", "b").__module__

File pypy/objspace/std/typeobject.py

     def get_module(w_self):
         space = w_self.space
         if w_self.is_heaptype() and '__module__' in w_self.dict_w:
-            return w_self.dict_w['__module__']
+            return w_self.getdictvalue(space, '__module__')
         else:
             # for non-heap types, CPython checks for a module.name in the
             # type name.  That's a hack, so we're allowed to use a different
             # hack...
             if ('__module__' in w_self.dict_w and
-                space.is_true(space.isinstance(w_self.dict_w['__module__'],
+                space.is_true(space.isinstance(w_self.getdictvalue(space, '__module__'),
                                                space.w_str))):
-                return w_self.dict_w['__module__']
+                return w_self.getdictvalue(space, '__module__')
             return space.wrap('__builtin__')
 
     def get_module_type_name(w_self):