Commits

Armin Rigo committed dfd843e

kill a hack that is a few hours old, for a change

Comments (0)

Files changed (4)

pypy/rpython/exceptiondata.py

         self.r_exception_value = r_instance
         self.lltype_of_exception_type  = r_type.lowleveltype
         self.lltype_of_exception_value = r_instance.lowleveltype
+        self.rtyper = rtyper
 
     def make_standard_exceptions(self, rtyper):
         bk = rtyper.annotator.bookkeeper
             classdef = bk.getuniqueclassdef(cls)
             rclass.getclassrepr(rtyper, classdef).setup()
 
-    def make_raise_noarg(self, rtyper):
-        def ll_raise_noarg(classname):
-            if classname == 'OverflowError':
-                raise OverflowError
-            if classname == 'ValueError':
-                raise ValueError
-            if classname == 'ZeroDivisionError':
-                raise ZeroDivisionError
-            if classname == 'MemoryError':
-                raise MemoryError
-            if classname == 'IOError':
-                raise IOError
-            if classname == 'StopIteration':
-                raise StopIteration
-            if classname == 'KeyError':
-                raise KeyError
-            if classname == 'IndexError':
-                raise IndexError
-            raise NotImplementedError   # we did not special-case this so far
-        helper_fn = rtyper.annotate_helper_fn(ll_raise_noarg, [annmodel.SomeString()])
-        return helper_fn
-
     def make_raise_OSError(self, rtyper):
         # ll_raise_OSError(errno)
         def ll_raise_OSError(errno):
         example = r_inst.get_reusable_prebuilt_instance()
         example = self.cast_exception(self.lltype_of_exception_value, example)
         return example
- 
 
+    def get_standard_ll_exc_instance_by_class(self, exceptionclass):
+        clsdef = self.rtyper.annotator.bookkeeper.getuniqueclassdef(
+            exceptionclass)
+        return self.get_standard_ll_exc_instance(self.rtyper, clsdef)

pypy/rpython/llinterp.py

         exdata = typer.getexceptiondata()
         if isinstance(exc, OSError):
             self.op_direct_call(exdata.fn_raise_OSError, exc.errno)
+            assert False, "op_direct_call above should have raised"
         else:
-            exc_class = exc.__class__.__name__
-            llname = typer.type_system.rstr.string_repr.convert_const(exc_class)
-            self.op_direct_call(exdata.fn_raise_noarg, llname)
-        assert False, "op_direct_call above should have raised"
+            evalue = exdata.get_standard_ll_exc_instance_by_class(exc.__class__)
+            etype = self.op_direct_call(exdata.fn_type_of_exc_inst, evalue)
+        raise LLException(etype, evalue, *extraargs)
 
     def invoke_callable_with_pyexceptions(self, fptr, *args):
         obj = self.llinterpreter.typer.type_system.deref(fptr)

pypy/rpython/lltypesystem/exceptiondata.py

         self.fn_exception_match  = self.make_exception_matcher(rtyper)
         self.fn_type_of_exc_inst = self.make_type_of_exc_inst(rtyper)
         self.fn_raise_OSError    = self.make_raise_OSError(rtyper)
-        self.fn_raise_noarg      = self.make_raise_noarg(rtyper)
 
     def make_exception_matcher(self, rtyper):
         # ll_exception_matcher(real_exception_vtable, match_exception_vtable)

pypy/rpython/ootypesystem/exceptiondata.py

         self.fn_exception_match = self.make_exception_matcher(rtyper)
         self.fn_type_of_exc_inst = self.make_type_of_exc_inst(rtyper)
         self.fn_raise_OSError    = self.make_raise_OSError(rtyper)        
-        self.fn_raise_noarg      = self.make_raise_noarg(rtyper)
 
     def make_exception_matcher(self, rtyper):
         # ll_exception_matcher(real_exception_class, match_exception_class)