[pypy-commit] pypy all_ordered_dicts: Fix

arigo noreply at buildbot.pypy.org
Fri Jan 16 18:32:13 CET 2015


Author: Armin Rigo <arigo at tunes.org>
Branch: all_ordered_dicts
Changeset: r75396:2cc55683107d
Date: 2015-01-16 18:31 +0100
http://bitbucket.org/pypy/pypy/changeset/2cc55683107d/

Log:	Fix

diff --git a/rpython/rtyper/lltypesystem/lltype.py b/rpython/rtyper/lltypesystem/lltype.py
--- a/rpython/rtyper/lltypesystem/lltype.py
+++ b/rpython/rtyper/lltypesystem/lltype.py
@@ -1031,7 +1031,16 @@
         raise TypeError("can only cast pointers to other pointers")
     if not isinstance(CURTYPE.TO, GcOpaqueType):
         raise TypeError("expected a GcOpaqueType")
-    return opaque_ptr._obj.container.getlength()
+    try:
+        c = opaque_ptr._obj.container
+    except AttributeError:
+        # if 'opaque_ptr' is already some _llgcopaque, hack its length
+        # by casting it to a random GcArray type and hoping
+        from rpython.rtyper.lltypesystem import rffi
+        p = rffi.cast(Ptr(GcArray(Signed)), opaque_ptr)
+        return len(p)
+    else:
+        return c.getlength()
 
 @analyzer_for(length_of_simple_gcarray_from_opaque)
 def ann_length_of_simple_gcarray_from_opaque(s_p):


More information about the pypy-commit mailing list