コード例 #1
0
 def _type_isinstance(self, w_inst, w_type):
     if not isinstance(w_type, W_TypeObject):
         raise oefmt(self.w_TypeError, "need type object")
     if is_annotation_constant(w_type):
         cls = self._get_interplevel_cls(w_type)
         if cls is not None:
             assert w_inst is not None
             if isinstance(w_inst, cls):
                 return True
     return self.type(w_inst).issubtype(w_type)
コード例 #2
0
ファイル: objspace.py プロジェクト: mozillazg/pypy
 def _type_isinstance(self, w_inst, w_type):
     if not isinstance(w_type, W_TypeObject):
         raise oefmt(self.w_TypeError, "need type object")
     if is_annotation_constant(w_type):
         cls = self._get_interplevel_cls(w_type)
         if cls is not None:
             assert w_inst is not None
             if isinstance(w_inst, cls):
                 return True
     return self.type(w_inst).issubtype(w_type)
コード例 #3
0
ファイル: test_objectmodel.py プロジェクト: mozillazg/pypy
 def f(arg):
     if is_annotation_constant(arg):
         return 1
     return 10
コード例 #4
0
 def f(arg):
     if is_annotation_constant(arg):
         return 1
     return 10
コード例 #5
0
 def newtext(self, s):
     assert isinstance(s, str)
     if is_annotation_constant(s):
         return self._newtext_memo(s)
     return W_BytesObject(s)  # Python3 this is unicode