Beispiel #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)
Beispiel #2
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)
Beispiel #3
0
 def f(arg):
     if is_annotation_constant(arg):
         return 1
     return 10
Beispiel #4
0
 def f(arg):
     if is_annotation_constant(arg):
         return 1
     return 10
Beispiel #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