Ejemplo n.º 1
0
 def _load_lazily(self, space, name):
     w_name = space.new_interned_str(name)
     try:
         loader = self.loaders[name]
     except KeyError:
         return None
     else:
         w_value = loader(space)
         # the idea of the following code is that all functions that are
         # directly in a mixed-module are "builtin", e.g. they get a
         # special type without a __get__
         # note that this is not just all functions that contain a
         # builtin code object, as e.g. methods of builtin types have to
         # be normal Functions to get the correct binding behaviour
         func = w_value
         if (isinstance(func, Function)
                 and type(func) is not BuiltinFunction):
             try:
                 bltin = func._builtinversion_
             except AttributeError:
                 bltin = BuiltinFunction(func)
                 bltin.w_module = self.w_name
                 func._builtinversion_ = bltin
                 bltin.name = name
                 bltin.qualname = bltin.name.decode('utf-8')
             w_value = bltin
         space.setitem(self.w_dict, w_name, w_value)
         return w_value