[pypy-commit] pypy cpyext-injection: fix merge, fix deprecated wrap()

mattip pypy.commits at gmail.com
Fri Mar 24 11:05:48 EDT 2017


Author: Matti Picus <matti.picus at gmail.com>
Branch: cpyext-injection
Changeset: r90802:979ca8d739c9
Date: 2017-03-24 18:04 +0300
http://bitbucket.org/pypy/pypy/changeset/979ca8d739c9/

Log:	fix merge, fix deprecated wrap()

diff --git a/pypy/module/cpyext/injection/_test_module.py b/pypy/module/cpyext/injection/_test_module.py
--- a/pypy/module/cpyext/injection/_test_module.py
+++ b/pypy/module/cpyext/injection/_test_module.py
@@ -22,11 +22,11 @@
 def injected_getitem(space, w_self, index):
     if index > 0:
         intval = space.int_w(w_self)
-        return space.wrap(index * intval)
+        return space.newint(index * intval)
     else:
         org = space.fromcache(Original)
         return space.call_function(org.w_original_getitem, w_self,
-                                   space.wrap(index))
+                                   space.newint(index))
 
 class W_MyThing(W_IntObject):
     def getclass(self, space):
@@ -57,10 +57,10 @@
 def injected_make(space, arg):
     if arg == 15:
         org = space.fromcache(Original)
-        return space.call_function(org.w_original_make, space.wrap(arg))
+        return space.call_function(org.w_original_make, space.newint(arg))
     if arg == 25:
         org = space.fromcache(Original)
-        return space.wrap(W_MyThing(arg))
+        return W_MyThing(arg).spacebind(space)
     return space.w_Ellipsis
 
 
@@ -74,16 +74,16 @@
     org = space.fromcache(Original)
     org.w_original_getitem = dict_w['__getitem__']
     for key, value in injected_methods.items():
-        dict_w[key] = space.wrap(value)
+        dict_w[key] = value.spacebind(space)
 
 def inject_global(space, w_func, name):
     assert name == 'make'
     org = space.fromcache(Original)
     org.w_original_make = w_func
-    return space.wrap(interp_injected_make)
+    return interp_injected_make.spacebind(space)
 
 def inject_module(space, w_mod, name):
     assert name == 'injection'
     org = space.fromcache(Original)
-    w_type = space.getattr(w_mod, space.wrap('test_mytype'))
+    w_type = space.getattr(w_mod, space.newtext('test_mytype'))
     org.w_original_type = w_type
diff --git a/pypy/module/cpyext/injection/numpy.py b/pypy/module/cpyext/injection/numpy.py
--- a/pypy/module/cpyext/injection/numpy.py
+++ b/pypy/module/cpyext/injection/numpy.py
@@ -29,7 +29,7 @@
     def __init__(self, space):
         self.injected_methods_w = []
         for key, value in injected_methods.items():
-            self.injected_methods_w.append((key, space.wrap(value)))
+            self.injected_methods_w.append((key, value.spacebind(space)))
 
 class W_ArrayObject(W_Root):
     def getclass(self, space):
@@ -150,7 +150,7 @@
     w_type = space.appexec([w_mod], """(mod):
         return mod.typeinfo['DOUBLE'][-1]
     """)
-    w_array_type = space.getattr(w_mod, space.wrap('ndarray'))
+    w_array_type = space.getattr(w_mod, space.newtext('ndarray'))
     assert isinstance(w_array_type, W_TypeObject)
     assert isinstance(w_type, W_TypeObject)
     org.w_float64_type = w_type
diff --git a/pypy/module/cpyext/typeobject.py b/pypy/module/cpyext/typeobject.py
--- a/pypy/module/cpyext/typeobject.py
+++ b/pypy/module/cpyext/typeobject.py
@@ -506,7 +506,6 @@
         W_TypeObject.__init__(self, space, name,
             bases_w or [space.w_object], dict_w, force_new_layout=new_layout,
             is_heaptype=flag_heaptype)
-            self.layout.typedef = newtypedef
         self.flag_cpytype = True
         # if a sequence or a mapping, then set the flag to force it
         if pto.c_tp_as_sequence and pto.c_tp_as_sequence.c_sq_item:


More information about the pypy-commit mailing list