Author: Antonio Cuni <[email protected]>
Branch: cpyext-fast-typecheck
Changeset: r94105:b4908ae52515
Date: 2018-03-22 23:41 +0100
http://bitbucket.org/pypy/pypy/changeset/b4908ae52515/

Log:    finally kill all the remainings of the old wrappers :)

diff --git a/pypy/module/cpyext/methodobject.py 
b/pypy/module/cpyext/methodobject.py
--- a/pypy/module/cpyext/methodobject.py
+++ b/pypy/module/cpyext/methodobject.py
@@ -284,39 +284,6 @@
                                    self.w_objclass.name))
 
 
-
-class W_PyCWrapperObjectGeneric(W_PyCWrapperObject):
-    """
-    slow generic implementation, it should die eventually
-    """
-
-    def __init__(self, space, pto, method_name, wrapper_func,
-                 wrapper_func_kwds, doc, func, offset=None):
-        W_PyCWrapperObject.__init__(self, space, pto, method_name, doc, func, 
offset)
-        self.wrapper_func = wrapper_func
-        self.wrapper_func_kwds = wrapper_func_kwds
-
-    def call(self, space, w_self, __args__):
-        #xxx
-        args_w, kw_w = __args__.unpack()
-        w_args = space.newtuple(args_w)
-        w_kw = space.newdict()
-        for key, w_obj in kw_w.items():
-            space.setitem(w_kw, space.newtext(key), w_obj)
-        #
-        func_to_call = self.get_func_to_call()
-        if self.wrapper_func is None:
-            assert self.wrapper_func_kwds is not None
-            return self.wrapper_func_kwds(space, w_self, w_args, func_to_call,
-                                          w_kw)
-        if space.is_true(w_kw):
-            raise oefmt(space.w_TypeError,
-                        "wrapper %s doesn't take any keyword arguments",
-                        self.method_name)
-        return self.wrapper_func(space, w_self, w_args, func_to_call)
-
-
-
 def cmethod_descr_get(space, w_function, w_obj, w_cls=None):
     asking_for_bound = (space.is_none(w_cls) or
                         not space.is_w(w_obj, space.w_None) or
diff --git a/pypy/module/cpyext/slotdefs.py b/pypy/module/cpyext/slotdefs.py
--- a/pypy/module/cpyext/slotdefs.py
+++ b/pypy/module/cpyext/slotdefs.py
@@ -40,29 +40,6 @@
 Py_GT = 4
 Py_GE = 5
 
-
-def check_num_args(space, w_ob, n):
-    from pypy.module.cpyext.tupleobject import PyTuple_CheckExact
-    if not PyTuple_CheckExact(space, w_ob):
-        raise oefmt(space.w_SystemError,
-                    "PyArg_UnpackTuple() argument list is not a tuple")
-    if n == space.len_w(w_ob):
-        return
-    raise oefmt(space.w_TypeError,
-                "expected %d arguments, got %d",
-                n, space.len_w(w_ob))
-
-def check_num_argsv(space, w_ob, low, high):
-    from pypy.module.cpyext.tupleobject import PyTuple_CheckExact
-    if not PyTuple_CheckExact(space, w_ob):
-        raise oefmt(space.w_SystemError,
-                    "PyArg_UnpackTuple() argument list is not a tuple")
-    if low <=space.len_w(w_ob) <= high:
-        return
-    raise oefmt(space.w_TypeError,
-                "expected %d-%d arguments, got %d",
-                low, high, space.len_w(w_ob))
-
 @not_rpython
 def llslot(space, func):
     return func.api_func.get_llhelper(space)
@@ -884,9 +861,10 @@
 missing_wrappers = ['wrap_indexargfunc', 'wrap_delslice', 'wrap_coercefunc']
 for name in missing_wrappers:
     assert name not in globals()
-    def missing_wrapper(space, w_self, w_args, func):
-        print "cpyext: missing slot wrapper " + name
-        raise NotImplementedError("Slot wrapper " + name)
+    class missing_wrapper(W_PyCWrapperObject):
+        def call(self, space, w_self, __args__):
+            print "cpyext: missing slot wrapper " + name
+            raise NotImplementedError("Slot wrapper " + name)
     missing_wrapper.__name__ = name
     globals()[name] = missing_wrapper
 
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
@@ -26,8 +26,7 @@
     )
 from pypy.module.cpyext.methodobject import (W_PyCClassMethodObject,
     PyCFunction_NewEx, PyCFunction, PyMethodDef,
-    W_PyCMethodObject, W_PyCFunctionObject,
-    W_PyCWrapperObject, W_PyCWrapperObjectGeneric)
+    W_PyCMethodObject, W_PyCFunctionObject, W_PyCWrapperObject)
 from pypy.module.cpyext.modsupport import convert_method_defs
 from pypy.module.cpyext.pyobject import (
     PyObject, make_ref, from_ref, get_typedescr, make_typedescr,
@@ -340,20 +339,8 @@
         if wrapper_class is None:
             continue
 
-        # XXX: this is just a quick hack to distinguish the old wrappers from
-        # the new ones: eventually, all of them will be subclasses of
-        # W_PyCWrapperObject
-        if type(wrapper_class) is type and issubclass(wrapper_class, 
W_PyCWrapperObject):
-            # new style
-            w_obj = wrapper_class(space, pto, method_name, doc, func_voidp,
-                                  offset=offset)
-        else:
-            # old style
-            wrapper_func = wrapper_class
-            wrapper_func_kwds = None
-            w_obj = W_PyCWrapperObjectGeneric(space, pto, method_name,  
wrapper_func,
-                                              wrapper_func_kwds, doc,
-                                              func_voidp, offset=offset)
+        assert issubclass(wrapper_class, W_PyCWrapperObject)
+        w_obj = wrapper_class(space, pto, method_name, doc, func_voidp, 
offset=offset)
         dict_w[method_name] = w_obj
     if pto.c_tp_doc:
         dict_w['__doc__'] = space.newtext(
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to