[pypy-svn] r15061 - in pypy/dist/pypy/rpython: . module test

cfbolz at codespeak.net cfbolz at codespeak.net
Mon Jul 25 19:10:24 CEST 2005


Author: cfbolz
Date: Mon Jul 25 19:10:23 2005
New Revision: 15061

Modified:
   pypy/dist/pypy/rpython/extfunctable.py
   pypy/dist/pypy/rpython/llinterp.py
   pypy/dist/pypy/rpython/module/ll_os.py
   pypy/dist/pypy/rpython/test/test_llinterp.py
   pypy/dist/pypy/rpython/test/test_rbuiltin.py
Log:
(pedronis, cfbolz):
intermediate checkin to be able to continue working on a different machine.


Modified: pypy/dist/pypy/rpython/extfunctable.py
==============================================================================
--- pypy/dist/pypy/rpython/extfunctable.py	(original)
+++ pypy/dist/pypy/rpython/extfunctable.py	Mon Jul 25 19:10:23 2005
@@ -78,6 +78,7 @@
 declare(os.ftruncate, noneannotation, 'll_os/ftruncate')
 declare(os.fstat    , statannotation, 'll_os/fstat')
 declare(os.stat     , statannotation, 'll_os/stat')
+declare(os.path.exists, bool        , 'll_os_path/exists')
 declare(time.time   , float         , 'll_time/time')
 declare(time.clock  , float         , 'll_time/clock')
 declare(time.sleep  , noneannotation, 'll_time/sleep')

Modified: pypy/dist/pypy/rpython/llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/llinterp.py	(original)
+++ pypy/dist/pypy/rpython/llinterp.py	Mon Jul 25 19:10:23 2005
@@ -161,6 +161,13 @@
         etype = exdata.ll_type_of_exc_inst(evalue)
         raise LLException(etype, evalue)
 
+    def invoke_callable_with_pyexceptions(self, fptr, *args):
+        print "invoking %s(%s)" % (fptr, args)
+        try:
+            return fptr._obj._callable(*args)
+        except Exception, e:
+            self.make_llexception(e.__class__)
+
     # __________________________________________________________
     # misc LL operation implementations
 
@@ -180,7 +187,7 @@
     def op_direct_call(self, f, *args):
         has_callable = getattr(f._obj, '_callable', None) is not None
         if has_callable and getattr(f._obj._callable, 'suggested_primitive', False):
-            return f._obj._callable(*args)
+                self.invoke_callable_with_pyexceptions(f, *args)
         if hasattr(f._obj, 'graph'):
             graph = f._obj.graph
         else:
@@ -188,7 +195,7 @@
                 graph = self.llinterpreter.getgraph(f._obj._callable)
             except KeyError:
                 assert has_callable, "don't know how to execute %r" % f
-                return f._obj._callable(*args)
+                return self.invoke_callable_with_pyexceptions(f, *args)
         frame = self.__class__(graph, args, self.llinterpreter)
         return frame.eval()
 

Modified: pypy/dist/pypy/rpython/module/ll_os.py
==============================================================================
--- pypy/dist/pypy/rpython/module/ll_os.py	(original)
+++ pypy/dist/pypy/rpython/module/ll_os.py	Mon Jul 25 19:10:23 2005
@@ -16,8 +16,6 @@
 import os, errno
 from pypy.rpython.rstr import STR
 from pypy.rpython.lltype import GcStruct, Signed, Array, Char, Ptr, malloc
-
-
 from pypy.rpython.module.support import to_rstr, from_rstr, ll_strcpy
 
 

Modified: pypy/dist/pypy/rpython/test/test_llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_llinterp.py	(original)
+++ pypy/dist/pypy/rpython/test/test_llinterp.py	Mon Jul 25 19:10:23 2005
@@ -6,6 +6,7 @@
 from pypy.translator.translator import Translator
 from pypy.rpython.rlist import *
 from pypy.rpython.rint import signed_repr
+from pypy.rpython import rstr
 from pypy.annotation.model import lltype_to_annotation
 
 # switch on logging of interp to show more info on failing tests
@@ -61,6 +62,8 @@
             T = typeOf(x)
             if T == Ptr(PyObject) and someobjects:
                 return object
+            elif T == Ptr(rstr.STR):
+                return str
             else:
                 return lltype_to_annotation(T)
         

Modified: pypy/dist/pypy/rpython/test/test_rbuiltin.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rbuiltin.py	(original)
+++ pypy/dist/pypy/rpython/test/test_rbuiltin.py	Mon Jul 25 19:10:23 2005
@@ -6,6 +6,7 @@
 from pypy.tool import udir
 
 from pypy.annotation.builtin import *
+from pypy.rpython.module.support import to_rstr
 import py
 
 def test_rbuiltin_list():
@@ -118,7 +119,17 @@
         assert cfptr.value._obj._callable == ll_os.ll_os_open
         count += 1
     assert count == 1
-        
+
+def test_os_path_exists():
+    import os
+    def f(fn):
+        return os.path.exists(fn)
+    filename = to_rstr(str(py.magic.autopath()))
+    assert interpret(f, [filename]) == True
+    assert interpret(f, [
+        to_rstr("strange_filename_that_looks_improbable.sde")]) == False
+
+
 def test_pbc_isTrue():
     class C:
         def f(self):
@@ -191,3 +202,4 @@
     assert res is True
     res = interpret(f, [1])
     assert res is False    
+



More information about the Pypy-commit mailing list