Author: Ronan Lamy <[email protected]>
Branch: py3.5
Changeset: r92547:4978206b1665
Date: 2017-10-02 01:53 +0200
http://bitbucket.org/pypy/pypy/changeset/4978206b1665/

Log:    hg merge default

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
@@ -768,7 +768,7 @@
     def __init__(self, method_name, slot_name, function, wrapper1, wrapper2, 
doc):
         self.method_name = method_name
         self.slot_name = slot_name
-        self.slot_names = ("c_" + slot_name).split(".")
+        self.slot_names = tuple(("c_" + slot_name).split("."))
         self.slot_func = function
         self.wrapper_func = wrapper1
         self.wrapper_func_kwds = wrapper2
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
@@ -257,31 +257,19 @@
     # overwrite slots that are already set: these ones are probably
     # coming from a parent C type.
 
-    if w_type.is_heaptype():
-        typedef = None
-        search_dict_w = w_type.dict_w
-    else:
-        typedef = w_type.layout.typedef
-        search_dict_w = None
-
     for method_name, slot_name, slot_names, slot_apifunc in 
slotdefs_for_tp_slots:
         slot_func_helper = None
-        if typedef is not None:
-            # built-in types: expose as many slots as possible, even
-            # if it happens to come from some parent class
-            slot_apifunc = get_slot_tp_function(space, typedef, slot_name)
+        w_descr = w_type.dict_w.get(method_name, None)
+        if w_descr:
+            # use the slot_apifunc (userslots) to lookup at runtime
+            pass
+        elif len(slot_names) ==1:
+            # 'inherit' from tp_base
+            slot_func_helper = getattr(pto.c_tp_base, slot_names[0])
         else:
-            w_descr = search_dict_w.get(method_name, None)
-            if w_descr:
-                # use the slot_apifunc (userslots) to lookup at runtime
-                pass
-            elif len(slot_names) ==1:
-                # 'inherit' from tp_base
-                slot_func_helper = getattr(pto.c_tp_base, slot_names[0])
-            else:
-                struct = getattr(pto.c_tp_base, slot_names[0])
-                if struct:
-                    slot_func_helper = getattr(struct, slot_names[1])
+            struct = getattr(pto.c_tp_base, slot_names[0])
+            if struct:
+                slot_func_helper = getattr(struct, slot_names[1])
 
         if not slot_func_helper:
             if not slot_apifunc:
@@ -290,6 +278,16 @@
             slot_func_helper = slot_apifunc.get_llhelper(space)
         fill_slot(space, pto, w_type, slot_names, slot_func_helper)
 
+def update_all_slots_builtin(space, w_type, pto):
+    typedef = w_type.layout.typedef
+    for method_name, slot_name, slot_names, slot_apifunc in 
slotdefs_for_tp_slots:
+        slot_apifunc = get_slot_tp_function(space, typedef, slot_name)
+        if not slot_apifunc:
+            warn_missing_slot(space, method_name, slot_name, w_type)
+            continue
+        slot_func_helper = slot_apifunc.get_llhelper(space)
+        fill_slot(space, pto, w_type, slot_names, slot_func_helper)
+
 @specialize.arg(3)
 def fill_slot(space, pto, w_type, slot_names, slot_func_helper):
     # XXX special case wrapper-functions and use a "specific" slot func
@@ -702,7 +700,10 @@
         if pto.c_tp_itemsize < pto.c_tp_base.c_tp_itemsize:
             pto.c_tp_itemsize = pto.c_tp_base.c_tp_itemsize
 
-    update_all_slots(space, w_type, pto)
+    if w_type.is_heaptype():
+        update_all_slots(space, w_type, pto)
+    else:
+        update_all_slots_builtin(space, w_type, pto)
     if not pto.c_tp_new:
         base_object_pyo = make_ref(space, space.w_object)
         base_object_pto = rffi.cast(PyTypeObjectPtr, base_object_pyo)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to