[pypy-commit] pypy cpyext-gc-support: translation in-progress

arigo noreply at buildbot.pypy.org
Fri Oct 23 13:12:14 EDT 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: cpyext-gc-support
Changeset: r80415:346702273784
Date: 2015-10-23 18:15 +0100
http://bitbucket.org/pypy/pypy/changeset/346702273784/

Log:	translation in-progress

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
@@ -597,8 +597,9 @@
         @specialize.memo()
         def get_w_type(space):
             return space.gettypeobject(cls.typedef)
-        def _PyXxx_Type():
-            ZZZ
+        def _PyXxx_Type(space):
+            from rpython.rlib.debug import fatalerror
+            fatalerror(py_type_name + " not implemented ZZZ")
     _PyXxx_Type = func_with_new_name(_PyXxx_Type, '_' + py_type_name)
 
     def check(space, py_obj):
@@ -701,6 +702,7 @@
                             retval = as_pyobj(space, result)
                         else:
                             retval = get_pyobj_and_incref(space, result)
+                        retval = rffi.cast(callable.api_func.restype, retval)
                     else:
                         retval = lltype.nullptr(PyObject.TO)
             elif callable.api_func.restype is not lltype.Void:
@@ -719,6 +721,7 @@
             else:
                 print str(e)
                 pypy_debug_catch_fatal_exception()
+                assert False
         rffi.stackcounter.stacks_counter -= 1
         if gil_release:
             before = rffi.aroundstate.before
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
@@ -21,8 +21,9 @@
 
 def make_typedescr(arg0, *args, **kwds):
     print "ZZZ: make_typedescr(%r)" % (arg0,)
-def get_typedescr(*args, **kwds):
-    ZZZ
+def get_typedescr(*args):
+    from rpython.rlib.debug import fatalerror
+    fatalerror("get_typedescr not fully removed ZZZ")
 
 RRC_PERMANENT       = 'P'  # the link pyobj<->pypy is permanent
 RRC_PERMANENT_LIGHT = 'p'  # same, but tp_dealloc can be replaced with free()
@@ -472,11 +473,7 @@
 
 @cpython_api([PyObject], lltype.Void)
 def _Py_NewReference(space, obj):
-    ZZZ
     obj.c_ob_refcnt = 1
-    w_type = from_ref(space, rffi.cast(PyObject, obj.c_ob_type))
-    assert isinstance(w_type, W_TypeObject)
-    get_typedescr(w_type.instancetypedef).realize(space, obj)
 
 @cpython_api([PyObject], lltype.Void)
 def _Py_Dealloc(space, obj):
diff --git a/pypy/module/cpyext/state.py b/pypy/module/cpyext/state.py
--- a/pypy/module/cpyext/state.py
+++ b/pypy/module/cpyext/state.py
@@ -148,7 +148,7 @@
         from pypy.module.cpyext.pyobject import PyObject, _Py_Dealloc
 
         while True:
-            py_obj = rawrefcount.next_dead(PyObject.TO)
+            py_obj = rawrefcount.next_dead(PyObject)
             if not py_obj:
                 break
             _Py_Dealloc(self.space, py_obj)
diff --git a/pypy/module/cpyext/tupleobject.py b/pypy/module/cpyext/tupleobject.py
--- a/pypy/module/cpyext/tupleobject.py
+++ b/pypy/module/cpyext/tupleobject.py
@@ -87,7 +87,7 @@
         PyErr_BadInternalCall(space)
     py_tuple = rffi.cast(PyTupleObject, py_t)
     if pos < 0 or pos >= py_tuple.c_ob_size:
-        raise oefmt(w_IndexError, "tuple assignment index out of range")
+        raise oefmt(space.w_IndexError, "tuple assignment index out of range")
 
     olditem = py_tuple.c_ob_item[pos]
     py_tuple.c_ob_item[pos] = py_obj
@@ -102,7 +102,7 @@
         PyErr_BadInternalCall(space)
     py_tuple = rffi.cast(PyTupleObject, py_t)
     if pos < 0 or pos >= py_tuple.c_ob_size:
-        raise oefmt(w_IndexError, "tuple assignment index out of range")
+        raise oefmt(space.w_IndexError, "tuple assignment index out of range")
 
     return py_tuple.c_ob_item[pos]     # borrowed
 
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -20,7 +20,7 @@
     PyDescr_NewWrapper, PyCFunction_NewEx, PyCFunction_typedef)
 from pypy.module.cpyext.modsupport import convert_method_defs
 from pypy.module.cpyext.pyobject import (
-    PyObject, create_ref, get_typedescr, from_pyobj, as_pyobj,
+    PyObject, create_ref, get_typedescr, from_pyobj, as_pyobj, as_xpyobj,
     setup_class_for_cpyext, get_pyobj_and_incref, get_pyobj_and_xincref,
     track_reference, Py_DecRef, RRC_PERMANENT)
 from pypy.module.cpyext.slotdefs import (
@@ -592,8 +592,8 @@
 def PyType_IsSubtype(space, a, b):
     """Return true if a is a subtype of b.
     """
-    w_type1 = from_ref(space, rffi.cast(PyObject, a))
-    w_type2 = from_ref(space, rffi.cast(PyObject, b))
+    w_type1 = from_pyobj(space, a)
+    w_type2 = from_pyobj(space, b)
     return int(abstract_issubclass_w(space, w_type1, w_type2)) #XXX correct?
 
 @cpython_api([PyTypeObjectPtr, Py_ssize_t], PyObject)
@@ -610,16 +610,14 @@
 def _PyType_Lookup(space, type, w_name):
     """Internal API to look for a name through the MRO.
     This returns a borrowed reference, and doesn't set an exception!"""
-    w_type = from_ref(space, rffi.cast(PyObject, type))
+    w_type = from_pyobj(space, type)
     assert isinstance(w_type, W_TypeObject)
 
-    if not space.isinstance_w(w_name, space.w_str):
-        return None
     name = space.str_w(w_name)
     w_obj = w_type.lookup(name)
     # return a borrowed ref.  assumes lookup() returns already-referenced
     # objs OR that the result will not be used for long
-    return as_pyobj(space, w_obj)
+    return as_xpyobj(space, w_obj)
 
 @cpython_api([PyTypeObjectPtr], lltype.Void)
 def PyType_Modified(space, w_obj):
diff --git a/pypy/module/cpyext/weakrefobject.py b/pypy/module/cpyext/weakrefobject.py
--- a/pypy/module/cpyext/weakrefobject.py
+++ b/pypy/module/cpyext/weakrefobject.py
@@ -42,7 +42,7 @@
     """Similar to PyWeakref_GetObject(), but implemented as a macro that does no
     error checking.
     """
-    return as_xpyobj(space.call_function(w_ref))   # borrowed
+    return as_xpyobj(space, space.call_function(w_ref))   # borrowed
 
 @cpython_api([PyObject], PyObject)
 def PyWeakref_LockObject(space, w_ref):


More information about the pypy-commit mailing list