1. Jasper St. Pierre
  2. pypy-avm


Lukas Diekmann  committed ab926f8

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

  • Participants
  • Parent commits f0418b9
  • Branches new-dict-proxy

Comments (0)

Files changed (2)

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

View file
  • Ignore whitespace
             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

View file
  • Ignore whitespace
     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__')
             # 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__'),
-                return w_self.dict_w['__module__']
+                return w_self.getdictvalue(space, '__module__')
             return space.wrap('__builtin__')
     def get_module_type_name(w_self):