Commits

Alex Gaynor committed 194eeca

fixes for cpyext

  • Participants
  • Parent commits 1011b0c
  • Branches dynamic-specialized-tuple

Comments (0)

Files changed (4)

File pypy/module/cpyext/sequence.py

         isinstance(w_obj, tupleobject.W_TupleObject)):
         return w_obj
     try:
-        return tupleobject.W_TupleObject(space.fixedview(w_obj))
+        return space.newtuple(space.fixedview(w_obj))
     except OperationError:
         raise OperationError(space.w_TypeError, space.wrap(rffi.charp2str(m)))
 

File pypy/module/cpyext/test/test_tupleobject.py

         lltype.free(ar, flavor='raw')
 
     def test_setitem(self, space, api):
-        atuple = space.newtuple([space.wrap(0), space.wrap("hello")])
+        atuple = api.PyTuple_New(2)
         assert api.PyTuple_Size(atuple) == 2
-        assert space.eq_w(space.getitem(atuple, space.wrap(0)), space.wrap(0))
-        assert space.eq_w(space.getitem(atuple, space.wrap(1)), space.wrap("hello"))
         w_obj = space.wrap(1)
         api.Py_IncRef(w_obj)
         api.PyTuple_SetItem(atuple, 1, w_obj)
         assert api.PyTuple_Size(atuple) == 2
-        assert space.eq_w(space.getitem(atuple, space.wrap(0)), space.wrap(0))
         assert space.eq_w(space.getitem(atuple, space.wrap(1)), space.wrap(1))
 
     def test_getslice(self, space, api):

File pypy/module/cpyext/test/test_typeobject.py

             def __init__(self):
                 self.foobar = 32
                 super(UnicodeSubclass2, self).__init__()
-        
+
         newobj = UnicodeSubclass2()
         assert newobj.get_val() == 42
         assert newobj.foobar == 32
         class C(object):
             pass
         assert module.name_by_heaptype(C) == "C"
-        
+
 
 class TestTypes(BaseApiTest):
     def test_type_attributes(self, space, api):
 
         py_type = rffi.cast(PyTypeObjectPtr, ref)
         assert py_type.c_tp_alloc
-        assert from_ref(space, py_type.c_tp_mro).wrappeditems is w_class.mro_w
+        assert space.eq_w(from_ref(space, py_type.c_tp_mro), space.newtuple(w_class.mro_w))
 
         api.Py_DecRef(ref)
 
         w_obj = api._PyType_Lookup(w_type, space.wrap("__invalid"))
         assert w_obj is None
         assert api.PyErr_Occurred() is None
-    
+
 class AppTestSlots(AppTestCpythonExtensionBase):
     def test_some_slots(self):
         module = self.import_extension('foo', [

File pypy/module/cpyext/test/test_unicodeobject.py

                                                 utf_8, None)
         assert space.eq_w(encoded, encoded_obj)
         self.raises(space, api, TypeError, api.PyUnicode_AsEncodedString,
-               space.newtuple([1, 2, 3]), None, None)
+               space.newtuple([space.wrap(1), space.wrap(2), space.wrap(3)]), None, None)
         self.raises(space, api, TypeError, api.PyUnicode_AsEncodedString,
                space.wrap(''), None, None)
         ascii = rffi.str2charp('ascii')
         w_res = api.PyUnicode_AsUTF8String(w_u)
         assert space.type(w_res) is space.w_str
         assert space.unwrap(w_res) == 'sp\xc3\xa4m'
-    
+
     def test_decode_utf8(self, space, api):
         u = rffi.str2charp(u'sp�m'.encode("utf-8"))
         w_u = api.PyUnicode_DecodeUTF8(u, 5, None)
         assert space.type(w_u) is space.w_unicode
         assert space.unwrap(w_u) == u'sp�m'
-        
+
         w_u = api.PyUnicode_DecodeUTF8(u, 2, None)
         assert space.type(w_u) is space.w_unicode
         assert space.unwrap(w_u) == 'sp'
         ustr = "abcdef"
         w_ustr = space.wrap(ustr.decode("ascii"))
         result = api.PyUnicode_AsASCIIString(w_ustr)
-        
+
         assert space.eq_w(space.wrap(ustr), result)
 
         w_ustr = space.wrap(u"abcd\xe9f")