Пример #1
0
 def test_staticraise(self):
     a = ir.StaticRaise(AssertionError, None, self.loc1)
     b = ir.StaticRaise(AssertionError, None, self.loc1)
     c = ir.StaticRaise(AssertionError, None, self.loc2)
     e = ir.StaticRaise(AssertionError, ("str", ), self.loc1)
     d = ir.StaticRaise(RuntimeError, None, self.loc1)
     self.check(a, same=[b, c], different=[d, e])
 def apply(self):
     """
     Rewrite all matching setitems as static_setitems.
     """
     new_block = self.block.copy()
     new_block.clear()
     for inst in self.block.body:
         if inst in self.raises:
             exc_type, exc_args = self.raises[inst]
             new_inst = ir.StaticRaise(exc_type, exc_args, inst.loc)
             new_block.append(new_inst)
         else:
             new_block.append(inst)
     return new_block