[pypy-svn] r73311 - pypy/branch/cpython-extension/pypy/module/cpyext

xoraxax at codespeak.net xoraxax at codespeak.net
Fri Apr 2 22:36:22 CEST 2010


Author: xoraxax
Date: Fri Apr  2 22:36:20 2010
New Revision: 73311

Modified:
   pypy/branch/cpython-extension/pypy/module/cpyext/pyobject.py
   pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py
Log:
Some translation fixes. Currently translation is blocked by getargs code.

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/pyobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/pyobject.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/pyobject.py	Fri Apr  2 22:36:20 2010
@@ -57,7 +57,7 @@
                 pto = rffi.cast(PyTypeObjectPtr, w_type_pyo)
                 # Don't increase refcount for non-heaptypes
                 if not rffi.cast(lltype.Signed, pto.c_tp_flags) & Py_TPFLAGS_HEAPTYPE:
-                    Py_DecRef(space, pto)
+                    Py_DecRef(space, w_type_pyo)
                 basicsize = pto.c_tp_basicsize
                 py_obj_pad = lltype.malloc(rffi.VOIDP.TO, basicsize,
                         flavor="raw", zero=True)
@@ -132,6 +132,7 @@
 def Py_DecRef(space, obj):
     if not obj:
         return
+    assert lltype.typeOf(obj) == PyObject
 
     from pypy.module.cpyext.typeobject import string_dealloc, W_PyCTypeObject
     obj.c_ob_refcnt -= 1

Modified: pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py	(original)
+++ pypy/branch/cpython-extension/pypy/module/cpyext/typeobject.py	Fri Apr  2 22:36:20 2010
@@ -29,6 +29,7 @@
 from pypy.module.cpyext.slotdefs import slotdefs
 from pypy.interpreter.error import OperationError, operationerrfmt
 from pypy.rlib.rstring import rsplit
+from pypy.rlib.objectmodel import we_are_translated
 
 
 WARN_ABOUT_MISSING_SLOT_FUNCTIONS = False
@@ -108,7 +109,7 @@
             if WARN_ABOUT_MISSING_SLOT_FUNCTIONS:
                 os.write(2, method_name + " defined by the type but no slot function defined!\n")
             continue
-        if method_name == "__new__" and "bar" in repr(w_obj):
+        if not we_are_translated() and method_name == "__new__" and "bar" in repr(w_obj):
             import pdb; pdb.set_trace()
         slot_func_helper = llhelper(slot_func.api_func.functype,
                 slot_func.api_func.get_wrapper(space))
@@ -236,6 +237,7 @@
         finally:
             Py_DecRef(space, pyo)
     else:
+        w_type = _precheck_for_new(space, w_type)
         return call__Type(space, w_type, __args__)
 
 def c_type_descr__new__(space, w_typetype, w_name, w_bases, w_dict):
@@ -290,8 +292,6 @@
 def type_dealloc(space, obj):
     state = space.fromcache(State)
     obj_pto = rffi.cast(PyTypeObjectPtr, obj)
-    if not obj_pto.c_tp_name or "C_type" == rffi.charp2str(obj_pto.c_tp_name):
-        import pdb; pdb.set_trace()
     type_pto = rffi.cast(PyTypeObjectPtr, obj.c_ob_type)
     base_pyo = rffi.cast(PyObject, obj_pto.c_tp_base)
     Py_DecRef(space, obj_pto.c_tp_bases)



More information about the Pypy-commit mailing list