[pypy-svn] r79791 - in pypy/branch/fast-forward: . lib-python/modified-2.5.2/test lib_pypy/_ctypes pypy pypy/annotation pypy/annotation/test pypy/doc/config pypy/jit/backend/x86/test pypy/jit/metainterp/optimizeopt pypy/module/array/benchmark pypy/module/array/test pypy/module/cpyext pypy/module/cpyext/include pypy/module/cpyext/test pypy/rlib pypy/rlib/test pypy/rpython pypy/rpython/lltypesystem pypy/rpython/memory/gc pypy/rpython/memory/gc/test pypy/rpython/memory/gctransform pypy/rpython/ootypesystem pypy/rpython/tool pypy/tool

afa at codespeak.net afa at codespeak.net
Fri Dec 3 19:09:13 CET 2010


Author: afa
Date: Fri Dec  3 19:09:09 2010
New Revision: 79791

Added:
   pypy/branch/fast-forward/lib-python/modified-2.5.2/test/seq_tests.py
      - copied unchanged from r79790, pypy/trunk/lib-python/modified-2.5.2/test/seq_tests.py
Modified:
   pypy/branch/fast-forward/   (props changed)
   pypy/branch/fast-forward/lib_pypy/_ctypes/array.py
   pypy/branch/fast-forward/lib_pypy/_ctypes/basics.py
   pypy/branch/fast-forward/lib_pypy/_ctypes/pointer.py
   pypy/branch/fast-forward/lib_pypy/_ctypes/primitive.py
   pypy/branch/fast-forward/pypy/   (props changed)
   pypy/branch/fast-forward/pypy/annotation/annrpython.py
   pypy/branch/fast-forward/pypy/annotation/binaryop.py
   pypy/branch/fast-forward/pypy/annotation/bookkeeper.py
   pypy/branch/fast-forward/pypy/annotation/description.py
   pypy/branch/fast-forward/pypy/annotation/model.py
   pypy/branch/fast-forward/pypy/annotation/specialize.py
   pypy/branch/fast-forward/pypy/annotation/test/test_annrpython.py
   pypy/branch/fast-forward/pypy/doc/config/objspace.usemodules.array.txt   (props changed)
   pypy/branch/fast-forward/pypy/jit/backend/x86/test/test_runner.py
   pypy/branch/fast-forward/pypy/jit/metainterp/optimizeopt/optimizer.py   (props changed)
   pypy/branch/fast-forward/pypy/module/array/benchmark/Makefile   (props changed)
   pypy/branch/fast-forward/pypy/module/array/benchmark/intimg.c   (props changed)
   pypy/branch/fast-forward/pypy/module/array/benchmark/intimgtst.c   (props changed)
   pypy/branch/fast-forward/pypy/module/array/benchmark/intimgtst.py   (props changed)
   pypy/branch/fast-forward/pypy/module/array/benchmark/loop.c   (props changed)
   pypy/branch/fast-forward/pypy/module/array/benchmark/sum.c   (props changed)
   pypy/branch/fast-forward/pypy/module/array/benchmark/sumtst.c   (props changed)
   pypy/branch/fast-forward/pypy/module/array/benchmark/sumtst.py   (props changed)
   pypy/branch/fast-forward/pypy/module/array/test/test_array_old.py   (props changed)
   pypy/branch/fast-forward/pypy/module/cpyext/api.py
   pypy/branch/fast-forward/pypy/module/cpyext/include/tupleobject.h
   pypy/branch/fast-forward/pypy/module/cpyext/slotdefs.py
   pypy/branch/fast-forward/pypy/module/cpyext/test/test_cpyext.py
   pypy/branch/fast-forward/pypy/module/cpyext/test/test_tupleobject.py
   pypy/branch/fast-forward/pypy/module/cpyext/tupleobject.py
   pypy/branch/fast-forward/pypy/rlib/rerased.py   (contents, props changed)
   pypy/branch/fast-forward/pypy/rlib/test/test_rerased.py   (props changed)
   pypy/branch/fast-forward/pypy/rpython/lltypesystem/rbuiltin.py
   pypy/branch/fast-forward/pypy/rpython/lltypesystem/rclass.py
   pypy/branch/fast-forward/pypy/rpython/lltypesystem/rdict.py
   pypy/branch/fast-forward/pypy/rpython/lltypesystem/rpbc.py
   pypy/branch/fast-forward/pypy/rpython/memory/gc/minimark.py
   pypy/branch/fast-forward/pypy/rpython/memory/gc/test/test_direct.py
   pypy/branch/fast-forward/pypy/rpython/memory/gctransform/boehm.py
   pypy/branch/fast-forward/pypy/rpython/memory/gctransform/framework.py
   pypy/branch/fast-forward/pypy/rpython/memory/gctransform/refcounting.py
   pypy/branch/fast-forward/pypy/rpython/memory/gctransform/support.py
   pypy/branch/fast-forward/pypy/rpython/ootypesystem/rpbc.py
   pypy/branch/fast-forward/pypy/rpython/rpbc.py
   pypy/branch/fast-forward/pypy/rpython/tool/rffi_platform.py
   pypy/branch/fast-forward/pypy/tool/error.py
Log:
Merge from trunk: -r79741:79790


Modified: pypy/branch/fast-forward/lib_pypy/_ctypes/array.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/_ctypes/array.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/_ctypes/array.py	Fri Dec  3 19:09:09 2010
@@ -150,12 +150,9 @@
     __metaclass__ = ArrayMeta
     _ffiargshape = 'P'
 
-    def __new__(cls, *args):
-        self = _CData.__new__(cls, *args)
-        self._buffer = self._ffiarray(self._length_, autofree=True)
-        return self
-
     def __init__(self, *args):
+        if not hasattr(self, '_buffer'):
+            self._buffer = self._ffiarray(self._length_, autofree=True)
         for i, arg in enumerate(args):
             self[i] = arg
 

Modified: pypy/branch/fast-forward/lib_pypy/_ctypes/basics.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/_ctypes/basics.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/_ctypes/basics.py	Fri Dec  3 19:09:09 2010
@@ -86,11 +86,14 @@
         self._buffer = None
 
     def __repr__(self):
-        return repr(self._obj)
+        return '<CArgObject %r>' % (self._obj,)
 
     def __eq__(self, other):
         return self._obj == other
 
+    def __ne__(self, other):
+        return self._obj != other
+
 class _CData(object):
     """ The most basic object for all ctypes types
     """

Modified: pypy/branch/fast-forward/lib_pypy/_ctypes/pointer.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/_ctypes/pointer.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/_ctypes/pointer.py	Fri Dec  3 19:09:09 2010
@@ -59,7 +59,8 @@
     def set_type(self, TP):
         ffiarray = _rawffi.Array('P')
         def __init__(self, value=None):
-            self._buffer = ffiarray(1, autofree=True)
+            if not hasattr(self, '_buffer'):
+                self._buffer = ffiarray(1, autofree=True)
             if value is not None:
                 self.contents = value
         self._ffiarray = ffiarray

Modified: pypy/branch/fast-forward/lib_pypy/_ctypes/primitive.py
==============================================================================
--- pypy/branch/fast-forward/lib_pypy/_ctypes/primitive.py	(original)
+++ pypy/branch/fast-forward/lib_pypy/_ctypes/primitive.py	Fri Dec  3 19:09:09 2010
@@ -288,12 +288,9 @@
     __metaclass__ = SimpleType
     _type_ = 'i'
 
-    def __new__(cls, *args, **kwds):
-        self = _CData.__new__(cls, *args, **kwds)
-        self._buffer = self._ffiarray(1, autofree=True)
-        return self
-
     def __init__(self, value=DEFAULT_VALUE):
+        if not hasattr(self, '_buffer'):
+            self._buffer = self._ffiarray(1, autofree=True)
         if value is not DEFAULT_VALUE:
             self.value = value
 

Modified: pypy/branch/fast-forward/pypy/annotation/annrpython.py
==============================================================================
--- pypy/branch/fast-forward/pypy/annotation/annrpython.py	(original)
+++ pypy/branch/fast-forward/pypy/annotation/annrpython.py	Fri Dec  3 19:09:09 2010
@@ -145,7 +145,7 @@
         classdef.add_source_for_attribute(attr, classdef.classdesc)
         self.bookkeeper
         assert isinstance(s_result, annmodel.SomePBC)
-        olddesc = s_result.descriptions.iterkeys().next()
+        olddesc = s_result.any_description()
         desc = olddesc.bind_self(classdef)
         args = self.bookkeeper.build_args("simple_call", args_s[:])
         desc.consider_call_site(self.bookkeeper, desc.getcallfamily(), [desc],

Modified: pypy/branch/fast-forward/pypy/annotation/binaryop.py
==============================================================================
--- pypy/branch/fast-forward/pypy/annotation/binaryop.py	(original)
+++ pypy/branch/fast-forward/pypy/annotation/binaryop.py	Fri Dec  3 19:09:09 2010
@@ -867,7 +867,7 @@
     def getitem((p, obj)):
         assert False,"ptr %r getitem index not an int: %r" % (p.ll_ptrtype, obj)
 
-    def setitem((p, obj)):
+    def setitem((p, obj), s_value):
         assert False,"ptr %r setitem index not an int: %r" % (p.ll_ptrtype, obj)
 
 class __extend__(pairtype(SomeObject, SomePtr)):

Modified: pypy/branch/fast-forward/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/branch/fast-forward/pypy/annotation/bookkeeper.py	(original)
+++ pypy/branch/fast-forward/pypy/annotation/bookkeeper.py	Fri Dec  3 19:09:09 2010
@@ -262,7 +262,7 @@
                                             args_s, s_result)
 
     def consider_call_site_for_pbc(self, s_callable, opname, args_s, s_result):
-        descs = s_callable.descriptions.keys()
+        descs = list(s_callable.descriptions)
         if not descs:
             return
         family = descs[0].getcallfamily()
@@ -590,7 +590,7 @@
         assert s_attr.is_constant()
         attr = s_attr.const
 
-        descs = pbc.descriptions.keys()
+        descs = list(pbc.descriptions)
         if not descs:
             return s_ImpossibleValue
 
@@ -633,7 +633,7 @@
         """Analyse a call to a SomePBC() with the given args (list of
         annotations).
         """
-        descs = pbc.descriptions.keys()
+        descs = list(pbc.descriptions)
         if not descs:
             return s_ImpossibleValue
         first = descs[0]

Modified: pypy/branch/fast-forward/pypy/annotation/description.py
==============================================================================
--- pypy/branch/fast-forward/pypy/annotation/description.py	(original)
+++ pypy/branch/fast-forward/pypy/annotation/description.py	Fri Dec  3 19:09:09 2010
@@ -672,7 +672,7 @@
             if isinstance(s_init, SomePBC):
                 assert len(s_init.descriptions) == 1, (
                     "unexpected dynamic __init__?")
-                initfuncdesc = s_init.descriptions.keys()[0]
+                initfuncdesc, = s_init.descriptions
                 if isinstance(initfuncdesc, FunctionDesc):
                     initmethdesc = bookkeeper.getmethoddesc(initfuncdesc,
                                                             classdef,
@@ -800,8 +800,8 @@
                                                         desc.selfclassdef,
                                                         desc.name,
                                                         commonflags)
-                del descs[desc]
-                descs[newdesc] = None
+                descs.remove(desc)
+                descs.add(newdesc)
 
         # --- case 1 ---
         groups = {}
@@ -816,7 +816,7 @@
                     for desc2 in group:
                         cdef2 = desc2.selfclassdef
                         if cdef1 is not cdef2 and cdef1.issubclass(cdef2):
-                            del descs[desc1]
+                            descs.remove(desc1)
                             break
     simplify_desc_set = staticmethod(simplify_desc_set)
 

Modified: pypy/branch/fast-forward/pypy/annotation/model.py
==============================================================================
--- pypy/branch/fast-forward/pypy/annotation/model.py	(original)
+++ pypy/branch/fast-forward/pypy/annotation/model.py	Fri Dec  3 19:09:09 2010
@@ -366,8 +366,8 @@
     immutable = True
 
     def __init__(self, descriptions, can_be_None=False, subset_of=None):
-        # descriptions is a set of Desc instances.
-        descriptions = dict.fromkeys(descriptions)
+        # descriptions is a set of Desc instances
+        descriptions = set(descriptions)
         self.descriptions = descriptions
         self.can_be_None = can_be_None
         self.subset_of = subset_of
@@ -389,6 +389,9 @@
                 if desc.pyobj is not None:
                     self.const = desc.pyobj
 
+    def any_description(self):
+        return iter(self.descriptions).next()
+
     def getKind(self):
         "Return the common Desc class of all descriptions in this PBC."
         kinds = {}

Modified: pypy/branch/fast-forward/pypy/annotation/specialize.py
==============================================================================
--- pypy/branch/fast-forward/pypy/annotation/specialize.py	(original)
+++ pypy/branch/fast-forward/pypy/annotation/specialize.py	Fri Dec  3 19:09:09 2010
@@ -345,7 +345,8 @@
             key.append(s.const)
         elif isinstance(s, SomePBC) and len(s.descriptions) == 1:
             # for test_specialize_arg_bound_method
-            key.append(s.descriptions.keys()[0])
+            desc, = s.descriptions
+            key.append(desc)
         else:
             raise Exception("specialize:arg(%d): argument not constant: %r"
                             % (i, s))

Modified: pypy/branch/fast-forward/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/branch/fast-forward/pypy/annotation/test/test_annrpython.py	(original)
+++ pypy/branch/fast-forward/pypy/annotation/test/test_annrpython.py	Fri Dec  3 19:09:09 2010
@@ -1010,7 +1010,7 @@
         bookkeeper = a.bookkeeper
 
         def getmdesc(bmeth):
-            return bookkeeper.immutablevalue(bmeth).descriptions.keys()[0]
+            return bookkeeper.immutablevalue(bmeth).any_description()
 
         mdescA_m = getmdesc(A().m)
         mdescC_m = getmdesc(C().m)
@@ -2862,7 +2862,7 @@
         assert s.items[0].flags == {'access_directly': True}
         assert isinstance(s.items[1], annmodel.SomePBC)
         assert len(s.items[1].descriptions) == 1
-        assert s.items[1].descriptions.keys()[0].flags == {'access_directly':
+        assert s.items[1].any_description().flags == {'access_directly':
                                                            True}
         assert isinstance(s.items[2], annmodel.SomeInstance)
         assert s.items[2].flags == {'access_directly': True}

Modified: pypy/branch/fast-forward/pypy/jit/backend/x86/test/test_runner.py
==============================================================================
--- pypy/branch/fast-forward/pypy/jit/backend/x86/test/test_runner.py	(original)
+++ pypy/branch/fast-forward/pypy/jit/backend/x86/test/test_runner.py	Fri Dec  3 19:09:09 2010
@@ -82,7 +82,7 @@
         # relative addressing to work properly.
         addr = rffi.cast(lltype.Signed, addr)
         
-        self.cpu.assembler.setup()
+        self.cpu.assembler.setup_once()
         self.cpu.assembler.malloc_func_addr = addr
         ofs = symbolic.get_field_token(rstr.STR, 'chars', False)[0]
 

Modified: pypy/branch/fast-forward/pypy/module/cpyext/api.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/cpyext/api.py	(original)
+++ pypy/branch/fast-forward/pypy/module/cpyext/api.py	Fri Dec  3 19:09:09 2010
@@ -374,7 +374,7 @@
         }.items():
         GLOBALS['Py%s_Type#' % (cpyname, )] = ('PyTypeObject*', pypyexpr)
 
-    for cpyname in 'Method List Int Long Dict Class'.split():
+    for cpyname in 'Method List Int Long Dict Tuple Class'.split():
         FORWARD_DECLS.append('typedef struct { PyObject_HEAD } '
                              'Py%sObject' % (cpyname, ))
 build_exported_objects()

Modified: pypy/branch/fast-forward/pypy/module/cpyext/include/tupleobject.h
==============================================================================
--- pypy/branch/fast-forward/pypy/module/cpyext/include/tupleobject.h	(original)
+++ pypy/branch/fast-forward/pypy/module/cpyext/include/tupleobject.h	Fri Dec  3 19:09:09 2010
@@ -10,19 +10,9 @@
 /* defined in varargswrapper.c */
 PyObject * PyTuple_Pack(Py_ssize_t, ...);
 
-typedef struct {
-    PyObject_HEAD
-    PyObject **items;
-    Py_ssize_t size;
-} PyTupleObject;
+#define PyTuple_SET_ITEM PyTuple_SetItem
+#define PyTuple_GET_ITEM PyTuple_GetItem
 
-#define PyTuple_GET_ITEM        PyTuple_GetItem
-
-/* Macro, trading safety for speed */
-#define PyTuple_GET_SIZE(op)    (((PyTupleObject *)(op))->size)
-
-/* Macro, *only* to be used to fill in brand new tuples */
-#define PyTuple_SET_ITEM(op, i, v) (((PyTupleObject *)(op))->items[i] = v)
 
 #ifdef __cplusplus
 }

Modified: pypy/branch/fast-forward/pypy/module/cpyext/slotdefs.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/cpyext/slotdefs.py	(original)
+++ pypy/branch/fast-forward/pypy/module/cpyext/slotdefs.py	Fri Dec  3 19:09:09 2010
@@ -28,14 +28,14 @@
 
 def check_num_args(space, ob, n):
     from pypy.module.cpyext.tupleobject import PyTuple_CheckExact, \
-            _PyTuple_Size_Fast
+            PyTuple_GET_SIZE
     if not PyTuple_CheckExact(space, ob):
         raise OperationError(space.w_SystemError,
             space.wrap("PyArg_UnpackTuple() argument list is not a tuple"))
-    if n == _PyTuple_Size_Fast(space, ob):
+    if n == PyTuple_GET_SIZE(space, ob):
         return
     raise operationerrfmt(space.w_TypeError,
-        "expected %d arguments, got %d", n, _PyTuple_Size_Fast(space, ob))
+        "expected %d arguments, got %d", n, PyTuple_GET_SIZE(space, ob))
 
 def wrap_init(space, w_self, w_args, func, w_kwargs):
     func_init = rffi.cast(initproc, func)

Modified: pypy/branch/fast-forward/pypy/module/cpyext/test/test_cpyext.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/cpyext/test/test_cpyext.py	(original)
+++ pypy/branch/fast-forward/pypy/module/cpyext/test/test_cpyext.py	Fri Dec  3 19:09:09 2010
@@ -554,17 +554,16 @@
             PyObject *true = Py_True;
             PyObject *tup = NULL;
             int refcnt = true->ob_refcnt;
-            int refcnt_middle, refcnt_after;
+            int refcnt_after;
 
             tup = PyTuple_New(1);
             Py_INCREF(true);
             if (PyTuple_SetItem(tup, 0, true) < 0)
                 return NULL;
-            refcnt_middle = true->ob_refcnt;
-            Py_DECREF(tup);
             refcnt_after = true->ob_refcnt;
-            fprintf(stderr, "REFCNT2 %i %i %i\\n", refcnt, refcnt_middle, refcnt_after);
-            return PyBool_FromLong(refcnt_after == refcnt && refcnt_middle == refcnt+1);
+            Py_DECREF(tup);
+            fprintf(stderr, "REFCNT2 %i %i\\n", refcnt, refcnt_after);
+            return PyBool_FromLong(refcnt_after == refcnt);
         }
 
         static PyMethodDef methods[] = {

Modified: pypy/branch/fast-forward/pypy/module/cpyext/test/test_tupleobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/cpyext/test/test_tupleobject.py	(original)
+++ pypy/branch/fast-forward/pypy/module/cpyext/test/test_tupleobject.py	Fri Dec  3 19:09:09 2010
@@ -7,34 +7,24 @@
 class TestTupleObject(BaseApiTest):
     def test_tupleobject(self, space, api):
         assert not api.PyTuple_Check(space.w_None)
-        #assert api.PyTuple_SetItem(space.w_None, 0, space.w_None) == -1     XXX
+        assert api.PyTuple_SetItem(space.w_None, 0, space.w_None) == -1
         atuple = space.newtuple([0, 1, 'yay'])
         assert api.PyTuple_Size(atuple) == 3
-        #raises(TypeError, api.PyTuple_Size(space.newlist([])))     XXX
+        assert api.PyTuple_GET_SIZE(atuple) == 3
+        raises(TypeError, api.PyTuple_Size(space.newlist([])))
         api.PyErr_Clear()
     
     def test_tuple_resize(self, space, api):
-        ref_tup = api.PyTuple_New(3)
+        py_tuple = api.PyTuple_New(3)
         ar = lltype.malloc(PyObjectP.TO, 1, flavor='raw')
-        ar[0] = rffi.cast(PyObject, ref_tup)
+        ar[0] = rffi.cast(PyObject, make_ref(space, py_tuple))
         api._PyTuple_Resize(ar, 2)
-        assert ar[0] == rffi.cast(PyObject, ref_tup)
-        # ^^^ our _PyTuple_Resize does not actually need to change the ptr so far
-        assert api.PyTuple_Size(ar[0]) == 2
+        py_tuple = from_ref(space, ar[0])
+        assert len(py_tuple.wrappeditems) == 2
         
         api._PyTuple_Resize(ar, 10)
-        assert api.PyTuple_Size(ar[0]) == 10
+        py_tuple = from_ref(space, ar[0])
+        assert len(py_tuple.wrappeditems) == 10
         
         api.Py_DecRef(ar[0])
         lltype.free(ar, flavor='raw')
-
-    def test_tuple_setup(self, space, api):
-        ref_tup = api.PyTuple_New(2)
-        ref0 = make_ref(space, space.wrap(123))
-        api.PyTuple_SetItem(ref_tup, 0, ref0)
-        ref1 = make_ref(space, space.wrap(456))
-        api.PyTuple_SetItem(ref_tup, 1, ref1)
-
-        w_tup = from_ref(space, ref_tup)
-        assert space.is_true(space.eq(w_tup, space.wrap((123, 456))))
-        api.Py_DecRef(ref_tup)

Modified: pypy/branch/fast-forward/pypy/module/cpyext/tupleobject.py
==============================================================================
--- pypy/branch/fast-forward/pypy/module/cpyext/tupleobject.py	(original)
+++ pypy/branch/fast-forward/pypy/module/cpyext/tupleobject.py	Fri Dec  3 19:09:09 2010
@@ -1,144 +1,55 @@
 from pypy.interpreter.error import OperationError
 from pypy.rpython.lltypesystem import rffi, lltype
 from pypy.module.cpyext.api import (cpython_api, Py_ssize_t, CANNOT_FAIL,
-                                    build_type_checkers, PyObjectFields,
-                                    cpython_struct, bootstrap_function)
+                                    build_type_checkers)
 from pypy.module.cpyext.pyobject import (PyObject, PyObjectP, Py_DecRef,
-    borrow_from, make_ref, from_ref, make_typedescr, get_typedescr, Reference,
-    track_reference)
+    borrow_from, make_ref, from_ref)
 from pypy.module.cpyext.pyerrors import PyErr_BadInternalCall
+from pypy.objspace.std.tupleobject import W_TupleObject
 
-##
-## Implementation of PyTupleObject
-## ===============================
-##
-## We have the same problem as PyStringObject: a PyTupleObject can be
-## initially used in a read-write way with PyTuple_New(), PyTuple_SetItem()
-## and _PyTuple_Resize().
-##
-## The 'size' and 'items' fields of a PyTupleObject are always valid.
-## Apart from that detail, see the big comment in stringobject.py for
-## more information.
-##
-
-ARRAY_OF_PYOBJ = rffi.CArrayPtr(PyObject)
-PyTupleObjectStruct = lltype.ForwardReference()
-PyTupleObject = lltype.Ptr(PyTupleObjectStruct)
-PyTupleObjectFields = PyObjectFields + \
-    (("items", ARRAY_OF_PYOBJ), ("size", Py_ssize_t))
-cpython_struct("PyTupleObject", PyTupleObjectFields, PyTupleObjectStruct)
-
- at bootstrap_function
-def init_tupleobject(space):
-    "Type description of PyTupleObject"
-    make_typedescr(space.w_tuple.instancetypedef,
-                   basestruct=PyTupleObject.TO,
-                   attach=tuple_attach,
-                   dealloc=tuple_dealloc,
-                   realize=tuple_realize)
 
 PyTuple_Check, PyTuple_CheckExact = build_type_checkers("Tuple")
 
-def new_empty_tuple(space, length):
-    """
-    Allocate a PyTupleObject and its array, but without a corresponding
-    interpreter object.  The array items may be mutated, until
-    tuple_realize() is called.
-    """
-    typedescr = get_typedescr(space.w_tuple.instancetypedef)
-    py_obj = typedescr.allocate(space, space.w_tuple)
-    py_tup = rffi.cast(PyTupleObject, py_obj)
-
-    py_tup.c_items = lltype.malloc(ARRAY_OF_PYOBJ.TO, length,
-                                   flavor='raw', zero=True)
-    py_tup.c_size = length
-    return py_tup
-
-def tuple_attach(space, py_obj, w_obj):
-    """
-    Fills a newly allocated PyTupleObject with the given tuple object.
-    """
-    items_w = space.fixedview(w_obj)
-    py_tup = rffi.cast(PyTupleObject, py_obj)
-    py_tup.c_items = lltype.nullptr(ARRAY_OF_PYOBJ.TO)
-    py_tup.c_size = len(items_w)
-
-def tuple_realize(space, py_obj):
-    """
-    Creates the tuple in the interpreter. The PyTupleObject items array
-    must not be modified after this call.
-    """
-    py_tup = rffi.cast(PyTupleObject, py_obj)
-    # If your CPython extension creates a self-referential tuple
-    # with PyTuple_SetItem(), you loose.
-    c_items = py_tup.c_items
-    items_w = [from_ref(space, c_items[i]) for i in range(py_tup.c_size)]
-    w_obj = space.newtuple(items_w)
-    track_reference(space, py_obj, w_obj)
-    return w_obj
-
- at cpython_api([PyObject], lltype.Void, external=False)
-def tuple_dealloc(space, py_obj):
-    """Frees allocated PyTupleObject resources.
-    """
-    py_tup = rffi.cast(PyTupleObject, py_obj)
-    if py_tup.c_items:
-        for i in range(py_tup.c_size):
-            Py_DecRef(space, py_tup.c_items[i])
-        lltype.free(py_tup.c_items, flavor="raw")
-    from pypy.module.cpyext.object import PyObject_dealloc
-    PyObject_dealloc(space, py_obj)
-
-#_______________________________________________________________________
-
 @cpython_api([Py_ssize_t], PyObject)
 def PyTuple_New(space, size):
-    return rffi.cast(PyObject, new_empty_tuple(space, size))
+    return space.newtuple([space.w_None] * size)
 
 @cpython_api([PyObject, Py_ssize_t, PyObject], rffi.INT_real, error=-1)
-def PyTuple_SetItem(space, ref, pos, ref_item):
-    # XXX steals a reference at the level of PyObjects.  Don't try to
-    # XXX call this function with an interpreter object as ref_item!
-
-    # XXX do PyTuple_Check, without forcing ref as an interpreter object
-    # XXX -- then if it fails it should also steal a reference, test it!!!
-    ref_tup = rffi.cast(PyTupleObject, ref)
-    if not ref_tup.c_items:
-        msg = "PyTuple_SetItem() called on an already-escaped tuple object"
-        raise OperationError(space.w_SystemError, space.wrap(msg))
-    ref_old = ref_tup.c_items[pos]
-    ref_tup.c_items[pos] = ref_item      # SetItem steals a reference!
-    Py_DecRef(space, ref_old)
+def PyTuple_SetItem(space, w_t, pos, w_obj):
+    if not PyTuple_Check(space, w_t):
+        # XXX this should also steal a reference, test it!!!
+        PyErr_BadInternalCall(space)
+    assert isinstance(w_t, W_TupleObject)
+    w_t.wrappeditems[pos] = w_obj
+    Py_DecRef(space, w_obj) # SetItem steals a reference!
     return 0
 
 @cpython_api([PyObject, Py_ssize_t], PyObject)
-def PyTuple_GetItem(space, ref, pos):
-    # XXX do PyTuple_Check, without forcing ref as an interpreter object
-    ref_tup = rffi.cast(PyTupleObject, ref)
-    if ref_tup.c_items:
-        return Reference(ref_tup.c_items[pos])     # borrowed reference
-    else:
-        w_t = from_ref(space, ref)
-        w_obj = space.getitem(w_t, space.wrap(pos))
-        return borrow_from(w_t, w_obj)
-
- at cpython_api([PyObject], Py_ssize_t, error=-1)
-def _PyTuple_Size_Fast(space, ref):
-    # custom version: it's not a macro, so it can be called from other .py
-    # files; but it doesn't include PyTuple_Check()
-    ref_tup = rffi.cast(PyTupleObject, ref)
-    return ref_tup.c_size
+def PyTuple_GetItem(space, w_t, pos):
+    if not PyTuple_Check(space, w_t):
+        PyErr_BadInternalCall(space)
+    assert isinstance(w_t, W_TupleObject)
+    w_obj = w_t.wrappeditems[pos]
+    return borrow_from(w_t, w_obj)
+
+ at cpython_api([PyObject], Py_ssize_t, error=CANNOT_FAIL)
+def PyTuple_GET_SIZE(space, w_t):
+    """Return the size of the tuple p, which must be non-NULL and point to a tuple;
+    no error checking is performed. """
+    assert isinstance(w_t, W_TupleObject)
+    return len(w_t.wrappeditems)
 
 @cpython_api([PyObject], Py_ssize_t, error=-1)
 def PyTuple_Size(space, ref):
     """Take a pointer to a tuple object, and return the size of that tuple."""
-    # XXX do PyTuple_Check, without forcing ref as an interpreter object
-    ref_tup = rffi.cast(PyTupleObject, ref)
-    return ref_tup.c_size
+    if not PyTuple_Check(space, ref):
+        raise OperationError(space.w_TypeError,
+                             space.wrap("expected tuple object"))
+    return PyTuple_GET_SIZE(space, ref)
 
 
 @cpython_api([PyObjectP, Py_ssize_t], rffi.INT_real, error=-1)
-def _PyTuple_Resize(space, refp, newsize):
+def _PyTuple_Resize(space, ref, newsize):
     """Can be used to resize a tuple.  newsize will be the new length of the tuple.
     Because tuples are supposed to be immutable, this should only be used if there
     is only one reference to the object.  Do not use this if the tuple may already
@@ -149,22 +60,18 @@
     this function. If the object referenced by *p is replaced, the original
     *p is destroyed.  On failure, returns -1 and sets *p to NULL, and
     raises MemoryError or SystemError."""
-    # XXX do PyTuple_Check, without forcing ref as an interpreter object
-    # XXX -- then if it fails it should reset refp[0] to null
-    ref_tup = rffi.cast(PyTupleObject, refp[0])
-    c_newitems = lltype.malloc(ARRAY_OF_PYOBJ.TO, newsize,
-                               flavor='raw', zero=True)
-    c_olditems = ref_tup.c_items
-    if not c_olditems:
-        msg = "_PyTuple_Resize() called on an already-escaped tuple object"
-        raise OperationError(space.w_SystemError, space.wrap(msg))
-    oldsize = ref_tup.c_size
-    for i in range(min(oldsize, newsize)):
-        c_newitems[i] = c_olditems[i]
-    # decref items deleted by shrinkage
-    for i in range(newsize, oldsize):
-        Py_DecRef(space, c_olditems[i])
-    ref_tup.c_items = c_newitems
-    ref_tup.c_size = newsize
-    lltype.free(c_olditems, flavor='raw')
+    py_tuple = from_ref(space, ref[0])
+    if not PyTuple_Check(space, py_tuple):
+        PyErr_BadInternalCall(space)
+    assert isinstance(py_tuple, W_TupleObject)
+    py_newtuple = PyTuple_New(space, newsize)
+    
+    to_cp = newsize
+    oldsize = len(py_tuple.wrappeditems)
+    if oldsize < newsize:
+        to_cp = oldsize
+    for i in range(to_cp):
+        py_newtuple.wrappeditems[i] = py_tuple.wrappeditems[i]
+    Py_DecRef(space, ref[0])
+    ref[0] = make_ref(space, py_newtuple)
     return 0

Modified: pypy/branch/fast-forward/pypy/rlib/rerased.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rlib/rerased.py	(original)
+++ pypy/branch/fast-forward/pypy/rlib/rerased.py	Fri Dec  3 19:09:09 2010
@@ -91,7 +91,7 @@
             return annmodel.SomeInteger()
         assert isinstance(s_type, annmodel.SomePBC)
         assert len(s_type.descriptions) == 1
-        clsdef = s_type.descriptions.keys()[0].getuniqueclassdef()
+        clsdef = s_type.any_description().getuniqueclassdef()
         return annmodel.SomeInstance(clsdef)
 
     def specialize_call(self, hop):
@@ -108,7 +108,7 @@
     def compute_result_annotation(self, s_obj, s_type):
         assert isinstance(s_type, annmodel.SomePBC)
         assert len(s_type.descriptions) == 1
-        clsdef = s_type.descriptions.keys()[0].getuniqueclassdef()
+        clsdef = s_type.any_description().getuniqueclassdef()
         s_item = annmodel.SomeInstance(clsdef)
         return self.bookkeeper.newlist(s_item)
 

Modified: pypy/branch/fast-forward/pypy/rpython/lltypesystem/rbuiltin.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/lltypesystem/rbuiltin.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/lltypesystem/rbuiltin.py	Fri Dec  3 19:09:09 2010
@@ -42,7 +42,7 @@
         return hop.genop('cast_pointer', [v_inst],    # v_type implicit in r_result
                          resulttype = hop.r_result.lowleveltype)
 
-    classdef = s_class.descriptions.keys()[0].getuniqueclassdef()
+    classdef = s_class.any_description().getuniqueclassdef()
     return rclass.rtype_new_instance(hop.rtyper, classdef, hop.llops)
 
 def rtype_builtin_hasattr(hop):

Modified: pypy/branch/fast-forward/pypy/rpython/lltypesystem/rclass.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/lltypesystem/rclass.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/lltypesystem/rclass.py	Fri Dec  3 19:09:09 2010
@@ -392,7 +392,7 @@
                 source_classdef = source_desc.getclassdef(None)
                 source_repr = getinstancerepr(self.rtyper, source_classdef)
                 assert len(s_func.descriptions) == 1
-                funcdesc = s_func.descriptions.keys()[0]
+                funcdesc, = s_func.descriptions
                 graph = funcdesc.getuniquegraph()
                 FUNCTYPE = FuncType([Ptr(source_repr.object_type)], Void)
                 destrptr = functionptr(FUNCTYPE, graph.name,

Modified: pypy/branch/fast-forward/pypy/rpython/lltypesystem/rdict.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/lltypesystem/rdict.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/lltypesystem/rdict.py	Fri Dec  3 19:09:09 2010
@@ -581,7 +581,7 @@
 def ll_dict_lookup_clean(d, hash):
     # a simplified version of ll_dict_lookup() which assumes that the
     # key is new, and the dictionary doesn't contain deleted entries.
-    # It only find the next free slot for the given hash.
+    # It only finds the next free slot for the given hash.
     entries = d.entries
     mask = len(entries) - 1
     i = hash & mask

Modified: pypy/branch/fast-forward/pypy/rpython/lltypesystem/rpbc.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/lltypesystem/rpbc.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/lltypesystem/rpbc.py	Fri Dec  3 19:09:09 2010
@@ -127,7 +127,7 @@
     def __init__(self, rtyper, s_pbc):
         self.rtyper = rtyper
         self.s_pbc = s_pbc
-        self.callfamily = s_pbc.descriptions.iterkeys().next().getcallfamily()
+        self.callfamily = s_pbc.any_description().getcallfamily()
         concretetable, uniquerows = get_concrete_calltable(self.rtyper,
                                                            self.callfamily)
         assert len(uniquerows) == 1
@@ -166,7 +166,7 @@
         return self, 0
 
     def get_s_signatures(self, shape):
-        funcdesc = self.s_pbc.descriptions.iterkeys().next()
+        funcdesc = self.s_pbc.any_description()
         return funcdesc.get_s_signatures(shape)
 
     def convert_desc(self, funcdesc):
@@ -230,7 +230,7 @@
         bk = self.rtyper.annotator.bookkeeper
         args = bk.build_args(opname, hop.args_s[1:])
         s_pbc = hop.args_s[0]   # possibly more precise than self.s_pbc
-        descs = s_pbc.descriptions.keys()
+        descs = list(s_pbc.descriptions)
         shape, index = description.FunctionDesc.variant_for_call_site(bk, self.callfamily, descs, args)
         row_of_graphs = self.callfamily.calltables[shape][index]
         anygraph = row_of_graphs.itervalues().next()  # pick any witness

Modified: pypy/branch/fast-forward/pypy/rpython/memory/gc/minimark.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/memory/gc/minimark.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/memory/gc/minimark.py	Fri Dec  3 19:09:09 2010
@@ -652,8 +652,13 @@
         # means recording that they have a smaller size, so that when
         # moved out of the nursery, they will consume less memory.
         # In particular, an array with GCFLAG_HAS_CARDS is never resized.
+        # Also, a nursery object with GCFLAG_HAS_SHADOW is not resized
+        # either, as this would potentially loose part of the memory in
+        # the already-allocated shadow.
         if not self.is_in_nursery(obj):
             return False
+        if self.header(obj).tid & GCFLAG_HAS_SHADOW:
+            return False
         #
         size_gc_header = self.gcheaderbuilder.size_gc_header
         typeid = self.get_type_id(obj)
@@ -1423,12 +1428,21 @@
                     size = self.get_size(obj)
                     shadowhdr = self._malloc_out_of_nursery(size_gc_header +
                                                             size)
-                    # initialize to an invalid tid *without* GCFLAG_VISITED,
-                    # so that if the object dies before the next minor
-                    # collection, the shadow will stay around but be collected
-                    # by the next major collection.
+                    # Initialize the shadow enough to be considered a
+                    # valid gc object.  If the original object stays
+                    # alive at the next minor collection, it will anyway
+                    # be copied over the shadow and overwrite the
+                    # following fields.  But if the object dies, then
+                    # the shadow will stay around and only be freed at
+                    # the next major collection, at which point we want
+                    # it to look valid (but ready to be freed).
                     shadow = shadowhdr + size_gc_header
-                    self.header(shadow).tid = 0
+                    self.header(shadow).tid = self.header(obj).tid
+                    typeid = self.get_type_id(obj)
+                    if self.is_varsize(typeid):
+                        lenofs = self.varsize_offset_to_length(typeid)
+                        (shadow + lenofs).signed[0] = (obj + lenofs).signed[0]
+                    #
                     self.header(obj).tid |= GCFLAG_HAS_SHADOW
                     self.young_objects_shadows.setitem(obj, shadow)
                 #

Modified: pypy/branch/fast-forward/pypy/rpython/memory/gc/test/test_direct.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/memory/gc/test/test_direct.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/memory/gc/test/test_direct.py	Fri Dec  3 19:09:09 2010
@@ -342,6 +342,15 @@
             self.gc.collect()
             assert hash == self.gc.identityhash(self.stackroots[-1])
             self.stackroots.pop()
+        # (7) the same, but the objects are dying young
+        for i in range(10):
+            self.gc.collect()
+            p = self.malloc(VAR, i)
+            self.stackroots.append(p)
+            hash1 = self.gc.identityhash(p)
+            hash2 = self.gc.identityhash(p)
+            assert hash1 == hash2
+            self.stackroots.pop()
 
     def test_memory_alignment(self):
         A1 = lltype.GcArray(lltype.Char)

Modified: pypy/branch/fast-forward/pypy/rpython/memory/gctransform/boehm.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/memory/gctransform/boehm.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/memory/gctransform/boehm.py	Fri Dec  3 19:09:09 2010
@@ -120,10 +120,11 @@
             fptr = self.annotate_finalizer(d['ll_finalizer'], [llmemory.Address], lltype.Void)
         elif destrptr:
             EXC_INSTANCE_TYPE = self.translator.rtyper.exceptiondata.lltype_of_exception_value
+            typename = TYPE.__name__
             def ll_finalizer(addr):
                 exc_instance = llop.gc_fetch_exception(EXC_INSTANCE_TYPE)
                 v = llmemory.cast_adr_to_ptr(addr, DESTR_ARG)
-                ll_call_destructor(destrptr, v)
+                ll_call_destructor(destrptr, v, typename)
                 llop.gc_restore_exception(lltype.Void, exc_instance)
             fptr = self.annotate_finalizer(ll_finalizer, [llmemory.Address], lltype.Void)
         else:

Modified: pypy/branch/fast-forward/pypy/rpython/memory/gctransform/framework.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/memory/gctransform/framework.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/memory/gctransform/framework.py	Fri Dec  3 19:09:09 2010
@@ -1204,9 +1204,10 @@
 
         assert not type_contains_pyobjs(TYPE), "not implemented"
         if destrptr:
+            typename = TYPE.__name__
             def ll_finalizer(addr):
                 v = llmemory.cast_adr_to_ptr(addr, DESTR_ARG)
-                ll_call_destructor(destrptr, v)
+                ll_call_destructor(destrptr, v, typename)
             fptr = self.transformer.annotate_finalizer(ll_finalizer,
                                                        [llmemory.Address],
                                                        lltype.Void)

Modified: pypy/branch/fast-forward/pypy/rpython/memory/gctransform/refcounting.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/memory/gctransform/refcounting.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/memory/gctransform/refcounting.py	Fri Dec  3 19:09:09 2010
@@ -227,7 +227,7 @@
         # refcount is at zero, temporarily bump it to 1:
         gcheader.refcount = 1
         destr_v = cast_pointer(DESTR_ARG, v)
-        ll_call_destructor(destrptr, destr_v)
+        ll_call_destructor(destrptr, destr_v, %r)
         refcount = gcheader.refcount - 1
         gcheader.refcount = refcount
         if refcount == 0:
@@ -239,7 +239,7 @@
     pop_alive(exc_instance)
     # XXX layering of exceptiontransform versus gcpolicy
 
-""" % (body, TYPE._gckind)
+""" % (TYPE.__name__, body, TYPE._gckind)
         else:
             call_del = None
             body = '\n'.join(_static_deallocator_body_for_type('v', TYPE))

Modified: pypy/branch/fast-forward/pypy/rpython/memory/gctransform/support.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/memory/gctransform/support.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/memory/gctransform/support.py	Fri Dec  3 19:09:09 2010
@@ -98,11 +98,15 @@
         hop.exception_cannot_occur()
         return hop.inputconst(hop.r_result.lowleveltype, hop.s_result.const)
 
-def ll_call_destructor(destrptr, destr_v):
+def ll_call_destructor(destrptr, destr_v, typename):
     try:
         destrptr(destr_v)
-    except:
+    except Exception, e:
         try:
-            os.write(2, "a destructor raised an exception, ignoring it\n")
+            os.write(2, "a destructor of type ")
+            os.write(2, typename)
+            os.write(2, " raised an exception ")
+            os.write(2, str(e))
+            os.write(2, " ignoring it\n")
         except:
             pass

Modified: pypy/branch/fast-forward/pypy/rpython/ootypesystem/rpbc.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/ootypesystem/rpbc.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/ootypesystem/rpbc.py	Fri Dec  3 19:09:09 2010
@@ -49,7 +49,7 @@
         return hop.genop('runtimenew', [v_class], resulttype=resulttype)
 
     def getlowleveltype(self):
-        classdescs = self.s_pbc.descriptions.keys()
+        classdescs = list(self.s_pbc.descriptions)
         # if any of the classdefs get the lowleveltype ootype.Class,
         # we can only pick ootype.Class for us too.  Otherwise META.
         for classdesc in classdescs:
@@ -70,7 +70,7 @@
 class MethodImplementations(object):
 
     def __init__(self, rtyper, methdescs):
-        samplemdesc = methdescs.iterkeys().next()
+        samplemdesc = iter(methdescs).next()
         concretetable, uniquerows = get_concrete_calltable(rtyper,
                                              samplemdesc.funcdesc.getcallfamily())
         self.row_mapping = {}
@@ -117,7 +117,7 @@
     concretetable = None # set by _setup_repr_final
 
     def _setup_repr_final(self):
-        sampledesc = self.s_pbc.descriptions.iterkeys().next()
+        sampledesc = self.s_pbc.any_description()
         self.concretetable, _ = get_concrete_calltable(self.rtyper,
                                              sampledesc.funcdesc.getcallfamily())
 

Modified: pypy/branch/fast-forward/pypy/rpython/rpbc.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/rpbc.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/rpbc.py	Fri Dec  3 19:09:09 2010
@@ -15,11 +15,10 @@
 
 from pypy.rpython import callparse
 
-
 def small_cand(rtyper, s_pbc):
     if 1 < len(s_pbc.descriptions) < rtyper.getconfig().translation.withsmallfuncsets and \
            hasattr(rtyper.type_system.rpbc, 'SmallFunctionSetPBCRepr'):
-        callfamily = s_pbc.descriptions.iterkeys().next().getcallfamily()
+        callfamily = s_pbc.any_description().getcallfamily()
         concretetable, uniquerows = get_concrete_calltable(rtyper, callfamily)
         if len(uniquerows) == 1 and (not s_pbc.subset_of or small_cand(rtyper, s_pbc.subset_of)):
             return True
@@ -31,7 +30,7 @@
             return none_frozen_pbc_repr 
         kind = self.getKind()
         if issubclass(kind, description.FunctionDesc):
-            sample = self.descriptions.keys()[0]
+            sample = self.any_description()
             callfamily = sample.querycallfamily()
             if callfamily and callfamily.total_calltable_size > 0:
                 if sample.overridden:
@@ -181,7 +180,7 @@
     def __init__(self, rtyper, s_pbc):
         self.rtyper = rtyper
         self.s_pbc = s_pbc
-        self.callfamily = s_pbc.descriptions.iterkeys().next().getcallfamily()
+        self.callfamily = s_pbc.any_description().getcallfamily()
         if len(s_pbc.descriptions) == 1 and not s_pbc.can_be_None:
             # a single function
             self.lowleveltype = Void
@@ -207,7 +206,7 @@
         return self, 0
 
     def get_s_signatures(self, shape):
-        funcdesc = self.s_pbc.descriptions.iterkeys().next()
+        funcdesc = self.s_pbc.any_description()
         return funcdesc.get_s_signatures(shape)
 
 ##    def function_signatures(self):
@@ -322,7 +321,7 @@
         bk = self.rtyper.annotator.bookkeeper
         args = bk.build_args(opname, hop.args_s[1:])
         s_pbc = hop.args_s[0]   # possibly more precise than self.s_pbc
-        descs = s_pbc.descriptions.keys()
+        descs = list(s_pbc.descriptions)
         shape, index = description.FunctionDesc.variant_for_call_site(bk, self.callfamily, descs, args)
         row_of_graphs = self.callfamily.calltables[shape][index]
         anygraph = row_of_graphs.itervalues().next()  # pick any witness
@@ -368,7 +367,7 @@
     return robject.pyobj_repr
 
 def getFrozenPBCRepr(rtyper, s_pbc):
-    descs = s_pbc.descriptions.keys()
+    descs = list(s_pbc.descriptions)
     assert len(descs) >= 1
     if len(descs) == 1 and not s_pbc.can_be_None:
         return SingleFrozenPBCRepr(descs[0])
@@ -530,7 +529,7 @@
 
     def __init__(self, rtyper, s_pbc):
         self.rtyper = rtyper
-        self.funcdesc = s_pbc.descriptions.keys()[0].funcdesc
+        self.funcdesc = s_pbc.any_description().funcdesc
 
         # a hack to force the underlying function to show up in call_families
         # (generally not needed, as normalizecalls() should ensure this,
@@ -662,7 +661,7 @@
         and the ClassRepr of the class which stores this attribute in
         its vtable.
         """
-        classdescs = self.s_pbc.descriptions.keys()
+        classdescs = list(self.s_pbc.descriptions)
         access = classdescs[0].queryattrfamily(attrname)
         for classdesc in classdescs[1:]:
             access1 = classdesc.queryattrfamily(attrname)
@@ -819,7 +818,7 @@
         if s_pbc.isNone():
             raise TyperError("unsupported: variable of type "
                              "bound-method-object or None")
-        mdescs = s_pbc.descriptions.keys()
+        mdescs = list(s_pbc.descriptions)
         methodname = mdescs[0].name
         classdef = mdescs[0].selfclassdef
         flags    = mdescs[0].flags

Modified: pypy/branch/fast-forward/pypy/rpython/tool/rffi_platform.py
==============================================================================
--- pypy/branch/fast-forward/pypy/rpython/tool/rffi_platform.py	(original)
+++ pypy/branch/fast-forward/pypy/rpython/tool/rffi_platform.py	Fri Dec  3 19:09:09 2010
@@ -673,7 +673,6 @@
 C_HEADER = """
 #include <stdio.h>
 #include <stddef.h>   /* for offsetof() */
-#include <stdint.h>   /* FreeBSD: for uint64_t */
 
 void dump(char* key, int value) {
     printf("%s: %d\\n", key, value);

Modified: pypy/branch/fast-forward/pypy/tool/error.py
==============================================================================
--- pypy/branch/fast-forward/pypy/tool/error.py	(original)
+++ pypy/branch/fast-forward/pypy/tool/error.py	Fri Dec  3 19:09:09 2010
@@ -120,7 +120,7 @@
         msg.append("      (%s getting at the binding!)" % (
             e.__class__.__name__,))
         return
-    for desc in descs.keys():
+    for desc in list(descs):
         func = desc.pyobj
         if func is None:
             r = repr(desc)



More information about the Pypy-commit mailing list