[pypy-commit] pypy numpy-dtype-strings: Add string to FakeSpace to fix failing compile tests

jterrace noreply at buildbot.pypy.org
Mon Dec 12 22:52:54 CET 2011


Author: Jeff Terrace <jterrace at gmail.com>
Branch: numpy-dtype-strings
Changeset: r50449:d0fa1bba8dd6
Date: 2011-12-11 10:17 -0500
http://bitbucket.org/pypy/pypy/changeset/d0fa1bba8dd6/

Log:	Add string to FakeSpace to fix failing compile tests

diff --git a/pypy/module/micronumpy/compile.py b/pypy/module/micronumpy/compile.py
--- a/pypy/module/micronumpy/compile.py
+++ b/pypy/module/micronumpy/compile.py
@@ -48,6 +48,7 @@
     w_long = "long"
     w_tuple = 'tuple'
     w_slice = "slice"
+    w_str = "str"
 
     def __init__(self):
         """NOT_RPYTHON"""
@@ -85,6 +86,8 @@
             return BoolObject(obj)
         elif isinstance(obj, int):
             return IntObject(obj)
+        elif isinstance(obj, str):
+            return StringObject(obj)
         elif isinstance(obj, W_Root):
             return obj
         raise NotImplementedError
@@ -120,6 +123,16 @@
         assert isinstance(w_obj, interp_boxes.W_GenericBox)
         return self.int(w_obj.descr_int(self))
 
+    def str_w(self, w_obj):
+        if isinstance(w_obj, StringObject):
+            return w_obj._value
+        raise NotImplementedError
+    
+    def str(self, w_obj):
+        if isinstance(w_obj, StringObject):
+            return w_obj
+        raise NotImplementedError
+
     def is_true(self, w_obj):
         assert isinstance(w_obj, BoolObject)
         return w_obj.boolval
@@ -169,6 +182,11 @@
     def __init__(self, intval):
         self.intval = intval
 
+class StringObject(W_Root):
+    tp = FakeSpace.w_str
+    def __init__(self, s):
+        self._value = s
+
 class ListObject(W_Root):
     tp = FakeSpace.w_list
     def __init__(self, items):


More information about the pypy-commit mailing list