示例#1
0
文件: mapdict.py 项目: sota/pypy-old
 def getitem(self, w_dict, w_key):
     space = self.space
     w_lookup_type = space.type(w_key)
     if space.is_w(w_lookup_type, space.w_str):
         return self.getitem_str(w_dict, space.str_w(w_key))
     elif _never_equal_to_string(space, w_lookup_type):
         return None
     else:
         self.switch_to_object_strategy(w_dict)
         return w_dict.getitem(w_key)
示例#2
0
文件: mapdict.py 项目: Debug-Orz/Sypy
 def getitem(self, w_dict, w_key):
     space = self.space
     w_lookup_type = space.type(w_key)
     if space.is_w(w_lookup_type, space.w_str):
         return self.getitem_str(w_dict, space.str_w(w_key))
     elif _never_equal_to_string(space, w_lookup_type):
         return None
     else:
         self.switch_to_object_strategy(w_dict)
         return w_dict.getitem(w_key)
示例#3
0
 def getitem(self, w_dict, w_key):
     space = self.space
     w_lookup_type = space.type(w_key)
     key = self.try_unwrap_key(space, w_key)
     if key is not None:
         return self.getitem_str(w_dict, key)
     elif _never_equal_to_string(space, w_lookup_type):
         return None
     else:
         self.switch_to_object_strategy(w_dict)
         return w_dict.getitem(w_key)
示例#4
0
文件: mapdict.py 项目: Debug-Orz/Sypy
 def delitem(self, w_dict, w_key):
     space = self.space
     w_key_type = space.type(w_key)
     w_obj = self.unerase(w_dict.dstorage)
     if space.is_w(w_key_type, space.w_str):
         key = self.space.str_w(w_key)
         flag = w_obj.deldictvalue(space, key)
         if not flag:
             raise KeyError
     elif _never_equal_to_string(space, w_key_type):
         raise KeyError
     else:
         self.switch_to_object_strategy(w_dict)
         w_dict.delitem(w_key)
示例#5
0
文件: mapdict.py 项目: sota/pypy-old
 def delitem(self, w_dict, w_key):
     space = self.space
     w_key_type = space.type(w_key)
     w_obj = self.unerase(w_dict.dstorage)
     if space.is_w(w_key_type, space.w_str):
         key = self.space.str_w(w_key)
         flag = w_obj.deldictvalue(space, key)
         if not flag:
             raise KeyError
     elif _never_equal_to_string(space, w_key_type):
         raise KeyError
     else:
         self.switch_to_object_strategy(w_dict)
         w_dict.delitem(w_key)
示例#6
0
 def delitem(self, w_dict, w_key):
     space = self.space
     w_key_type = space.type(w_key)
     if space.is_w(w_key_type, space.w_str):
         key = space.str_w(w_key)
         dict_w = self.unerase(w_dict.dstorage)
         try:
             del dict_w[key]
         except KeyError:
             raise
         else:
             self.mutated()
     elif _never_equal_to_string(space, w_key_type):
         raise KeyError
     else:
         self.switch_to_object_strategy(w_dict)
         w_dict.delitem(w_key)
示例#7
0
 def delitem(self, w_dict, w_key):
     space = self.space
     w_key_type = space.type(w_key)
     if space.is_w(w_key_type, space.w_str):
         key = space.str_w(w_key)
         dict_w = self.unerase(w_dict.dstorage)
         try:
             del dict_w[key]
         except KeyError:
             raise
         else:
             self.mutated()
     elif _never_equal_to_string(space, w_key_type):
         raise KeyError
     else:
         self.switch_to_object_strategy(w_dict)
         w_dict.delitem(w_key)
示例#8
0
 def delitem(self, w_dict, w_key):
     space = self.space
     w_key_type = space.type(w_key)
     key = self.try_unwrap_key(space, w_key)
     if key is not None:
         dict_w = self.unerase(w_dict.dstorage)
         try:
             del dict_w[key]
         except KeyError:
             raise
         else:
             self.mutated()
     elif _never_equal_to_string(space, w_key_type):
         raise KeyError
     else:
         self.switch_to_object_strategy(w_dict)
         w_dict.delitem(w_key)
示例#9
0
文件: celldict.py 项目: Mu-L/pypy
 def delitem(self, w_dict, w_key):
     space = self.space
     w_key_type = space.type(w_key)
     if space.is_w(w_key_type, space.w_text):
         key = space.text_w(w_key)
         dict_w = self.unerase(w_dict.dstorage)
         try:
             del dict_w[key]
         except KeyError:
             raise
         else:
             if self.caches:
                 cache = self.caches.get(key, None)
                 if cache:
                     cache.cell = None
             self.mutated()
     elif _never_equal_to_string(space, w_key_type):
         raise KeyError
     else:
         self.switch_to_object_strategy(w_dict)
         w_dict.delitem(w_key)