[pypy-svn] r14743 - in pypy/dist/pypy/rpython: . test

pedronis at codespeak.net pedronis at codespeak.net
Mon Jul 18 19:16:51 CEST 2005


Author: pedronis
Date: Mon Jul 18 19:16:49 2005
New Revision: 14743

Modified:
   pypy/dist/pypy/rpython/rdict.py
   pypy/dist/pypy/rpython/rint.py
   pypy/dist/pypy/rpython/test/test_robject.py
Log:
fix newdict for pyobj_repr case. The same dict was reused, oops



Modified: pypy/dist/pypy/rpython/rdict.py
==============================================================================
--- pypy/dist/pypy/rpython/rdict.py	(original)
+++ pypy/dist/pypy/rpython/rdict.py	Mon Jul 18 19:16:49 2005
@@ -290,7 +290,8 @@
 def rtype_newdict(hop):
     r_dict = hop.r_result
     if r_dict == robject.pyobj_repr: # special case: SomeObject: SomeObject dicts!
-        return hop.inputconst(robject.pyobj_repr, {})
+        cdict = hop.inputconst(robject.pyobj_repr, dict)
+        return hop.genop('simple_call', [cdict], resulttype = robject.pyobj_repr)
     if not isinstance(r_dict, StrDictRepr):
         raise rmodel.TyperError("cannot create non-StrDicts, got %r" %(r_dict,))
     c1 = hop.inputconst(lltype.Void, r_dict.lowleveltype)

Modified: pypy/dist/pypy/rpython/rint.py
==============================================================================
--- pypy/dist/pypy/rpython/rint.py	(original)
+++ pypy/dist/pypy/rpython/rint.py	Mon Jul 18 19:16:49 2005
@@ -365,7 +365,8 @@
                                      resulttype=Unsigned)
         if r_to.lowleveltype == Signed:
             return llops.gencapicall('PyInt_AsLong', [v],
-                                     resulttype=Signed)
+                                     resulttype=Signed,
+                                     _callable = lambda pyo: int(pyo._obj.value))
         return NotImplemented
 
 class __extend__(pairtype(IntegerRepr, PyObjRepr)):

Modified: pypy/dist/pypy/rpython/test/test_robject.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_robject.py	(original)
+++ pypy/dist/pypy/rpython/test/test_robject.py	Mon Jul 18 19:16:49 2005
@@ -16,7 +16,10 @@
         d[1] = 'a'
         d['a'] = i
         d['ab'] = c
-        return d
-    res = interpret(f, [1, 'c'])
-    print res
+        d[i] = c
+        return len(d)
+    res = interpret(f, [2, 'c'])
+    assert res == 4
+    res = interpret(f, [3, 'c'])
+    assert res == 4
     



More information about the Pypy-commit mailing list