Author: Wim Lavrijsen <[email protected]>
Branch: reflex-support
Changeset: r59906:8b4ea08c6d71
Date: 2013-01-09 15:11 -0800
http://bitbucket.org/pypy/pypy/changeset/8b4ea08c6d71/

Log:    minor bugfix for CINT backend

diff --git a/pypy/module/cppyy/capi/cint_capi.py 
b/pypy/module/cppyy/capi/cint_capi.py
--- a/pypy/module/cppyy/capi/cint_capi.py
+++ b/pypy/module/cppyy/capi/cint_capi.py
@@ -200,16 +200,24 @@
     else:
         # builtin data
         w_leaf = space.call_method(w_self, "GetLeaf", args_w[0])
-        w_typename = space.call_method(w_leaf, "GetTypeName" )
-        from pypy.module.cppyy import capi
-        typename = capi.c_resolve_name(space.str_w(w_typename))
+        space.call_method(w_branch, "GetEntry", space.wrap(0))
+
+        # location
         w_address = space.call_method(w_leaf, "GetValuePointer")
         buf = space.buffer_w(w_address)
         from pypy.module._rawffi import buffer
         assert isinstance(buf, buffer.RawFFIBuffer)
         address = rffi.cast(rffi.CCHARP, buf.datainstance.ll_buffer)
+
+        # placeholder
+        w_typename = space.call_method(w_leaf, "GetTypeName" )
+        from pypy.module.cppyy import capi
+        typename = capi.c_resolve_name(space.str_w(w_typename))
+        w_address = space.call_method(w_leaf, "GetValuePointer")
         from pypy.module._cffi_backend import cdataobj, newtype
         cdata = cdataobj.W_CData(space, address, 
newtype.new_primitive_type(space, typename))
+
+        # cache result
         space.setattr(w_self, space.wrap('_'+attr), space.wrap(cdata))
         return space.getattr(w_self, args_w[0])
 
diff --git a/pypy/module/cppyy/test/test_cint.py 
b/pypy/module/cppyy/test/test_cint.py
--- a/pypy/module/cppyy/test/test_cint.py
+++ b/pypy/module/cppyy/test/test_cint.py
@@ -336,8 +336,8 @@
         mytree.Branch("myd", b, "myd/D")
 
         for i in range(self.N):
-            a[0] = i
-            b[0] = i/2.
+            a[0] = i+1                 # make sure value is different from 
default (0)
+            b[0] = (i+1)/2.            # id. 0.
             mytree.Fill()
         f.Write()
         f.Close()
@@ -351,12 +351,12 @@
         f = TFile(self.fname)
         mytree = f.Get(self.tname)
 
-        i = 0
+        i = 1
         for event in mytree:
             assert event.myi == i
             assert event.myd == i/2.
             i += 1
-        assert i == self.N
+        assert (i-1) == self.N
 
         f.Close()
 
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to