def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_Buffer.typedef: W_Buffer, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_IntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_LongObject.typedef: W_LongObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type name = typedef.name # we don't expose 'space.w_str' at all, to avoid confusion # with Python 3. Instead, in Python 2, it becomes # space.w_bytes (or space.w_text). if name == 'str': name = 'bytes' setattr(self, 'w_' + name, w_type) self._interplevel_classes[w_type] = cls self.w_text = self.w_bytes # 'space.w_text' is w_unicode on Py3 self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis self.w_basestring = self.builtin_types['basestring'] = \ self.gettypeobject(basestring_typedef) # exceptions & builtins self.make_builtins() # the type of old-style classes self.w_classobj = self.builtin.get('__metaclass__') # final setup self.setup_builtin_modules() # Adding transparent proxy call if self.config.objspace.std.withtproxy: transparent.setup(self)
def initialize(self): """only for initializing the space Setup all the object types and implementations. """ setup_prebuilt(self) self.FrameClass = frame.build_frame(self) self.StringObjectCls = W_BytesObject self.UnicodeObjectCls = W_UnicodeObject # singletons self.w_None = W_NoneObject.w_None self.w_False = W_BoolObject.w_False self.w_True = W_BoolObject.w_True self.w_NotImplemented = self.wrap(special.NotImplemented()) self.w_Ellipsis = self.wrap(special.Ellipsis()) # types builtin_type_classes = { W_BoolObject.typedef: W_BoolObject, W_BytearrayObject.typedef: W_BytearrayObject, W_BytesObject.typedef: W_BytesObject, W_ComplexObject.typedef: W_ComplexObject, W_DictMultiObject.typedef: W_DictMultiObject, W_FloatObject.typedef: W_FloatObject, W_IntObject.typedef: W_AbstractIntObject, W_AbstractSeqIterObject.typedef: W_AbstractSeqIterObject, W_ListObject.typedef: W_ListObject, W_MemoryView.typedef: W_MemoryView, W_NoneObject.typedef: W_NoneObject, W_ObjectObject.typedef: W_ObjectObject, W_SetObject.typedef: W_SetObject, W_FrozensetObject.typedef: W_FrozensetObject, W_SliceObject.typedef: W_SliceObject, W_TupleObject.typedef: W_TupleObject, W_TypeObject.typedef: W_TypeObject, W_UnicodeObject.typedef: W_UnicodeObject, } self.builtin_types = {} self._interplevel_classes = {} for typedef, cls in builtin_type_classes.items(): w_type = self.gettypeobject(typedef) self.builtin_types[typedef.name] = w_type setattr(self, 'w_' + typedef.name, w_type) self._interplevel_classes[w_type] = cls # The loop above sets space.w_str and space.w_bytes. # We rename 'space.w_str' to 'space.w_unicode' and # 'space.w_text'. self.w_unicode = self.w_str self.w_text = self.w_str del self.w_str self.w_long = self.w_int self.w_dict.flag_map_or_seq = 'M' from pypy.objspace.std import dictproxyobject dictproxyobject._set_flag_map_or_seq(self) self.w_list.flag_map_or_seq = 'S' self.w_tuple.flag_map_or_seq = 'S' self.builtin_types['str'] = self.w_unicode self.builtin_types['bytes'] = self.w_bytes self.builtin_types["NotImplemented"] = self.w_NotImplemented self.builtin_types["Ellipsis"] = self.w_Ellipsis # exceptions & builtins self.make_builtins() # final setup self.setup_builtin_modules() # Adding transparent proxy call if self.config.objspace.std.withtproxy: transparent.setup(self)