[pypy-commit] pypy default: improve error reporting

fijal noreply at buildbot.pypy.org
Mon May 13 19:56:04 CEST 2013


Author: Maciej Fijalkowski <fijall at gmail.com>
Branch: 
Changeset: r64041:082d3fee772a
Date: 2013-05-13 19:54 +0200
http://bitbucket.org/pypy/pypy/changeset/082d3fee772a/

Log:	improve error reporting

diff --git a/pypy/goal/targetpypystandalone.py b/pypy/goal/targetpypystandalone.py
--- a/pypy/goal/targetpypystandalone.py
+++ b/pypy/goal/targetpypystandalone.py
@@ -79,16 +79,19 @@
     # should be used as sparsely as possible, just to register callbacks
 
     from rpython.rlib.entrypoint import entrypoint
-    from rpython.rtyper.lltypesystem import rffi
+    from rpython.rtyper.lltypesystem import rffi, lltype
 
-    @entrypoint('main', [rffi.CCHARP], c_name='pypy_setup_home')
-    def pypy_setup_home(ll_home):
+    @entrypoint('main', [rffi.CCHARP, lltype.Signed], c_name='pypy_setup_home')
+    def pypy_setup_home(ll_home, verbose):
         from pypy.module.sys.initpath import pypy_find_stdlib
         if ll_home:
             home = rffi.charp2str(ll_home)
         else:
             home = pypydir
-        pypy_find_stdlib(space, home)
+        if space.is_none(pypy_find_stdlib(space, home)):
+            if verbose:
+                debug("Failed to find library based on pypy_find_stdlib")
+            return 1
         space.startup()
         # import site
         try:
@@ -96,7 +99,11 @@
                                     space.wrap('__import__'))
             space.call_function(import_, space.wrap('site'))
             return 0
-        except OperationError:
+        except OperationError, e:
+            if verbose:
+                debug("OperationError:")
+                debug(" operror-type: " + e.w_type.getname(space))
+                debug(" operror-value: " + space.str_w(space.str(e.get_w_value(space))))
             return 1
 
     @entrypoint('main', [rffi.CCHARP], c_name='pypy_execute_source')
diff --git a/pypy/interpreter/test/test_targetpypy.py b/pypy/interpreter/test/test_targetpypy.py
--- a/pypy/interpreter/test/test_targetpypy.py
+++ b/pypy/interpreter/test/test_targetpypy.py
@@ -24,5 +24,5 @@
     # did not crash - the same globals
     pypy_setup_home = d['pypy_setup_home']
     lls = rffi.str2charp(__file__)
-    pypy_setup_home(lls)
+    pypy_setup_home(lls, 1)
     lltype.free(lls, flavor='raw')


More information about the pypy-commit mailing list