[pypy-commit] pypy cpyext-gc-support: Some more translation fixes

arigo noreply at buildbot.pypy.org
Fri Oct 23 16:43:47 EDT 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: cpyext-gc-support
Changeset: r80417:ea45d10498f2
Date: 2015-10-23 21:47 +0100
http://bitbucket.org/pypy/pypy/changeset/ea45d10498f2/

Log:	Some more translation fixes

diff --git a/pypy/module/cpyext/__init__.py b/pypy/module/cpyext/__init__.py
--- a/pypy/module/cpyext/__init__.py
+++ b/pypy/module/cpyext/__init__.py
@@ -36,7 +36,7 @@
 import pypy.module.cpyext.object
 import pypy.module.cpyext.stringobject
 import pypy.module.cpyext.tupleobject
-import pypy.module.cpyext.ndarrayobject
+#import pypy.module.cpyext.ndarrayobject ZZZ
 import pypy.module.cpyext.setobject
 import pypy.module.cpyext.dictobject
 import pypy.module.cpyext.intobject
diff --git a/pypy/module/cpyext/api.py b/pypy/module/cpyext/api.py
--- a/pypy/module/cpyext/api.py
+++ b/pypy/module/cpyext/api.py
@@ -388,14 +388,15 @@
 FUNCTIONS = {}
 
 @specialize.memo()
-def constant_pyobj(space, name):
-    # returns the C symbol "Py" + name, constant-folded
+def constant_pytypeobj(space, name):
+    # returns the C symbol given by "name", constant-folded,
+    # of type "PyTypeObject *"
     if space.config.translating:
-        return rffi.CConstant("((PyObject *)&PyPy%s)" % (name,), PyObject)
+        return rffi.CConstant("(&%s)" % (name,), PyTypeObjectPtr)
     else:
         from pypy.module.cpyext.pyobject import as_pyobj
         w_obj = INTERPLEVEL_API[name]
-        return as_pyobj(space, w_obj)
+        return rffi.cast(PyTypeObjectPtr, as_pyobj(space, w_obj))
 
 # These are C symbols which cpyext will export, but which are defined in .c
 # files somewhere in the implementation of cpyext (rather than being defined in
@@ -591,8 +592,7 @@
         def get_w_type(space):
             return getattr(space, cls)
         def _PyXxx_Type(space):
-            return rffi.cast(PyTypeObjectPtr,
-                             constant_pyobj(space, py_type_name))
+            return constant_pytypeobj(space, py_type_name)
     else:
         @specialize.memo()
         def get_w_type(space):
@@ -600,6 +600,7 @@
         def _PyXxx_Type(space):
             from rpython.rlib.debug import fatalerror
             fatalerror(py_type_name + " not implemented ZZZ")
+            assert 0
     _PyXxx_Type = func_with_new_name(_PyXxx_Type, '_' + py_type_name)
 
     def check(space, py_obj):
@@ -1090,7 +1091,7 @@
                                source_dir / "capsule.c",
                                source_dir / "pysignals.c",
                                source_dir / "pythread.c",
-                               source_dir / "ndarrayobject.c",
+                               #source_dir / "ndarrayobject.c", ZZZ
                                source_dir / "missing.c",
                                ],
         separate_module_sources=separate_module_sources,
diff --git a/pypy/module/cpyext/frameobject.py b/pypy/module/cpyext/frameobject.py
--- a/pypy/module/cpyext/frameobject.py
+++ b/pypy/module/cpyext/frameobject.py
@@ -68,6 +68,9 @@
 
 @cpython_api([PyThreadState, PyCodeObject, PyObject, PyObject], PyFrameObject)
 def PyFrame_New(space, tstate, w_code, w_globals, w_locals):
+    from rpython.rlib.debug import fatalerror
+    fatalerror("PyFrame_New not implemented ZZZ")
+    assert 0
     typedescr = get_typedescr(PyFrame.typedef)
     py_obj = typedescr.allocate(space, space.gettypeobject(PyFrame.typedef))
     py_frame = rffi.cast(PyFrameObject, py_obj)
diff --git a/pypy/module/cpyext/pyobject.py b/pypy/module/cpyext/pyobject.py
--- a/pypy/module/cpyext/pyobject.py
+++ b/pypy/module/cpyext/pyobject.py
@@ -61,7 +61,7 @@
                 ob = lltype.malloc(tp_basestruct, flavor='raw',
                                    track_allocation=False)
                 return ob, RRC_PERMANENT_LIGHT
-        tp_alloc_pyobj._always_inline_ = True
+        tp_alloc_pyobj._always_inline_ = 'try'
         #
         if not tp_fill_pyobj:
             def tp_fill_pyobj(space, w_obj, py_obj):
@@ -100,7 +100,7 @@
                     if alloc_pypy_light_if(space, pyobj):
                         strength = RRC_TRANSIENT_LIGHT
                 return w_obj, strength
-        tp_alloc_pypy._always_inline_ = True
+        tp_alloc_pypy._always_inline_ = 'try'
         #
         if not tp_fill_pypy:
             def tp_fill_pypy(space, w_obj, pyobj):
@@ -160,7 +160,7 @@
         rawrefcount.create_link_pyobj(w_obj, ob)
     #
     else:
-        assert False, "rawrefcount_init_link: strength=%r" % (strength,)
+        assert False, "rawrefcount_init_link: strength=%s" % (strength,)
 
 
 def setup_prebuilt_pyobj(w_obj, py_obj):
@@ -317,7 +317,7 @@
     """
     assert not is_pyobj(w_obj)
     return w_obj.cpyext_as_pyobj(space)
-as_pyobj._always_inline_ = True
+as_pyobj._always_inline_ = 'try'
 INTERPLEVEL_API['as_pyobj'] = as_pyobj
 
 def as_xpyobj(space, w_obj):
@@ -341,7 +341,7 @@
     if w_obj is None:
         w_obj = _create_w_obj_from_pyobj(space, pyobj)
     return w_obj
-from_pyobj._always_inline_ = True
+from_pyobj._always_inline_ = 'try'
 INTERPLEVEL_API['from_pyobj'] = from_pyobj
 
 @specialize.ll()
diff --git a/pypy/module/cpyext/unicodeobject.py b/pypy/module/cpyext/unicodeobject.py
--- a/pypy/module/cpyext/unicodeobject.py
+++ b/pypy/module/cpyext/unicodeobject.py
@@ -48,6 +48,9 @@
     interpreter object.  The buffer may be mutated, until unicode_realize() is
     called.
     """
+    from rpython.rlib.debug import fatalerror
+    fatalerror("new_empty_unicode not implemented ZZZ")
+    assert 0
     typedescr = get_typedescr(space.w_unicode.instancetypedef)
     py_obj = typedescr.allocate(space, space.w_unicode)
     py_uni = rffi.cast(PyUnicodeObject, py_obj)


More information about the pypy-commit mailing list