[pypy-svn] r64838 - pypy/branch/pyjitpl5/pypy/translator/cli

antocuni at codespeak.net antocuni at codespeak.net
Wed Apr 29 20:35:27 CEST 2009


Author: antocuni
Date: Wed Apr 29 20:35:20 2009
New Revision: 64838

Modified:
   pypy/branch/pyjitpl5/pypy/translator/cli/class_.py
   pypy/branch/pyjitpl5/pypy/translator/cli/gencli.py
Log:
use .NET System.Exception as the base class for RPython Exception, and do not
override the default ToString() of exceptions.  This should let us to get nice
traceback when rpython exceptions are not caught



Modified: pypy/branch/pyjitpl5/pypy/translator/cli/class_.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/cli/class_.py	(original)
+++ pypy/branch/pyjitpl5/pypy/translator/cli/class_.py	Wed Apr 29 20:35:20 2009
@@ -42,6 +42,9 @@
 
     def get_base_class(self):
         base_class = self.INSTANCE._superclass
+        if self.INSTANCE is self.db.genoo.EXCEPTION:
+            assert self.is_root(base_class)
+            return '[mscorlib]System.Exception'
         if self.is_root(base_class):
             return '[mscorlib]System.Object'
         else:
@@ -146,6 +149,8 @@
         self.ilasm.end_function()
 
     def _toString(self):
+        if self.get_base_class() == '[mscorlib]System.Exception':
+            return # don't override the default ToString, which prints a traceback
         self.ilasm.begin_function('ToString', [], 'string', False, 'virtual', 'instance', 'default')
         self.ilasm.opcode('ldarg.0')
         self.ilasm.call('string class [pypylib]pypy.test.Result::InstanceToPython(object)')

Modified: pypy/branch/pyjitpl5/pypy/translator/cli/gencli.py
==============================================================================
--- pypy/branch/pyjitpl5/pypy/translator/cli/gencli.py	(original)
+++ pypy/branch/pyjitpl5/pypy/translator/cli/gencli.py	Wed Apr 29 20:35:20 2009
@@ -42,6 +42,11 @@
         self.assembly_name = entrypoint.get_name()
         self.tmpfile = tmpdir.join(self.assembly_name + '.il')
         self.const_stat = str(tmpdir.join('const_stat'))
+        rtyper = translator.rtyper
+        bk = rtyper.annotator.bookkeeper
+        clsdef = bk.getuniqueclassdef(Exception)
+        ll_Exception = rtyper.exceptiondata.get_standard_ll_exc_instance(rtyper, clsdef)
+        self.EXCEPTION = ll_Exception._inst._TYPE
 
     def append_prebuilt_nodes(self):
         for node in get_prebuilt_nodes(self.translator, self.db):



More information about the Pypy-commit mailing list